X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=update.php;h=9c9c6ae8de742de18d06cd7b5c36638167e7f8f4;hb=9b27cec8c01ff231085bc2045d196ace85e299d9;hp=34357f2f223b370c1762573b7eac0ec097d5478a;hpb=1559e3741c7a823cf0eecee25d751e6553c7af76;p=tt-rss.git diff --git a/update.php b/update.php old mode 100644 new mode 100755 index 34357f2f..9c9c6ae8 --- a/update.php +++ b/update.php @@ -1,157 +1,116 @@ +#!/usr/bin/php Error: your access level is insufficient to run this script.
"; - exit; + + $lock_handle = make_lockfile($lock_filename); + $must_exit = false; + + // Try to lock a file in order to avoid concurrent update. + if (!$lock_handle) { + die("error: Can't create lockfile ($lock_filename). ". + "Maybe another update process is already running.\n"); } - - define('SCHEMA_VERSION', 13); -?> + // Create a database connection. + $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - - -Warning: Please backup your database before proceeding.
"; - - print "Your Tiny Tiny RSS database needs update to the latest - version ($version —> $latest_version).
"; - - /* print "Available incremental updates:"; - - foreach (array_keys($update_versions) as $v) { - if ($v > $version) { - print " $v"; - } - } */ - - print "
"; - - print ""; - - } else if ($op == "do") { - - print "Performing updates (from version $version)...
"; - - $num_updates = 0; - - foreach (array_keys($update_versions) as $v) { - if ($v == $version + 1) { - print "Updating to version $v...
"; - $fp = fopen($update_versions[$v], "r"); - if ($fp) { - while (!feof($fp)) { - $query = trim(getline($fp, ";")); - if ($query != "") { - print "QUERY: $query
"; - db_query($link, $query); - } - } - } - fclose($fp); - - print "Checking version... "; - - $result = db_query($link, "SELECT schema_version FROM ttrss_version"); - $version = db_fetch_result($result, 0, "schema_version"); - - if ($version == $v) { - print "OK! ($version)"; - } else { - print "ERROR!"; - return; - } - - $num_updates++; - } + + if ($op == "-daemon-loop") { + if (!make_stampfile('update_daemon.stamp')) { + die("error: unable to create stampfile\n"); + } + + // Call to the feed batch update function + // or regenerate feedbrowser cache + + if (rand(0,100) > 30) { + update_daemon_common($link); + } else { + $count = update_feedbrowser_cache($link); + _debug("Feedbrowser updated, $count feeds processed."); + + purge_orphans($link, true); + + $rc = cleanup_tags($link, 14, 50000); + + _debug("Cleaned $rc cached tags."); } - - print "
Finished. Performed $num_updates updates up to schema - version $version.
"; - - print ""; - + + } + + if ($op == "-cleanup-tags") { + $rc = cleanup_tags($link, 14, 50000); + print "$rc tags deleted.\n"; } - -?> - - + db_close($link); + unlink(LOCK_DIRECTORY . "/$lock_filename"); +?>