فهرست منبع

Fix and improve actualize_script

See https://github.com/FreshRSS/FreshRSS/issues/730
Marien Fressinaud 11 سال پیش
والد
کامیت
5cdfd6d493
1فایلهای تغییر یافته به همراه28 افزوده شده و 24 حذف شده
  1. 28 24
      app/actualize_script.php

+ 28 - 24
app/actualize_script.php

@@ -12,21 +12,36 @@ if (defined('STDOUT')) {
 	fwrite(STDOUT, 'Starting feed actualization at ' . $begin_date->format('c') . "\n");	//Unbuffered
 	fwrite(STDOUT, 'Starting feed actualization at ' . $begin_date->format('c') . "\n");	//Unbuffered
 }
 }
 
 
-Minz_Configuration::init();
 
 
-$users = listUsers();
-shuffle($users);	//Process users in random order
+// Set the header params ($_GET) to call the FRSS application.
+$_GET['c'] = 'feed';
+$_GET['a'] = 'actualize';
+$_GET['ajax'] = 1;
+$_GET['force'] = true;
+$_SERVER['HTTP_HOST'] = '';
+
+
+$app = new FreshRSS();
+$app->init();
 
 
-if (Minz_Configuration::defaultUser() !== ''){
-	array_unshift($users, Minz_Configuration::defaultUser());	//But always start with admin
+$system_conf = Minz_Configuration::get('system');
+$system_conf->auth_type = 'none';  // avoid necessity to be logged in (not saved!)
+
+// Create the list of users to actualize.
+// Users are processed in a random order but always start with admin
+$users = listUsers();
+shuffle($users);
+if ($system_conf->default_user !== ''){
+	array_unshift($users, $system_conf->default_user);
 	$users = array_unique($users);
 	$users = array_unique($users);
 }
 }
 
 
-$limits = Minz_Configuration::limits();
-$minLastActivity = time() - $limits['max_inactivity'];
 
 
+$limits = $system_conf->limits;
+$minLastActivity = time() - $limits['max_inactivity'];
 foreach ($users as $myUser) {
 foreach ($users as $myUser) {
-	if (($myUser !== Minz_Configuration::defaultUser()) && (FreshRSS_UserDAO::mtime($myUser) < $minLastActivity)) {
+	if (($myUser !== $system_conf->default_user) &&
+			(FreshRSS_UserDAO::mtime($myUser) < $minLastActivity)) {
 		syslog(LOG_INFO, 'FreshRSS skip inactive user ' . $myUser);
 		syslog(LOG_INFO, 'FreshRSS skip inactive user ' . $myUser);
 		if (defined('STDOUT')) {
 		if (defined('STDOUT')) {
 			fwrite(STDOUT, 'FreshRSS skip inactive user ' . $myUser . "\n");	//Unbuffered
 			fwrite(STDOUT, 'FreshRSS skip inactive user ' . $myUser . "\n");	//Unbuffered
@@ -39,31 +54,20 @@ foreach ($users as $myUser) {
 	}
 	}
 	echo $myUser, ' ';	//Buffered
 	echo $myUser, ' ';	//Buffered
 
 
-	$_GET['c'] = 'feed';
-	$_GET['a'] = 'actualize';
-	$_GET['ajax'] = 1;
-	$_GET['force'] = true;
-	$_SERVER['HTTP_HOST'] = '';
-
-	$freshRSS = new FreshRSS();
-
-	Minz_Configuration::_authType('none');
 
 
-	Minz_Session::init('FreshRSS');
 	Minz_Session::_param('currentUser', $myUser);
 	Minz_Session::_param('currentUser', $myUser);
+	$app->run();
 
 
-	$freshRSS->init();
-	$freshRSS->run();
 
 
 	if (!invalidateHttpCache()) {
 	if (!invalidateHttpCache()) {
-		syslog(LOG_NOTICE, 'FreshRSS write access problem in ' . USERS_PATH . '/*/log.txt!');
+		syslog(LOG_NOTICE, 'FreshRSS write access problem in ' . join_path(USERS_PATH, $myUser, 'log.txt'));
 		if (defined('STDERR')) {
 		if (defined('STDERR')) {
-			fwrite(STDERR, 'Write access problem in ' . USERS_PATH . '/*/log.txt!' . "\n");
+			fwrite(STDERR, 'Write access problem in ' . join_path(USERS_PATH, $myUser, 'log.txt') . "\n");
 		}
 		}
 	}
 	}
-	Minz_Session::unset_session(true);
-	Minz_ModelPdo::clean();
 }
 }
+
+
 syslog(LOG_INFO, 'FreshRSS actualize done.');
 syslog(LOG_INFO, 'FreshRSS actualize done.');
 if (defined('STDOUT')) {
 if (defined('STDOUT')) {
 	fwrite(STDOUT, 'Done.' . "\n");
 	fwrite(STDOUT, 'Done.' . "\n");