aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/admin/site/unlock_upgrade.php23
-rw-r--r--engine/lib/admin.php1
-rw-r--r--languages/en.php3
-rw-r--r--upgrade.php2
-rw-r--r--views/default/widgets/control_panel/content.php32
5 files changed, 55 insertions, 6 deletions
diff --git a/actions/admin/site/unlock_upgrade.php b/actions/admin/site/unlock_upgrade.php
new file mode 100644
index 000000000..b73cf7033
--- /dev/null
+++ b/actions/admin/site/unlock_upgrade.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Unlocks the upgrade script
+ */
+
+// @todo Move this in ElggUpgradeManager::isLocked() when #4682 fixed
+global $CONFIG, $DB_QUERY_CACHE;
+
+$is_locked = count(get_data("show tables like '{$CONFIG->dbprefix}locked'"));
+
+// Invalidate query cache
+if ($DB_QUERY_CACHE) {
+ $DB_QUERY_CACHE->clear();
+ elgg_log("Query cache invalidated", 'NOTICE');
+}
+
+if ($is_locked) {
+ // @todo Move to ElggUpgradeManager::unlock() when #4682 fixed.
+ delete_data("drop table {$CONFIG->dbprefix}locked");
+ error_log('Upgrade unlocks itself');
+}
+system_message(elgg_echo('upgrade:unlock:success'));
+forward(REFERER); \ No newline at end of file
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index b65d98c95..4673805f0 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -233,6 +233,7 @@ function admin_init() {
elgg_register_action('admin/site/update_basic', '', 'admin');
elgg_register_action('admin/site/update_advanced', '', 'admin');
elgg_register_action('admin/site/flush_cache', '', 'admin');
+ elgg_register_action('admin/site/unlock_upgrade', '', 'admin');
elgg_register_action('admin/menu/save', '', 'admin');
diff --git a/languages/en.php b/languages/en.php
index 18d0c88d9..159867e2f 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -1047,6 +1047,9 @@ Once you have logged in, we highly recommend that you change your password.
'upgrading' => 'Upgrading...',
'upgrade:db' => 'Your database was upgraded.',
'upgrade:core' => 'Your Elgg installation was upgraded.',
+ 'upgrade:unlock' => 'Unlock upgrade',
+ 'upgrade:unlock:confirm' => "Somebody is performing an upgrade. You should cancel and wait until upgrade is done. Are you sure you want to continue?",
+ 'upgrade:unlock:success' => "Upgrade unlocked suscessfully.",
'upgrade:unable_to_upgrade' => 'Unable to upgrade.',
'upgrade:unable_to_upgrade_info' =>
'This installation cannot be upgraded because legacy views
diff --git a/upgrade.php b/upgrade.php
index 38be476a4..e1f3c6b9e 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -13,6 +13,7 @@
* @subpackage Upgrade
*/
+// @todo Move to ElggUpgradeManager::lock() when #4628 fixed.
function upgrade_lock() {
global $CONFIG, $DB_QUERY_CACHE;
@@ -35,6 +36,7 @@ function upgrade_lock() {
return false;
}
+// @todo Move to ElggUpgradeManager::unlock() when #4682 fixed.
function upgrade_unlock() {
global $CONFIG;
delete_data("drop table {$CONFIG->dbprefix}locked");
diff --git a/views/default/widgets/control_panel/content.php b/views/default/widgets/control_panel/content.php
index d2db54bc6..e6763d851 100644
--- a/views/default/widgets/control_panel/content.php
+++ b/views/default/widgets/control_panel/content.php
@@ -11,12 +11,32 @@ elgg_register_menu_item('admin_control_panel', array(
'link_class' => 'elgg-button elgg-button-action',
));
-elgg_register_menu_item('admin_control_panel', array(
- 'name' => 'upgrade',
- 'text' => elgg_echo('upgrade'),
- 'href' => 'upgrade.php',
- 'link_class' => 'elgg-button elgg-button-action',
-));
+// @todo Move in this in ElggUpgradeManager::isLocked() when #4682 fixed
+global $CONFIG, $DB_QUERY_CACHE;
+$is_locked = count(get_data("show tables like '{$CONFIG->dbprefix}locked'"));
+// Invalidate query cache
+if ($DB_QUERY_CACHE) {
+ $DB_QUERY_CACHE->clear();
+ elgg_log("Query cache invalidated", 'NOTICE');
+}
+
+if (!$is_locked) {
+ elgg_register_menu_item('admin_control_panel', array(
+ 'name' => 'upgrade',
+ 'text' => elgg_echo('upgrade'),
+ 'href' => 'upgrade.php',
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+} else {
+ elgg_register_menu_item('admin_control_panel', array(
+ 'name' => 'unlock_upgrade',
+ 'text' => elgg_echo('upgrade:unlock'),
+ 'href' => 'action/admin/site/unlock_upgrade',
+ 'is_action' => true,
+ 'link_class' => 'elgg-button elgg-button-delete',
+ 'confirm' => elgg_echo('upgrade:unlock:confirm'),
+ ));
+}
echo elgg_view_menu('admin_control_panel', array(
'class' => 'elgg-menu-hz',