X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=update.php;h=521b956ad33b7d60311928690ff0da1716864042;hb=59b5d5f3e6df7264349c136b5e981cc355deaa96;hp=be7314175d628df1611c6bd11feba3645b981dc1;hpb=c8784bceecfd4aef7240a3daf07401fb923db804;p=tt-rss.git diff --git a/update.php b/update.php index be731417..521b956a 100755 --- a/update.php +++ b/update.php @@ -36,18 +36,25 @@ "list-plugins", "help"); - foreach ($pluginhost->get_commands() as $command => $data) { + foreach (PluginHost::getInstance()->get_commands() as $command => $data) { array_push($longopts, $command . $data["suffix"]); } $options = getopt("", $longopts); + if (!is_array($options)) { + die("error: getopt() failed. ". + "Most probably you are using PHP CGI to run this script ". + "instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ". + "additional information.\n"); + } + if (count($options) == 0 && !defined('STDIN')) { ?> Tiny Tiny RSS data update script. - + @@ -79,7 +86,7 @@ print " --help - show this help\n"; print "Plugin options:\n"; - foreach ($pluginhost->get_commands() as $command => $data) { + foreach (PluginHost::getInstance()->get_commands() as $command => $data) { $args = $data['arghelp']; printf(" --%-19s - %s\n", "$command $args", $data["description"]); } @@ -148,21 +155,10 @@ } if (isset($options["feeds"])) { - // Update all feeds needing a update. update_daemon_common(); + housekeeping_common(true); - // Update feedbrowser - $count = update_feedbrowser_cache(); - _debug("Feedbrowser updated, $count feeds processed."); - - // Purge orphans and cleanup tags - purge_orphans( true); - - $rc = cleanup_tags( 14, 50000); - _debug("Cleaned $rc cached tags."); - - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); } if (isset($options["feedbrowser"])) { @@ -173,8 +169,9 @@ if (isset($options["daemon"])) { while (true) { $quiet = (isset($options["quiet"])) ? "--quiet" : ""; + $log = isset($options['log']) ? '--log '.$options['log'] : ''; - passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet"); + passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet $log"); _debug("Sleeping for " . DAEMON_SLEEP_INTERVAL . " seconds..."); sleep(DAEMON_SLEEP_INTERVAL); } @@ -185,25 +182,12 @@ _debug("warning: unable to create stampfile\n"); } - // Call to the feed batch update function - // or regenerate feedbrowser cache + update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT); - if (rand(0,100) > 30) { - update_daemon_common(); - } else { - $count = update_feedbrowser_cache(); - _debug("Feedbrowser updated, $count feeds processed."); - - purge_orphans( true); - - $rc = cleanup_tags( 14, 50000); - - _debug("Cleaned $rc cached tags."); - - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op); - } + if (!isset($options["pidlock"]) || $options["task"] == 0) + housekeeping_common(true); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); } if (isset($options["cleanup-tags"])) { @@ -310,7 +294,7 @@ $_REQUEST = $filter; $_SESSION["uid"] = $owner_uid; - $filters = new Pref_Filters( $_REQUEST); + $filters = new Pref_Filters($_REQUEST); $filters->add(); } } @@ -347,7 +331,7 @@ } if (isset($options["list-plugins"])) { - $tmppluginhost = new PluginHost(Db::get()); + $tmppluginhost = new PluginHost(); $tmppluginhost->load_all($tmppluginhost::KIND_ALL); $enabled = array_map("trim", explode(",", PLUGINS)); @@ -368,11 +352,7 @@ } - $pluginhost->run_commands($options); - - if ($lock_handle != false) { - fclose($lock_handle); - } + PluginHost::getInstance()->run_commands($options); if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) unlink(LOCK_DIRECTORY . "/$lock_filename");