From 6d16c39b7eff0eb4e7283e2b768a0608752f4b7b Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 2 Oct 2016 13:52:52 +0000 Subject: [PATCH] dbstructure now switches in the maintenance mode when updating --- include/dbstructure.php | 6 ++++++ include/poller.php | 8 ++++++++ mod/maintenance.php | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/include/dbstructure.php b/include/dbstructure.php index 0c933c6648..6224b434d8 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -126,6 +126,9 @@ function print_structure($database, $charset) { function update_structure($verbose, $action, $tables=null, $definition=null) { global $a, $db; + if ($action) + set_config('system', 'maintenance', 1); + if (isset($a->config["system"]["db_charset"])) $charset = $a->config["system"]["db_charset"]; else @@ -241,6 +244,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } } + if ($action) + set_config('system', 'maintenance', 0); + return $errors; } diff --git a/include/poller.php b/include/poller.php index ce2a6be0fa..fe4d4245af 100644 --- a/include/poller.php +++ b/include/poller.php @@ -29,6 +29,10 @@ function poller_run(&$argv, &$argc){ unset($db_host, $db_user, $db_pass, $db_data); }; + // Quit when in maintenance + if (get_config('system', 'maintenance', true)) + return; + $a->start_process(); $mypid = getmypid(); @@ -71,6 +75,10 @@ function poller_run(&$argv, &$argc){ while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority`, `created` LIMIT 1")) { + // Quit when in maintenance + if (get_config('system', 'maintenance', true)) + return; + // Constantly check the number of parallel database processes if ($a->max_processes_reached()) return; diff --git a/mod/maintenance.php b/mod/maintenance.php index b50c94c9b9..3d21ce40b7 100644 --- a/mod/maintenance.php +++ b/mod/maintenance.php @@ -1,6 +1,10 @@ t('System down for maintenance') ));