feat: run pending schema migrations from the admin UI - #834
feat: run pending schema migrations from the admin UI#834anonymoususer72041 wants to merge 2 commits into
Conversation
RussH
left a comment
There was a problem hiding this comment.
My review shows that this duplicates some of the existing AJAX bootstrap and security handling. Could you make one small change before we merge?
In modules/install/ajax/maint.php, the config, session and CSRF setup is being handled again locally:
include_once('./config.php');
include_once(LEGACY_ROOT . '/constants.php');
include_once(LEGACY_ROOT . '/lib/DatabaseConnection.php');
include_once(LEGACY_ROOT . '/lib/Session.php');
@session_name(CATS_SESSION_NAME);
@session_start();The request already comes through the existing ajax.php dispatcher via AJAX_callCATSFunction(), which loads the required dependencies, starts the session and validates the CSRF token. We also now have the shared ajax/bootstrap.php, which is used by other direct AJAX endpoints.
Could we remove the duplicated bootstrap, session and CSRF handling here, and leave this endpoint responsible only for its maintenance-specific checks, particularly confirming that the user is logged in and has SA access?
That should keep the security behaviour in one place and follow the existing OpenCATS AJAX pattern.
Once this is done, good to merge!
Summary
Adds a dedicated maintenance page (
?m=install&a=maint) reachable through the existing "Maintenance Required" notice, so a logged-in site administrator can bring an already-installed database up to the current schema without leaving the application for the Installation Wizard.modules/install/CATSUI.phpnow handlesa=maint: gates on a logged-in SA session, no-ops when no migrations are pending, and renders the newMaintenance.tpl.modules/install/Maintenance.tplprovides a standalone progress page (CSRF token, lib.js, install.js, install.css) with a Start button and progress bar.modules/install/ajax/maint.phpgains an installed-system auth path: whenINSTALL_BLOCKexists it requires a logged-in SA session and a valid CSRF token; the fresh-installer path is unchanged.js/install.jsadds amaintenanceOnlyflag so the chunkedInstallpage_maintloop redirects toindex.phpon completion and surfaces an error block instead of continuing into installer-only steps (a=reindexResumes, etc.).lib/ModuleUtility.phpcallsSchemaMigrationStatus::clearCache()after each applied install migration and after the NULL-snapshot finalization, so the pending-migration gate re-evaluates on the next request.index.phpexcludes?m=install&a=maintfrom the pending-migration page gate;modules/login/PendingMigrations.tplnow links to that page instead ofinstallwizard.php.Motivation
Since #803, OpenCATS blocks all logged-in, non-public requests while install schema migrations are pending and points admins at the Installation Wizard. For an existing installation that only needs a schema upgrade, the wizard is heavier than necessary: it re-enters the full installer flow (questions, demo data, reindex) and forces the admin out of the application UI. This PR gives admins a focused, in-app path that runs the same chunked migration runner and returns them to the application once the database is current.