diff options
Diffstat (limited to 'update.php')
-rwxr-xr-x | update.php | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/update.php b/update.php index aab84bfdb..956aa8548 100755 --- a/update.php +++ b/update.php @@ -9,7 +9,8 @@ require_once "autoload.php"; require_once "functions.php"; - require_once "sanity_check.php"; + + Config::sanity_check(); function make_stampfile($filename) { $fp = fopen(Config::get(Config::LOCK_DIRECTORY) . "/$filename", "w"); @@ -144,10 +145,8 @@ require_once "errorhandler.php"; } - if (!isset($options['update-schema'])) { - if (get_schema_version() != SCHEMA_VERSION) { - die("Schema version is wrong, please upgrade the database (--update-schema).\n"); - } + if (!isset($options['update-schema']) && Config::is_migration_needed()) { + die("Schema version is wrong, please upgrade the database (--update-schema).\n"); } Debug::set_enabled(true); @@ -233,7 +232,7 @@ if (isset($options["update-feed"])) { try { - if (!RSSUtils::update_rss_feed($options["update-feed"], true)) + if (!RSSUtils::update_rss_feed((int)$options["update-feed"], true)) exit(100); } catch (PDOException $e) { @@ -253,7 +252,7 @@ RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : Config::get(Config::DAEMON_FEED_LIMIT), $options); - if (!isset($options["pidlock"]) || $options["task"] == 0) + if (!isset($options["pidlock"]) || $options["task"] == "0") RSSUtils::housekeeping_common(); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, $options); @@ -371,18 +370,7 @@ } if (isset($options["update-schema"])) { - Debug::log("Checking for updates (" . Config::get(Config::DB_TYPE) . ")..."); - - $updater = new DbUpdater(Db::pdo(), Config::get(Config::DB_TYPE), SCHEMA_VERSION); - - if ($updater->is_update_required()) { - Debug::log("Schema update required, version " . $updater->get_schema_version() . " to " . SCHEMA_VERSION); - - if (Config::get(Config::DB_TYPE) == "mysql") - Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". - "Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING."); - else - Debug::log("WARNING: please backup your database before continuing."); + if (Config::is_migration_needed()) { if ($options["update-schema"] != "force-yes") { Debug::log("Type 'yes' to continue."); @@ -390,29 +378,19 @@ if (read_stdin() != 'yes') exit; } else { - Debug::log("Proceeding to update without confirmation..."); + Debug::log("Proceeding to update without confirmation."); } - Debug::log("Performing updates to version " . SCHEMA_VERSION . "..."); - - for ($i = $updater->get_schema_version() + 1; $i <= SCHEMA_VERSION; $i++) { - Debug::log("* Updating to version $i..."); - - $result = $updater->update_to($i, false); - - if ($result) { - Debug::log("* Completed."); - } else { - Debug::log("One of the updates failed. Either retry the process or perform updates manually."); - return; - } + if (!isset($options["log-level"])) { + Debug::set_loglevel(Debug::$LOG_VERBOSE); } - Debug::log("All done."); + $migrations = Config::get_migrations(); + $migrations->migrate(); + } else { Debug::log("Database schema is already at latest version."); } - } if (isset($options["gen-search-idx"])) { @@ -476,7 +454,7 @@ } if (isset($options["debug-feed"])) { - $feed = $options["debug-feed"]; + $feed = (int) $options["debug-feed"]; if (isset($options["force-refetch"])) $_REQUEST["force_refetch"] = true; if (isset($options["force-rehash"])) $_REQUEST["force_rehash"] = true; |