diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-08-01 21:00:30 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-08-01 21:00:30 -0700 |
commit | c33b24c9faf5d83e4f1bfc6d3778da6c37139b3f (patch) | |
tree | 0284f35a4d3d58c474e562d5e149ca0d1a212244 /modules/gallery/helpers/gallery_task.php | |
parent | 49eb3e32b9b8df20360ee6ceb388f00828063efa (diff) |
Make maintenance mode a variable instead of a config. Then create
links on the Admin > Maintenance page to allow you to turn it on and
off. This should be efficient since we cache all vars and look them
up on every request anyway.
This also allows us to have the Fix task enable maintenance mode while
it's running which greatly reduces the chances that somebody will come
along and hork the database while we're tinkering with MPTT pointers.
Fixes ticket #1259.
Diffstat (limited to 'modules/gallery/helpers/gallery_task.php')
-rw-r--r-- | modules/gallery/helpers/gallery_task.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index da9fba49..f5c25ddc 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -56,8 +56,8 @@ class gallery_task_Core { $tasks[] = Task_Definition::factory() ->callback("gallery_task::fix") ->name(t("Fix your Gallery")) - ->description(t("Fix up a variety of little problems that might be causing " . - "your Gallery to act a little weird")) + ->description(t("Fix a variety of problems that might cause your Gallery to act " . + "strangely. Requires maintenance mode.")) ->severity(log::SUCCESS); return $tasks; @@ -343,6 +343,10 @@ class gallery_task_Core { $completed = $task->get("completed"); $state = $task->get("state"); + if (!module::get_var("gallery", "maintenance_mode")) { + module::set_var("gallery", "maintenance_mode", 1); + } + // This is a state machine that checks each item in the database. It verifies the following // attributes for an item. // 1. Left and right MPTT pointers are correct @@ -543,6 +547,7 @@ class gallery_task_Core { $task->done = true; $task->state = "success"; $task->percent_complete = 100; + module::set_var("gallery", "maintenance_mode", 0); } else { $task->percent_complete = round(100 * $completed / $total); } |