Skip to content

Commit

Permalink
Fixes Elgg#4643. Prevent someone from running the upgrade script in p…
Browse files Browse the repository at this point in the history
…arallel.
  • Loading branch information
Sem committed Jul 7, 2012
1 parent b2f4650 commit b82e61b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion upgrade.php
Expand Up @@ -20,6 +20,14 @@
require_once(dirname(__FILE__) . "/engine/start.php");

if (get_input('upgrade') == 'upgrade') {

// prevent someone from running the upgrade script in parallel (see #4643)
$upgrade_gatekeeper = elgg_get_data_path() . 'upgrading';
if (file_exists($upgrade_gatekeeper)) {
forward();
}
fclose(fopen($upgrade_gatekeeper, 'w'));

// disable the system log for upgrades to avoid exceptions when the schema changes.
elgg_unregister_event_handler('log', 'systemlog', 'system_log_default_logger');
elgg_unregister_event_handler('all', 'all', 'system_log_listener');
Expand All @@ -33,6 +41,10 @@
elgg_trigger_event('upgrade', 'system', null);
elgg_invalidate_simplecache();
elgg_reset_system_cache();

// critical region has past
unlink($upgrade_gatekeeper);

} else {
// if upgrading from < 1.8.0, check for the core view 'welcome' and bail if it's found.
// see http://trac.elgg.org/ticket/3064
Expand All @@ -53,4 +65,4 @@
exit;
}

forward();
forward();

0 comments on commit b82e61b

Please sign in to comment.