Aleksander Machniak
2016-05-18 930a3ceac0aeb42474fb0a6129517aaa15b794b4
Fix bug where errors could have been not logged when per_user_logging=true
2 files modified
38 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube.php 37 ●●●● patch | view | raw | blame | history
CHANGELOG
@@ -8,6 +8,7 @@
- Managesieve: Support 'duplicate' extension [RFC 7352]
- Managesieve: Unhide advanced rule controls if there are inputs with errors
- Managesieve: Display warning message when filter form contains errors
- Fix bug where errors could have been not logged when per_user_logging=true
RELEASE 1.2.0
-------------
program/lib/Roundcube/rcube.php
@@ -1142,12 +1142,16 @@
        // trigger logging hook
        if (is_object(self::$instance) && is_object(self::$instance->plugins)) {
            $log  = self::$instance->plugins->exec_hook('write_log', array('name' => $name, 'date' => $date, 'line' => $line));
            $log = self::$instance->plugins->exec_hook('write_log',
                array('name' => $name, 'date' => $date, 'line' => $line));
            $name = $log['name'];
            $line = $log['line'];
            $date = $log['date'];
            if ($log['abort'])
            if ($log['abort']) {
                return true;
            }
        }
        // add session ID to the log
@@ -1169,32 +1173,25 @@
        // per-user logging is activated
        if (self::$instance && self::$instance->config->get('per_user_logging', false) && self::$instance->get_user_id()) {
            $log_dir = self::$instance->get_user_log_dir();
            if (empty($log_dir))
            if (empty($log_dir) && $name != 'errors') {
                return false;
            }
        }
        else if (!empty($log['dir'])) {
            $log_dir = $log['dir'];
        }
        else if (self::$instance) {
            $log_dir = self::$instance->config->get('log_dir');
        if (empty($log_dir)) {
            if (!empty($log['dir'])) {
                $log_dir = $log['dir'];
            }
            else if (self::$instance) {
                $log_dir = self::$instance->config->get('log_dir');
            }
        }
        if (empty($log_dir)) {
            $log_dir = RCUBE_INSTALL_PATH . 'logs';
        }
        // try to open specific log file for writing
        $logfile = $log_dir.'/'.$name;
        if ($fp = @fopen($logfile, 'a')) {
            fwrite($fp, $line);
            fflush($fp);
            fclose($fp);
            return true;
        }
        trigger_error("Error writing to log file $logfile; Please check permissions", E_USER_WARNING);
        return false;
        return file_put_contents("$log_dir/$name", $line, FILE_APPEND) !== false;
    }
    /**