From 8a4eecbcb00eea109c0bd24475e08036ae698eac Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 24 Oct 2021 15:53:47 +0200 Subject: [PATCH] Don't write stats info to console.log when in CLI If the file was created by the web server user, user executing the CLI command might have no permissions. This leads to an error, and e.g. when installing a plugin/skin via composer is converted to an ugly exception. We want to prevent that. Anyway, these stats are most useful for the webmail use not for CLI commands. --- program/include/rcmail.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/program/include/rcmail.php b/program/include/rcmail.php index f88626570..f12fabc28 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -1186,6 +1186,12 @@ class rcmail extends rcube $this->address_books = []; + // In CLI stop here, prevent from errors when the console.log might exist, + // but be not accessible + if (php_sapi_name() == 'cli') { + return; + } + // write performance stats to logs/console if ($this->config->get('devel_mode') || $this->config->get('performance_stats')) { // we have to disable per_user_logging to make sure stats end up in the main console log