+
+
+ +
From b83a18aeb97d6fb65248d66942ecde009722a680 Mon Sep 17 00:00:00 2001
From: anonymoususer72041
<247563575+anonymoususer72041@users.noreply.github.com>
Date: Sat, 6 Jun 2026 18:02:00 +0200
Subject: [PATCH 1/2] Skip normal module loading while install migrations are
pending
---
lib/ModuleUtility.php | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/ModuleUtility.php b/lib/ModuleUtility.php
index 8a2b70e01..3d638e036 100755
--- a/lib/ModuleUtility.php
+++ b/lib/ModuleUtility.php
@@ -35,6 +35,8 @@
* @package CATS
* @subpackage Library
*/
+include_once(LEGACY_ROOT . '/lib/SchemaMigrationStatus.php');
+
class ModuleUtility
{
/* Prevent this class from being instantiated. */
@@ -508,7 +510,11 @@ private static function processModuleSchema($moduleName, $schema)
if ($moduleName === 'install' && ($currentVersion === NULL || $currentVersion === ''))
{
- /* A NULL install module version means the database came from cats_schema.sql and should not replay historical install migrations. */
+ /* This explicit installer/maintenance finalization is only for
+ * snapshot databases whose schema already matches the bundled
+ * baseline. It must not run during normal requests and is not
+ * proof that an unknown historical database state is current.
+ */
$sql = sprintf(
"UPDATE
module_schema
@@ -521,6 +527,7 @@ private static function processModuleSchema($moduleName, $schema)
);
$db->query($sql);
+ SchemaMigrationStatus::clearCache();
return;
}
@@ -592,6 +599,11 @@ private static function processModuleSchema($moduleName, $schema)
$rs = $db->query($sql);
$currentVersion = $version;
+
+ if ($moduleName === 'install')
+ {
+ SchemaMigrationStatus::clearCache();
+ }
}
}
}
From 4bfd2e1e96662fd0f513cf67df5fc164661c8df8 Mon Sep 17 00:00:00 2001
From: anonymoususer72041
<247563575+anonymoususer72041@users.noreply.github.com>
Date: Sat, 6 Jun 2026 18:03:56 +0200
Subject: [PATCH 2/2] Let site admins run pending migrations from a maintenance
page
---
index.php | 2 ++
js/install.js | 31 +++++++++++++++----
modules/install/CATSUI.php | 28 ++++++++++++++++++
modules/install/Maintenance.tpl | 45 ++++++++++++++++++++++++++++
modules/install/ajax/maint.php | 46 +++++++++++++++++++++--------
modules/login/PendingMigrations.tpl | 2 +-
6 files changed, 134 insertions(+), 20 deletions(-)
create mode 100644 modules/install/Maintenance.tpl
diff --git a/index.php b/index.php
index bee6a6619..ffe4c8a58 100644
--- a/index.php
+++ b/index.php
@@ -160,6 +160,8 @@
(isset($rssPage) && $rssPage) ||
(isset($xmlPage) && $xmlPage);
$isMigrationGateExcluded =
+ (isset($_GET['m']) && $_GET['m'] === 'install' &&
+ isset($_GET['a']) && $_GET['a'] === 'maint') ||
(isset($_GET['m']) && ($_GET['m'] === 'login' || $_GET['m'] === 'logout'));
if ($_SESSION['CATS']->isLoggedIn() &&
diff --git a/js/install.js b/js/install.js
index 035e819de..622e75df6 100755
--- a/js/install.js
+++ b/js/install.js
@@ -29,6 +29,7 @@
var response;
var maxSteps;
var installMaintNextAction = "a=reindexResumes";
+var maintenanceOnly = false;
function setActiveStep(step)
@@ -120,13 +121,31 @@ function Installpage_maint()
response = http.responseText;
+ if (maintenanceOnly &&
+ (http.status < 200 ||
+ http.status >= 300 ||
+ AJAX_isPHPError(response) ||
+ response.indexOf("
Database migrations are pending. OpenCATS should be updated before normal use continues.
+ + + + + + +This maintenance action must be triggered via POST.
', - 'This page starts maintenance mode and related installer tasks.
', - '', - ''; + header('HTTP/1.1 405 Method Not Allowed'); + header('Allow: POST'); die(); } +$installerActive = !file_exists('INSTALL_BLOCK'); + +if (!$installerActive) +{ + /* Fresh installation uses the installer's existing access model. An + * installed system requires an authenticated site admin and CSRF token. + */ + 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(); + + if (!isset($_SESSION['CATS']) || + !$_SESSION['CATS']->isLoggedIn() || + $_SESSION['CATS']->getAccessLevel(ACL::SECOBJ_ROOT) < ACCESS_LEVEL_SA || + !isset($_POST['csrfToken']) || + !$_SESSION['CATS']->isCSRFTokenValid($_POST['csrfToken'])) + { + header('HTTP/1.1 403 Forbidden'); + die('Access denied.'); + } +} + if (file_exists('./modules.cache')) { @unlink('./modules.cache'); } +if (isset($_SESSION['modules'])) +{ + unset($_SESSION['modules']); +} + $maintPage = true; include_once('index.php'); diff --git a/modules/login/PendingMigrations.tpl b/modules/login/PendingMigrations.tpl index 50fa74fc7..21f4bf04a 100644 --- a/modules/login/PendingMigrations.tpl +++ b/modules/login/PendingMigrations.tpl @@ -21,7 +21,7 @@ isAdministrator): ?>Database migrations are pending. OpenCATS should be updated before normal use continues.
-Open the Installation Wizard to complete the upgrade.
+Database maintenance is required before OpenCATS can be used normally. Please contact your administrator.