diff --git a/admin/database_updates.php b/admin/database_updates.php index b31be782b..8a6fe054c 100644 --- a/admin/database_updates.php +++ b/admin/database_updates.php @@ -18,7 +18,7 @@ */ // Check if our database versions are defined -// If undefined, the file is probably being accessed directly rather than called via post.php?update_db or update_cli.php +// If undefined, the file is probably being accessed directly rather than called via update_cli.php if (!defined("LATEST_DATABASE_VERSION") || !defined("CURRENT_DATABASE_VERSION") || !isset($mysqli)) { echo "Cannot access this file directly."; exit(); @@ -27,7 +27,7 @@ if (!defined("LATEST_DATABASE_VERSION") || !defined("CURRENT_DATABASE_VERSION") // Migration files include-guard against this constant define("FROM_DB_UPDATER", true); -// Outputs for the caller (post/update.php, update_cli.php) +// Outputs for the caller (update_cli.php) $database_updates_applied = []; // Versions successfully applied this run $database_updates_error = null; // "version: error message" if a migration failed diff --git a/admin/post/update.php b/admin/post/update.php index 75ed60955..625473754 100644 --- a/admin/post/update.php +++ b/admin/post/update.php @@ -3,11 +3,12 @@ defined('FROM_POST_HANDLER') || die("Direct file access is not allowed"); /* - * Queueing is the ONLY way to update the application. There used to be an ?update handler - * here that ran git pull (or a hard reset) inside this request; it is gone deliberately. - * scripts/update_cli.php replaces the files this request is executing from and then applies - * the migrations that came with them, which is not something to do half way through a page - * load, and a host where PHP cannot run external commands could never do it at all. + * Queueing is the ONLY update path from the web - files and database both. There used to be + * an ?update handler here that ran git pull inside this request, and an ?update_db one that + * ran the migrations; both are gone deliberately. scripts/update_cli.php replaces the files + * this request is executing from and then applies the migrations that came with them, which + * is not something to do half way through a page load, and a host where PHP cannot run + * external commands could never do the first half at all. * * The row is written as well as the settings column: config_update_queued_at is what * cron/app_update.php acts on, and cron_job_run_now is what gets the dispatcher to look @@ -20,9 +21,10 @@ if (isset($_GET['queue_update'])) { enforceAdminPermission(); // The files can be newer than the schema - that is the window this whole page exists to - // close - and the column the queue is written to arrives with a migration + // close - and the column the queue is written to arrives with a migration. There is no + // longer a button that applies migrations on their own, so the way out is the shell. if (!settingsColumnExists($mysqli, 'config_update_queued_at')) { - flashAlert("Apply the database update first - queueing needs a schema change this install has not caught up with yet.", 'error'); + flashAlert("Queueing needs a schema change this install has not caught up with yet - run php scripts/update_cli.php from a shell once, and it will work from then on.", 'error'); redirect(); } @@ -36,27 +38,3 @@ if (isset($_GET['queue_update'])) { redirect(); } - -if (isset($_GET['update_db'])) { - - validateCSRFToken(); - - // Get the current version - require_once ('../includes/database_version.php'); - - // Perform upgrades, if required - populates $database_updates_applied and $database_updates_error - require_once ('database_updates.php'); - - if ($database_updates_error) { - logAudit("Database", "Update", "$session_name ran a database update that failed at $database_updates_error"); - flashAlert("Database update failed at $database_updates_error - the version was not advanced past the last successful update, so it is safe to retry", "error"); - } else { - logAudit("Database", "Update", "$session_name updated the database structure"); - flashAlert("Database structure update successful"); - } - - sleep(1); - - redirect(); - -} diff --git a/admin/update.php b/admin/update.php index 47987aca3..3af7b40f2 100644 --- a/admin/update.php +++ b/admin/update.php @@ -193,25 +193,35 @@ $app_update_available = !empty($pending_commits); first: some releases need manual steps, and this page will not do them for you. - -

- Both are pending. Queueing the update covers both - - cron applies the files and then the migrations they bring, in that order, in one run. -

- - - + +
-
Application files
+
Pending
+

+ Application files: commit behind .

- +

- This server cannot check , so there may - or may not be anything waiting. Queueing an update when there is nothing to do is harmless. + Application files: this server cannot check + , so there may or may not be anything + waiting. Queueing an update when there is nothing to do is harmless. +

+ + + +

+ Database: schema is at + and this code expects + . Parts of the app will error + until the update runs.

@@ -225,43 +235,26 @@ $app_update_available = !empty($pending_commits); Queue Update hands the job to cron, which runs - scripts/update_cli.php in its own process - it updates the files and then the - database, with no request timeout, as the user that owns the files. It resets the files to - , so local changes to them are lost. + scripts/update_cli.php in its own process - it updates the files and then + applies every pending migration, with no request timeout, as the user that owns the + files. It resets the files to , so + local changes to them are lost. A migration that fails part way stops without advancing + the recorded version, so it is safe to queue again once the cause is fixed. Cron is not checking in, so a queued update will sit there until it is. - Apply the database update below first. Queueing an update needs a schema - change this install has not caught up with yet. From a shell, - php scripts/update_cli.php does both in one step. + This install cannot queue yet. Queueing needs a schema change it has not + caught up with, so this one has to be started from a shell: + php scripts/update_cli.php, as the user that owns the files. It updates the + files and the database in one step, and Queue Update works from then on.

- -
-
Database
-

- Schema is at and this code expects - . Parts of the app will error until - this is applied. -

- - Update Database - -

- - A large instance can take a minute or more. If it fails part way it stops without advancing - the recorded version, so it is safe to run again after fixing the cause. - -

-
- -