]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #4643. Added unlock upgrade action.
authorSem <sembrestels@riseup.net>
Tue, 17 Jul 2012 00:46:53 +0000 (02:46 +0200)
committerSem <sembrestels@riseup.net>
Tue, 17 Jul 2012 00:46:53 +0000 (02:46 +0200)
actions/admin/site/unlock_upgrade.php [new file with mode: 0644]
engine/lib/admin.php
languages/en.php
upgrade.php
views/default/widgets/control_panel/content.php

diff --git a/actions/admin/site/unlock_upgrade.php b/actions/admin/site/unlock_upgrade.php
new file mode 100644 (file)
index 0000000..b73cf70
--- /dev/null
@@ -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
index b65d98c95720c4ed9721a496a0538327fb27a4b5..4673805f087615d8b294692ec2504703db3d6967 100644 (file)
@@ -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');
 
index 18d0c88d9370666ad93765d7d96719e82cc8b065..159867e2fe4702c27117e7489314abf3eb278f88 100644 (file)
@@ -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
index 38be476a4d9ceb8bb975a349cc3b2db7e2ec7827..e1f3c6b9e5ee0720ba6eb2954842729d4a1b6e3a 100644 (file)
@@ -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");
index d2db54bc64c7587bcf3500f8cdf4642586100c82..e6763d851d5ce93c1a7c0e935a5dead5fbc05e4b 100644 (file)
@@ -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',