Commit 775f811a authored by skodak's avatar skodak
Browse files

MDL-16002 rewritten upgrade locking and better upgrade progress tracking;...

MDL-16002 rewritten upgrade locking and better upgrade progress tracking; MDL-16070 Do not use $a[0] syntax in lang packs + various other upgrade improvements and fixes
parent 9deded34
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_search_forums_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_search_forums_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_section_links_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_section_links_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_social_activities_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_social_activities_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -69,7 +69,7 @@ visit the admin page.
The function must look like:
function xmldb_format_yourformat_upgrade($oldversion=0) {
function xmldb_format_yourformat_upgrade($oldversion) {
...
* yourformat/version.php
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_enrol_authorize_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_enrol_authorize_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
//===== 1.9.0 upgrade line ======//
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_enrol_paypal_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_enrol_paypal_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -733,6 +733,7 @@ $string['upgradesure'] = 'Your Moodle files have been changed, and you are about
Once you do this you can not go back again. <br /><br />
Please note that this process can take a long time. <br /><br />
Are you sure you want to upgrade this server to this version?';
$string['upgradetimedout'] = 'Upgrade timed out, please restart the upgrade.';
$string['upgradingdata'] = 'Upgrading data';
$string['upgradinglogs'] = 'Upgrading logs';
$string['uploaduserspreview'] = 'Upload users preview';
......
......@@ -29,9 +29,7 @@ $string['cannotaccesspresentsother'] = 'You are not allowed to access presets fr
$string['cannotadd'] = 'Can not add entries!';
$string['cannotdeletepreset'] = 'Error deleting a preset!';
$string['cannotrate'] = 'Rating of items not allowed!';
$string['cannotupdaterate'] = 'Could not update an old rating ($a[0] = $a[1])';
$string['cannotunziptopreset'] = 'Cannot unzip to the preset directory';
$string['cannotinsertrate'] = 'Could not insert a new rating ($a[0] = $a[1])';
$string['cannotinsertempty'] = 'Could not make an empty record!';
$string['cancel'] = 'Cancel';
$string['checkbox'] = 'Checkbox';
......
......@@ -3,10 +3,11 @@
* debug information for developer only
*/
$string['authpluginnotfound'] = 'Authentication plugin $a not found.';
$string['blocknotexist'] = '$a block doesn\'t exist';
$string['cannotbenull'] = '$a cannot be null!';
$string['cannotcreateadminuser'] = 'SERIOUS ERROR: Could not create admin user record !!!';
$string['cannotdowngrade'] = 'Cannot downgrade from $a[0] to $a[1].';
$string['cannotinitpage'] = 'Cannot fully initialize page: invalid $a[0] id $a[1]';
$string['cannotdowngrade'] = 'Cannot downgrade from $a->oldversion to $a->newversion.';
$string['cannotinitpage'] = 'Cannot fully initialize page: invalid $a->name id $a->id';
$string['cannotupgradecapabilities'] = 'Had trouble upgrading the core capabilities for the Roles System';
$string['cannotupdateversion'] = 'Upgrade failed! (Could not update version in config table)';
$string['cannotupdaterelease'] = 'ERROR: Could not update release version in database!!';
......@@ -21,9 +22,10 @@ $string['dbnotsupport'] = 'Error: Your database ($a) is not yet fully supported
$string['dbnotsetup'] = 'Error: Main databases NOT set up successfully';
$string['doesnotworkwitholdversion'] = 'This script does not work with this old version of Moodle';
$string['erroroccur'] = 'An error has occurred during this process';
$string['fixsetting'] = 'Please fix your settings in config.php: <p>You have:</p> <p>\$CFG->dirroot = \"$a[0]\";</p> <p>but it should be:</p> <p>\$CFG->dirroot = \"$a[1]\"</p>';
$string['fixsetting'] = 'Please fix your settings in config.php: <p>You have:</p> <p>\$CFG->dirroot = \"$a->current\";</p> <p>but it should be:</p> <p>\$CFG->dirroot = \"$a->found\"</p>';
$string['invalideventdata'] = 'Incorrect eventadata submitted: $a';
$string['invalidarraysize'] = 'Incorrect size of arrays in params of $a';
$string['missingconfigversion'] = 'Config table does not contain version, can not continue, sorry.';
$string['mustbeoveride'] = 'Abstract $a method must be overriden.';
$string['morethanonerecordinfetch'] = 'Found more than one record in fetch() !';
$string['noadminrole'] = 'No admin role could be found';
......@@ -37,16 +39,13 @@ $string['nopageclass'] = 'Imported $a but found no page classes';
$string['noreports'] = 'No reports accessible';
$string['nomodules'] = 'No modules found!!';
$string['modulenotexist'] = '$a module doesn\'t exist';
$string['phpvaroff'] = 'The PHP server variable \'$a[0]\' should be Off - $a[1]';
$string['phpvaron'] = 'The PHP server variable \'$a[0]\' is not turned On - $a[1]';
$string['prefixcannotbeempty'] = 'Table prefix \"$a[0]\" cannot be empty for your target DB ($a[1])'; // obsoleted 2.0
$string['prefixlimit'] = 'Table prefix \"$a\" maximum allowed length for Oracle DBs is 2cc.'; // obsoleted in 2.0
$string['withoutversion'] = 'Main version.php was not readable or specified';
$string['phpvaroff'] = 'The PHP server variable \'$a->name\' should be Off - $a->link';
$string['phpvaron'] = 'The PHP server variable \'$a->name\' is not turned On - $a->link';
$string['sessionmissing'] = '$a object missing from session';
$string['siteisnotdefined'] = 'Site is not defined!';
$string['sqlrelyonobsoletetable'] = 'This SQL relies on obsolete table(s): $a! Your code must be fixed by a developer.';
$string['upgradefail'] = 'Upgrade failed! see: $a';
$string['withoutversion'] = 'Main version.php was not readable or specified';
$string['withoutversion'] = 'Main version.php file is missing, not readable or broken.';
$string['xmlizeunavailable'] = 'xmlize functions are not available';
?>
......@@ -8,10 +8,10 @@ $string['blockdoesnotexist'] = 'This block does not exist';
$string['blockcannotinistantiate'] = 'Problem in instantiating block object';
$string['blockcannotread'] = 'Could not read data for blockid= $a ';
$string['blockcannotconfig'] = 'This block does not support global configuration';
$string['blocknameconflict'] = 'Naming conflict: block $a[0] has the same title with an existing block: $a[1]!';
$string['blocknameconflict'] = 'Naming conflict: block $a->name has the same title with an existing block: $a->conflict!';
$string['backupcontainexternal'] = 'This backup file contains external Moodle Network Hosts that are not configured locally';
$string['backuptablefail'] = 'Backup tables could NOT be set up successfully!';
$string['boundsyntaxnotsupport'] = 'Pg $1, $2 bound syntax not supported yet :-(';
$string['boundsyntaxnotsupport'] = 'Pg \$1, \$2 bound syntax not supported yet :-(';
$string['cannotassignanthing'] = 'Cannot assign moodle/site:doanything';
$string['cannotassignrole'] = 'Cannot assign role in course';
$string['cannotassignselfasparent'] = 'Cannot assign self as parent!';
......@@ -23,9 +23,9 @@ $string['cannotaddrss'] = 'You do not have permission to add rss feeds';
$string['cannotaddmodule'] = '$a module could not be added to the module list!';
$string['cannotaddnewmodule'] = 'Could not add a new module of $a';
$string['cannotaddnewinstance'] = 'Could not add a new instance of $a';
$string['cannotsaveconfig'] = 'Problem saving config \"$a[0]\" as \"$a[1]\" for plugin \"$a[2]\"';
$string['cannotsaveconfig'] = 'Problem saving config \"$a->name\" as \"$a=>value\" for plugin \"$a->plugin\"';
$string['cannotsavecomment'] = 'Cannot save comment';
$string['cannotsavefile'] = 'Cannot save the file\"$a[0]\/$a[1]\"!';
$string['cannotsavefile'] = 'Cannot save the file \"$a\"!';
$string['cannotsavedata'] = 'Cannot save data';
$string['cannotsaveagreement'] = 'Could not save your agreement';
$string['cannotcallscript'] = 'You cannot call this script in that way';
......@@ -103,12 +103,11 @@ $string['cannotresetguestpwd'] = 'You cannot reset the guest password';
$string['cannotresetmail'] = 'Error resetting password and mailing you';
$string['cannotsaveblock'] = 'Error saving block configuration';
$string['cannotsavefile'] = 'Cannot save the file \"$a\"';
$string['cannotinitpage'] = 'Cannot quickly initialize page, course id: $a';
$string['cannotinsertcategory'] = 'Weird error. The category was not inserted.';
$string['cannotinsertcomment'] = 'Could not insert this new comment';
$string['cannotinsertgrade'] = 'Cannot insert grade item without course id!';
$string['cannotinsertrecord'] = 'Could not insert new record ID $a';
$string['cannotinsertrate'] = 'Could not insert a new rating ($a[0] = $a[1])';
$string['cannotinsertrate'] = 'Could not insert a new rating ($a->id = $a->rating)';
$string['cannotinsertkey'] = 'Cannot insert new key';
$string['cannotsavecomment'] = 'Error while saving comment';
$string['cannotsavemd5file'] = 'Cannot save md5 file';
......@@ -133,6 +132,7 @@ $string['cannotupdatecm'] = 'Could not update the course module with the correct
$string['cannotupdatefield'] = 'Error updating field';
$string['cannotupdatelevel'] = 'Could not update the indent level on that course module';
$string['cannotupdategroup'] = 'Error updating group';
$string['cannotupdaterate'] = 'Could not update an old rating ($a->id = $a->rating)';
$string['cannotupdaterecord'] = 'Could not update record ID $a';
$string['cannotupdaterole'] = 'Cannot update role!';
$string['cannotupdatemod'] = 'Could not update $a';
......@@ -152,7 +152,7 @@ $string['cannotuploadfile'] = 'Error processing upload file';
$string['cannotuseadmin'] = 'You need to be an admin user to use this page';
$string['cannotuseadminadminorteacher'] = 'You need to be a teacher or admin user to use this page';
$string['cannotunassignrolefrom'] = 'Cannot unassign this user from role id: $a';
$string['cannotunassigncap'] = 'Could not unassign deprecated capability $a[0] from role $a[1]';
$string['cannotunassigncap'] = 'Could not unassign deprecated capability $a->cap from role $a->role';
$string['cannotrestoreadminorcreator'] = 'You need to be a creator or admin user to restore into new course!';
$string['cannotrestoreadminoredit'] = 'You need to be a editing teacher or admin user to restore into selected course!';
$string['cannotusepage'] = 'Only teachers and administrators can use this page';
......@@ -207,7 +207,7 @@ $string['expiredkey'] = 'Expired key';
$string['failtoloadblocks'] = 'One or more blocks are registered in the database, but they all failed to load!';
$string['fieldrequired'] = '\"$a\" is a required field';
$string['filenotfound'] = 'Sorry, the requested file could not be found';
$string['filemismatch'] = 'Non-core file name mismatch. The file \"$a[0]\" should be {$a[1]}{$a[2]}.php';
$string['filemismatch'] = 'Non-core file name mismatch. The file \"$a->current\" should be $a->file';
$string['filternotinstalled'] = 'Filter $a is not currently installed';
$string['filternotactive'] = 'Filter $a is not currently active';
$string['forumblockingtoomanyposts'] = 'You have exceeded the posting threshold set for this forum';
......@@ -436,6 +436,7 @@ $string['usernotupdatednotexists'] = 'User not updated - does not exist';
$string['updatersserror'] = 'There was an error trying to update RSS feed with id: $a';
$string['upgradeversionfail'] = 'Upgrade of backup system failed! (Could not update version in config table.)';
$string['upgradefail'] = 'Upgrade failed! $a';
$string['upgraderunning'] = 'Site is being upgraded, please retry later.';
$string['younotteacher'] = 'You are not a teacher!';
$string['wrongcall'] = 'This script is called wrongly';
$string['wrongcontextid'] = 'Context ID was incorrect (cannot find it)';
......
......@@ -37,8 +37,6 @@ $string['cannotaddsubscriber'] = 'Could not add subscriber with id $a to this fo
$string['cannotremovesubscriber'] = 'Could not remove subscriber with id $a from this forum!';
$string['cannotfindorcreateforum'] = 'Could not find or create a main news forum for the site';
$string['cannotfindfirstpost'] = 'Could not find the first post in this forum';
$string['cannotupdaterate'] = 'Could not update an old rating ($a[0] = $a[1])';
$string['cannotinsertrate'] = 'Could not insert a new rating ($a[0] = $a[1])';
$string['cannottrack'] = 'Could not stop tracking that forum';
$string['cleanreadtime'] = 'Mark old posts as read hour';
$string['completiondiscussions'] = 'User must create discussions:';
......
......@@ -3184,7 +3184,7 @@ function capabilities_cleanup($component, $newcapdef=NULL) {
if ($roles = get_roles_with_capability($cachedcap->name)) {
foreach($roles as $role) {
if (!unassign_capability($cachedcap->name, $role->id)) {
print_error('cannotunassigncap', '', '', array($cachedcap->name, $role->name));
print_error('cannotunassigncap', 'error', '', (object)array('cap'=>$cachedcap->name, 'role'=>$role->name));
}
}
}
......
......@@ -26,20 +26,55 @@ require_once($CFG->libdir.'/xmldb/xmldb_statement.php');
require_once($CFG->libdir.'/xmlize.php');
require_once($CFG->libdir .'/messagelib.php'); // Messagelib functions
global $upgradeloghandle, $upgradelogbuffer;
$upgradeloghandle = false;
$upgradelogbuffer = '';
/**
* Upgrade savepoint, marks end of each upgrade block.
* It stores new main version, resets upgrade timeout
* and abort upgrade if user cancels page loading.
*
* Please do not make large upgrade blocks with lots of operations,
* for example when adding tables keep only one table operation per block.
*
* @param bool $result false if upgrade step failed, true if completed
* @param string or float $version main version
* @return void
*/
function upgrade_main_savepoint($result, $version) {
global $CFG;
if ($result) {
if ($CFG->version >= $version) {
// something really wrong is going on in main upgrade script
print_error('cannotdowngrade', 'debug', '', array($CFG->version, $version));
print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$CFG->version, 'newversion'=>$version));
}
set_config('version', $version);
} else {
notify ("Upgrade savepoint: Error during main upgrade to version $version");
}
// reset upgrade timeout to default
upgrade_set_timeout();
// this is a safe place to stop upgrades if user aborts page loading
if (connection_aborted()) {
die;
}
}
/**
* Module upgrade savepoint, marks end of module upgrade blocks
* It stores module version, resets upgrade timeout
* and abort upgrade if usercancels page loading.
*
* @param bool $result false if upgrade step failed, true if completed
* @param string or float $version main version
* @return void
*/
function upgrade_mod_savepoint($result, $version, $modname) {
global $DB;
......@@ -50,13 +85,48 @@ function upgrade_mod_savepoint($result, $version, $modname) {
if ($result) {
if ($module->version >= $version) {
// something really wrong is going on in upgrade script
print_error('cannotdowngrade', 'debug', '', array($module->version, $version));
print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$module->version, 'newversion'=>$version));
}
$module->verions = $version;
$DB->update_record('modules', $module);
} else {
notify ("Upgrade savepoint: Error during mod upgrade to version $version");
}
// reset upgrade timeout to default
upgrade_set_timeout();
// this is a safe place to stop upgrades if user aborts page loading
if (connection_aborted()) {
die;
}
}
function upgrade_blocks_savepoint($result, $version, $blockname) {
global $DB;
if (!$block = $DB->get_record('block', array('name'=>$blockname))) {
print_error('blocknotexist', 'debug', '', $blockname);
}
if ($result) {
if ($block->version >= $version) {
// something really wrong is going on in upgrade script
print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$block->version, 'newversion'=>$version));
}
$block->verions = $version;
$DB->update_record('block', $block);
} else {
notify ("Upgrade savepoint: Error during mod upgrade to version $version");
}
// reset upgrade timeout to default
upgrade_set_timeout();
// this is a safe place to stop upgrades if user aborts page loading
if (connection_aborted()) {
die;
}
}
function upgrade_plugin_savepoint($result, $version, $type, $dir) {
......@@ -67,10 +137,6 @@ function upgrade_backup_savepoint($result, $version) {
//TODO
}
function upgrade_blocks_savepoint($result, $version, $type) {
//TODO
}
/**
* Delete all plugin tables
* @name string name of plugin, used as table prefix
......@@ -382,7 +448,7 @@ function upgrade_plugins($type, $dir, $return) {
}
} else {
upgrade_log_start();
print_error('cannotdowngrade', 'debug', '', array($CFG->pluginversion, $plugin->version));
print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$CFG->pluginversion, 'newversion'=>$plugin->version));
}
}
......@@ -390,14 +456,14 @@ function upgrade_plugins($type, $dir, $return) {
if ($updated_plugins && !$embedded) {
if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
print_continue($return);
print_footer('none');
die;
print_continue($return);
print_footer('none');
die;
} else if (CLI_UPGRADE && ($interactive > CLI_SEMI )) {
console_write(STDOUT,'askcontinue');
if (read_boolean()){
return ;
}else {
} else {
console_write(STDERR,'','',false);
}
}
......@@ -517,7 +583,7 @@ function upgrade_activity_modules($return) {
remove_dir($CFG->dataroot . '/cache', true); // flush cache
notify(get_string('modulesuccess', '', $module->name), 'notifysuccess');
if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) {
echo '<hr />';
echo '<hr />';
}
} else {
notify('Upgrading '. $module->name .' from '. $currmodule->version .' to '. $module->version .' FAILED!');
......@@ -538,16 +604,16 @@ function upgrade_activity_modules($return) {
} else {
upgrade_log_start();
print_error('cannotdowngrade', 'debug', '', array($currmodule->version, $module->version));
print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$currmodule->version, 'newversion'=>$module->version));
}
} else { // module not installed yet, so install it
if (!$updated_modules) {
if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
print_header($strmodulesetup, $strmodulesetup,
print_header($strmodulesetup, $strmodulesetup,
build_navigation(array(array('name' => $strmodulesetup, 'link' => null, 'type' => 'misc'))), '',
upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
}
}
}
upgrade_log_start();
print_heading($module->name);
......@@ -593,7 +659,7 @@ function upgrade_activity_modules($return) {
notify(get_string('modulesuccess', '', $module->name), 'notifysuccess');
if (!defined('CLI_UPGRADE')|| !CLI_UPGRADE ) {
echo '<hr />';
echo '<hr />';
}
} else {
print_error('cannotaddmodule', '', '', $module->name);
......@@ -630,9 +696,9 @@ function upgrade_activity_modules($return) {
if ($updated_modules) {
if (!defined('CLI_UPGRADE')|| !CLI_UPGRADE ) {
print_continue($return);
print_footer('none');
die;
print_continue($return);
print_footer('none');
die;
} else if ( CLI_UPGRADE && ($interactive > CLI_SEMI) ) {
console_write(STDOUT,'askcontinue');
if (read_boolean()){
......@@ -794,7 +860,7 @@ function create_admin_user($user_input=NULL) {
foreach ($adminroles as $adminrole) {
role_assign($adminrole->id, $user->id, 0, $sitecontext->id);
}
//set default message preferences
if (!message_set_default_message_preferences( $user )){
print_error('cannotsavemessageprefs', 'message');
......@@ -808,7 +874,7 @@ function create_admin_user($user_input=NULL) {
load_all_capabilities();
if (!defined('CLI_UPGRADE')||!CLI_UPGRADE) {
redirect("$CFG->wwwroot/user/editadvanced.php?id=$user->id"); // Edit thyself
redirect("$CFG->wwwroot/user/editadvanced.php?id=$user->id"); // Edit thyself
}
} else {
print_error('cannotcreateadminuser', 'debug');
......@@ -819,30 +885,40 @@ function create_admin_user($user_input=NULL) {
/// upgrade logging functions
////////////////////////////////////////////////
$upgradeloghandle = false;
$upgradelogbuffer = '';
// I did not find out how to use static variable in callback function,
// the problem was that I could not flush the static buffer :-(
global $upgradeloghandle, $upgradelogbuffer;
/**
* Check if upgrade is already running.
*
* If anything goes wrong due to missing call to upgrade_log_finish()
* just restart the browser.
*
* @param string warning message indicating upgrade is already running
* @param int page reload timeout
* Marks start of upgrade, blocks any other access to site.
* The upgrade is finished at the end of script or after timeout.
*/
function upgrade_check_running($message, $timeout) {
global $SESSION;
function start_upgrade() {
global $CFG;
if (!empty($SESSION->upgraderunning)) {
print_header();
redirect(me(), $message, $timeout);
static $started = false;
if ($started) {
upgrade_set_timeout(120);
} else {
ignore_user_abort(true);
register_shutdown_function('upgrade_finished_handler');
if ($CFG->version === '') {
// db not installed yet
$CFG->upgraderunning = time()+300;
} else {
set_config('upgraderunning', time()+300);
}
$started = true;
}
}
/**
* Internal function - executed at the very end of each upgrade.
*/
function upgrade_finished_handler() {
upgrade_log_finish();
unset_config('upgraderunning');
ignore_user_abort(false);
}
/**
* Start logging of output into file (if not disabled) and
* prevent aborting and concurrent execution of upgrade script.
......@@ -852,25 +928,20 @@ function upgrade_check_running($message, $timeout) {
* This function may be called repeatedly.
*/
function upgrade_log_start() {
global $CFG, $upgradeloghandle, $SESSION;
global $upgradeloghandle;
if (!empty($SESSION->upgraderunning)) {
return; // logging already started
}
start_upgrade(); // make sure the upgrade is started
@ignore_user_abort(true); // ignore if user stops or otherwise aborts page loading
$SESSION->upgraderunning = 1; // set upgrade indicator
if (empty($CFG->dbsessions)) { // workaround for bug in adodb, db session can not be restarted
session_write_close(); // from now on user can reload page - will be displayed warning
if ($upgradeloghandle and ($upgradeloghandle !== 'error')) {
return;
}
make_upload_directory('upgradelogs');
ob_start('upgrade_log_callback', 2); // function for logging to disk; flush each line of text ASAP
register_shutdown_function('upgrade_log_finish'); // in case somebody forgets to stop logging
}
/**
* Terminate logging of output, flush all data, allow script aborting
* and reopen session for writing. Function print_error() does terminate the logging too.
* Terminate logging of output, flush all data.
*
* Please make sure that each upgrade_log_start() is properly terminated by
* this function or print_error().
......@@ -878,11 +949,7 @@ function upgrade_log_start() {
* This function may be called repeatedly.
*/
function upgrade_log_finish() {
global $CFG, $upgradeloghandle, $upgradelogbuffer, $SESSION;
if (empty($SESSION->upgraderunning)) {
return; // logging already terminated
}
global $CFG, $upgradeloghandle, $upgradelogbuffer;
@ob_end_flush();
if ($upgradelogbuffer !== '') {
......@@ -893,14 +960,6 @@ function upgrade_log_finish() {
@fclose($upgradeloghandle);
$upgradeloghandle = false;
}
@session_start(); // ignore header errors, we only need to reopen session
$SESSION->upgraderunning = 0; // clear upgrade indicator
if (connection_aborted()) {
die;
}
@ignore_user_abort(false);
}
/**
......@@ -1658,9 +1717,7 @@ class admin_settingpage extends part_of_admin_tree {
$data = $adminroot->errors[$fullname]->data;
} else {
$data = $setting->get_setting();
if (is_null($data)) {
$data = $setting->get_defaultsetting();
}
// do not use defaults if settings not available - upgrdesettings handles the defaults!
}
$return .= $setting->output_html($data);
}
......@@ -2237,13 +2294,8 @@ class admin_setting_configmulticheckbox extends admin_setting {
$default = array();
}
if (is_null($data)) {
foreach ($default as $value) {
if ($value) {
$data[] = $value;
}
}
$data = array();
}
$options = array();
$defaults = array();
foreach($this->choices as $key=>$description) {
......@@ -3423,9 +3475,9 @@ class admin_setting_pickroles extends admin_setting_configmulticheckbox {
* which identify roles that will be enabled by default. Default is the
* student role
*/
function admin_setting_pickroles($name, $visiblename, $description,$types=array('moodle/legacy:student')) {
function admin_setting_pickroles($name, $visiblename, $description, $types) {
parent::admin_setting_configmulticheckbox($name, $visiblename, $description, NULL, NULL);
$this->types=$types;
$this->types = $types;