From 5e9c60752c9a40e1540de50d02e19ba1d06e5491 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 1 Feb 2014 12:23:12 +0100 Subject: [PATCH] =?UTF-8?q?Actualize=20:=20Tol=C3=A8re=20PHP=20lanc=C3=A9?= =?UTF-8?q?=20en=20CGI=20plut=C3=B4t=20que=20CLI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige https://github.com/marienfressinaud/FreshRSS/issues/405 + Message d'erreur en cas de problème de droits dans ./data/ (par exemple si le cron utilise un mauvais utilisateur) --- app/FreshRSS.php | 4 ---- app/actualize_script.php | 23 +++++++++++++++++++---- lib/lib_rss.php | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/FreshRSS.php b/app/FreshRSS.php index c51f91dec..84cf3429b 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -94,10 +94,6 @@ class FreshRSS extends Minz_FrontController { $loginOk = false; break; } - if ((!$loginOk) && (PHP_SAPI === 'cli') && (Minz_Request::actionName() === 'actualize')) { //Command line - Minz_Configuration::_authType('none'); - $loginOk = true; - } } Minz_View::_param ('loginOk', $loginOk); return $loginOk; diff --git a/app/actualize_script.php b/app/actualize_script.php index 9ac80a852..bef9bd218 100755 --- a/app/actualize_script.php +++ b/app/actualize_script.php @@ -8,7 +8,10 @@ if (file_exists($lock) && ((time() - @filemtime($lock)) > 3600)) { } if (($handle = @fopen($lock, 'x')) === false) { syslog(LOG_NOTICE, 'FreshRSS actualize already running?'); - fwrite(STDERR, 'FreshRSS actualize already running?' . "\n"); + if (defined('STDERR')) { + fwrite(STDERR, 'FreshRSS actualize already running?' . "\n"); + } + echo 'FreshRSS actualize already running?', "\n"; return; } register_shutdown_function('unlink', $lock); @@ -32,7 +35,9 @@ $users = array_unique($users); foreach ($users as $myUser) { syslog(LOG_INFO, 'FreshRSS actualize ' . $myUser); - fwrite(STDOUT, 'Actualize ' . $myUser . "...\n"); //Unbuffered + if (defined('STDOUT')) { + fwrite(STDOUT, 'Actualize ' . $myUser . "...\n"); //Unbuffered + } echo $myUser, ' '; //Buffered $_GET['c'] = 'feed'; @@ -44,16 +49,26 @@ foreach ($users as $myUser) { $freshRSS = new FreshRSS(); $freshRSS->_useOb(false); + Minz_Configuration::_authType('none'); + Minz_Session::init('FreshRSS'); Minz_Session::_param('currentUser', $myUser); $freshRSS->init(); $freshRSS->run(); - invalidateHttpCache(); + if (!invalidateHttpCache()) { + syslog(LOG_NOTICE, 'FreshRSS write access problem in ' . LOG_PATH . '/*.log!'); + if (defined('STDERR')) { + fwrite(STDERR, 'Write access problem in ' . LOG_PATH . '/*.log!' . "\n"); + } + } Minz_Session::unset_session(true); Minz_ModelPdo::clean(); } syslog(LOG_INFO, 'FreshRSS actualize done.'); +if (defined('STDOUT')) { + fwrite(STDOUT, 'Done.' . "\n"); +} +echo 'End.', "\n"; ob_end_flush(); -fwrite(STDOUT, 'Done.' . "\n"); diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 1bb117ab6..a13d9e951 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -214,8 +214,8 @@ function uSecString() { } function invalidateHttpCache() { - touch(LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log'); Minz_Session::_param('touch', uTimeString()); + return touch(LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log'); } function usernameFromPath($userPath) {