}
}
- $installedversion = get_config($plugin->fullname, 'version');
+ // try to recover from interrupted install.php if needed
+ if (file_exists($fullplug.'/db/install.php')) {
+ if (get_config($plugin->fullname, 'installrunning')) {
+ require_once($fullplug.'/db/install.php');
+ $recover_install_function = 'xmldb_'.$plugin->fullname.'_install_recovery';
+ if (function_exists($recover_install_function)) {
+ $startcallback($component, true, $verbose);
+ $recover_install_function();
+ unset_config('installrunning', 'block_'.$plugin->fullname);
+ update_capabilities($component);
+ events_update_definition($component);
+ message_update_providers($component);
+ $endcallback($component, true, $verbose);
+ }
+ }
+ }
+ $installedversion = get_config($plugin->fullname, 'version');
if (empty($installedversion)) { // new installation
$startcallback($component, true, $verbose);
if (file_exists($fullplug.'/db/install.xml')) {
$DB->get_manager()->install_from_xmldb_file($fullplug.'/db/install.xml');
}
+
+ /// store version
+ upgrade_plugin_savepoint(true, $plugin->version, $type, $plug, false);
+
/// execute post install file
if (file_exists($fullplug.'/db/install.php')) {
require_once($fullplug.'/db/install.php');
+ set_config('installrunning', 1, 'block_'.$plugin->fullname);
$post_install_function = 'xmldb_'.$plugin->fullname.'_install';;
$post_install_function();
+ unset_config('installrunning', 'block_'.$plugin->fullname);
}
- /// store version
- upgrade_plugin_savepoint(true, $plugin->version, $type, $plug, false);
-
/// Install various components
update_capabilities($component);
events_update_definition($component);
$currmodule = $DB->get_record('modules', array('name'=>$module->name));
+ if (file_exists($fullmod.'/db/install.php')) {
+ if (get_config($module->name, 'installrunning')) {
+ require_once($fullmod.'/db/install.php');
+ $recover_install_function = 'xmldb_'.$module->name.'_install_recovery';
+ if (function_exists($recover_install_function)) {
+ $startcallback($component, true, $verbose);
+ $recover_install_function();
+ unset_config('installrunning', $module->name);
+ // Install various components too
+ update_capabilities($component);
+ events_update_definition($component);
+ message_update_providers($component);
+ $endcallback($component, true, $verbose);
+ }
+ }
+ }
+
if (empty($currmodule->version)) {
$startcallback($component, true, $verbose);
/// Post installation hook - optional
if (file_exists("$fullmod/db/install.php")) {
require_once("$fullmod/db/install.php");
+ // Set installation running flag, we need to recover after exception or error
+ set_config('installrunning', 1, $module->name);
$post_install_function = 'xmldb_'.$module->name.'_install';;
$post_install_function();
+ unset_config('installrunning', $module->name);
}
/// Install various components
$currblock = $DB->get_record('block', array('name'=>$block->name));
+ if (file_exists($fullblock.'/db/install.php')) {
+ if (get_config('block_'.$blockname, 'installrunning')) {
+ require_once($fullblock.'/db/install.php');
+ $recover_install_function = 'xmldb_block_'.$blockname.'_install_recovery';
+ if (function_exists($recover_install_function)) {
+ $startcallback($component, true, $verbose);
+ $recover_install_function();
+ unset_config('installrunning', 'block_'.$blockname);
+ // Install various components
+ update_capabilities($component);
+ events_update_definition($component);
+ message_update_providers($component);
+ $endcallback($component, true, $verbose);
+ }
+ }
+ }
+
if (empty($currblock->version)) { // block not installed yet, so install it
// If it allows multiples, start with it enabled
if (file_exists($fullblock.'/db/install.php')) {
require_once($fullblock.'/db/install.php');
+ // Set installation running flag, we need to recover after exception or error
+ set_config('installrunning', 1, 'block_'.$blockname);
$post_install_function = 'xmldb_block_'.$blockname.'_install';;
$post_install_function();
+ unset_config('installrunning', 'block_'.$blockname);
}
$blocktitles[$block->name] = $blocktitle;
if (!$tables = $DB->get_tables() ) { // No tables yet at all.
return false;
-
+
} else { // Check for missing main tables
$mtables = array('config', 'course', 'groupings'); // some tables used in 1.9 and 2.0, preferable something from the start and end of install.xml
foreach ($mtables as $mtable) {
}
}
return true;
- }
+ }
}