';
+ echo '
';
echo '
';
echo '';
- print_footer('none');
- die();
-
- } else {
- $strdatabasesuccess = get_string("databasesuccess");
- $navigation = build_navigation(array(array('name'=>$strdatabasesuccess, 'link'=>null, 'type'=>'misc')));
- print_header($strdatabasechecking, $stradministration, $navigation,
- "", upgrade_get_javascript(), false, " ", " ");
-
- /// return to original debugging level
- $CFG->debug = $origdebug;
- error_reporting($CFG->debug);
- upgrade_log_start();
-
- /// Upgrade current language pack if we can
- upgrade_language_pack();
-
- print_heading($strdatabasechecking);
- $DB->set_debug(true);
- /// Launch the old main upgrade (if exists)
- $status = true;
- if (function_exists('main_upgrade')) {
- $status = main_upgrade($CFG->version);
- }
- /// If succesful and exists launch the new main upgrade (XMLDB), called xmldb_main_upgrade
- if ($status && function_exists('xmldb_main_upgrade')) {
- $status = xmldb_main_upgrade($CFG->version);
- }
- $DB->set_debug(false);
- /// If successful, continue upgrading roles and setting everything properly
- if ($status) {
- if (!update_capabilities()) {
- print_error('cannotupgradecapabilities', 'debug');
- }
-
- // Update core events
- events_update_definition();
-
- // Update core message providers
- require_once($CFG->libdir .'/messagelib.php'); // Messagelib functions
- message_update_providers();
-
- if (set_config("version", $version)) {
- remove_dir($CFG->dataroot . '/cache', true); // flush cache
- notify($strdatabasesuccess, "green");
- print_continue("upgradesettings.php");
- print_footer('none');
- exit;
- } else {
- print_error('cannotupdateversion', 'debug');
- }
- /// Main upgrade not success
- } else {
- notify('Main Upgrade failed! See lib/db/upgrade.php');
- print_continue('index.php?confirmupgrade=1&confirmrelease=1&confirmplugincheck=1');
- print_footer('none');
- die;
- }
- upgrade_log_finish();
}
- } else if ($version < $CFG->version) {
+
+ print_footer('none');
+ die;
+ } elseif (empty($confirmplugins)) {
+ $strplugincheck = get_string('plugincheck');
+ $navigation = build_navigation(array(array('name'=>$strplugincheck, 'link'=>null, 'type'=>'misc')));
+ print_header($strplugincheck, $strplugincheck, $navigation, "", "", false, " ", " ");
+ print_heading($strplugincheck);
+ print_box_start('generalbox', 'notice'); // MDL-8330
+ print_string('pluginchecknotice');
+ print_box_end();
+ print_plugin_tables();
+ echo "
";
+ echo '
';
+ print_single_button('index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1), get_string('reload'), 'get');
+ echo '
';
+ echo '
';
+ print_footer('none');
+ die();
+
+ } else {
+
+ $strdatabasesuccess = get_string("databasesuccess");
+ $navigation = build_navigation(array(array('name'=>$strdatabasesuccess, 'link'=>null, 'type'=>'misc')));
+ print_header($strdatabasechecking, $stradministration, $navigation,
+ "", upgrade_get_javascript(), false, " ", " ");
+
+ /// return to original debugging level
+ $CFG->debug = $origdebug;
+ error_reporting($CFG->debug);
upgrade_log_start();
- notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
+
+ /// Upgrade current language pack if we can
+ upgrade_language_pack();
+
+ print_heading($strdatabasechecking);
+ $DB->set_debug(true);
+ /// Launch the old main upgrade (if exists)
+ $status = true;
+ if (function_exists('main_upgrade')) {
+ $status = main_upgrade($CFG->version);
+ }
+ /// If succesful and exists launch the new main upgrade (XMLDB), called xmldb_main_upgrade
+ if ($status && function_exists('xmldb_main_upgrade')) {
+ $status = xmldb_main_upgrade($CFG->version);
+ }
+ $DB->set_debug(false);
+ /// If successful, continue upgrading roles and setting everything properly
+ if ($status) {
+ if (!update_capabilities()) {
+ print_error('cannotupgradecapabilities', 'debug');
+ }
+
+ // Update core events
+ events_update_definition();
+
+ // Update core message providers
+ message_update_providers();
+
+ if (set_config("version", $version)) {
+ remove_dir($CFG->dataroot . '/cache', true); // flush cache
+ notify($strdatabasesuccess, "green");
+ print_continue("upgradesettings.php");
+ print_footer('none');
+ exit;
+ } else {
+ print_error('cannotupdateversion', 'debug');
+ }
+ /// Main upgrade not success
+ } else {
+ notify('Main Upgrade failed! See lib/db/upgrade.php');
+ print_continue('index.php?confirmupgrade=1&confirmrelease=1&confirmplugincheck=1');
+ print_footer('none');
+ die;
+ }
upgrade_log_finish();
}
- } else {
- if (!set_config("version", $version)) {
- print_error('cannotupdateversion', 'debug');
- }
+ } else if ($version < $CFG->version) {
+ upgrade_log_start();
+ notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
+ upgrade_log_finish();
}
/// Updated human-readable release version if necessary
@@ -380,9 +365,6 @@
}
}
-/// Groups install/upgrade is now in core above.
-
-
/// Find and check all main modules and load them up or upgrade them if necessary
/// first old *.php update and then the new upgrade.php script
upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
diff --git a/admin/lang.php b/admin/lang.php
index d7b7c7f2fda..724b93d56ee 100644
--- a/admin/lang.php
+++ b/admin/lang.php
@@ -404,7 +404,7 @@
if ($location || $plugin) {
// file in an extra location
if ($currentfile != "{$prefix}{$plugin}.php") {
- print_error('filemismatch', 'error', '', array($currectfile, $prefix, $plugin));
+ print_error('filemismatch', 'error', '', (object)array('current'=>$currectfile, 'file'=>$prefix.$plugin.'.php'));
}
if (!$uselocal) {
notify($streditingnoncorelangfile);
@@ -413,7 +413,7 @@
} else {
// file in standard location
if ($currentfile != $filename) {
- print_error('filemismatch', 'error', '', array($currectfile, $filename, ''));
+ print_error('filemismatch', 'error', '', (object)array('current'=>$currectfile, 'file'=>$filename.'.php'));
}
}
@@ -467,7 +467,7 @@
if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) {
notify(get_string("changessaved")." ($saveinto/$currentfile)", "notifysuccess");
} else {
- print_error('cannotsavefile', 'error', 'lang.php?mode=compare¤tfile=$currentfile', array($saveinto, $currentfile));
+ print_error('cannotsavefile', 'error', 'lang.php?mode=compare¤tfile=$currentfile', $saveinto.'/'.$currentfile);
}
unset($packstring);
}
diff --git a/admin/settings/misc.php b/admin/settings/misc.php
index 67583c5b2e4..ec9ac0b33f0 100644
--- a/admin/settings/misc.php
+++ b/admin/settings/misc.php
@@ -15,8 +15,8 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
// Completion system
require_once($CFG->libdir.'/completionlib.php');
- $temp->add(new admin_setting_configcheckbox('enablecompletion',get_string('enablecompletion','completion'),get_string('configenablecompletion','completion'),COMPLETION_DISABLED));
- $temp->add(new admin_setting_pickroles('progresstrackedroles',get_string('progresstrackedroles','completion'),get_string('configprogresstrackedroles','completion')));
+ $temp->add(new admin_setting_configcheckbox('enablecompletion', get_string('enablecompletion','completion'), get_string('configenablecompletion','completion'), COMPLETION_DISABLED));
+ $temp->add(new admin_setting_pickroles('progresstrackedroles', get_string('progresstrackedroles','completion'), get_string('configprogresstrackedroles', 'completion'), array('moodle/legacy:student')));
$ADMIN->add('misc', $temp);
diff --git a/backup/db/upgrade.php b/backup/db/upgrade.php
index de6597c6f40..e75c1266ff9 100644
--- a/backup/db/upgrade.php
+++ b/backup/db/upgrade.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_backup_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_backup_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/activity_modules/db/upgrade.php b/blocks/activity_modules/db/upgrade.php
index 9cd056bdae6..502e7a0c1ba 100644
--- a/blocks/activity_modules/db/upgrade.php
+++ b/blocks/activity_modules/db/upgrade.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_block_activity_modules_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_activity_modules_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/admin/db/upgrade.php b/blocks/admin/db/upgrade.php
index fc6ef1403d0..bb2282e65e7 100644
--- a/blocks/admin/db/upgrade.php
+++ b/blocks/admin/db/upgrade.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_block_admin_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_admin_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/calendar_month/db/upgrade.php b/blocks/calendar_month/db/upgrade.php
index ba3745b09e8..88eb8c18038 100644
--- a/blocks/calendar_month/db/upgrade.php
+++ b/blocks/calendar_month/db/upgrade.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_block_calendar_month_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_calendar_month_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/calendar_upcoming/db/upgrade.php b/blocks/calendar_upcoming/db/upgrade.php
index 1ee5c024f3a..c55e79114fd 100644
--- a/blocks/calendar_upcoming/db/upgrade.php
+++ b/blocks/calendar_upcoming/db/upgrade.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_block_calendar_upcoming_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_calendar_upcoming_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/course_list/db/upgrade.php b/blocks/course_list/db/upgrade.php
index fb46ad1b6e4..b25621016e8 100644
--- a/blocks/course_list/db/upgrade.php
+++ b/blocks/course_list/db/upgrade.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_block_course_list_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_course_list_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/course_summary/db/upgrade.php b/blocks/course_summary/db/upgrade.php
index 28f823ce7c9..674d56391cb 100644
--- a/blocks/course_summary/db/upgrade.php
+++ b/blocks/course_summary/db/upgrade.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_block_course_summary_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_course_summary_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/db/upgrade.php b/blocks/db/upgrade.php
index 784808bb437..467e0124fa1 100644
--- a/blocks/db/upgrade.php
+++ b/blocks/db/upgrade.php
@@ -16,13 +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_blocks_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_blocks_upgrade($oldversion) {
+ global $CFG, $DB;
$dbman = $DB->get_manager();
-
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/news_items/db/upgrade.php b/blocks/news_items/db/upgrade.php
index bd9b97562b3..8f2c5100caa 100644
--- a/blocks/news_items/db/upgrade.php
+++ b/blocks/news_items/db/upgrade.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_block_news_items_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_news_items_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/online_users/db/upgrade.php b/blocks/online_users/db/upgrade.php
index 334c81f6962..501ff24fe31 100644
--- a/blocks/online_users/db/upgrade.php
+++ b/blocks/online_users/db/upgrade.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_block_online_users_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_online_users_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/participants/db/upgrade.php b/blocks/participants/db/upgrade.php
index 9decca38801..98b03be8a15 100644
--- a/blocks/participants/db/upgrade.php
+++ b/blocks/participants/db/upgrade.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_block_participants_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_participants_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/recent_activity/db/upgrade.php b/blocks/recent_activity/db/upgrade.php
index 65082fd9629..d08f065aa0e 100644
--- a/blocks/recent_activity/db/upgrade.php
+++ b/blocks/recent_activity/db/upgrade.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_block_recent_activity_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_recent_activity_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/rss_client/db/upgrade.php b/blocks/rss_client/db/upgrade.php
index c8261d020cb..282f08e4227 100644
--- a/blocks/rss_client/db/upgrade.php
+++ b/blocks/rss_client/db/upgrade.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_block_rss_client_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_rss_client_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/search/config_global.html b/blocks/search/config_global.html
index 6e742dbd05a..40575942bd9 100644
--- a/blocks/search/config_global.html
+++ b/blocks/search/config_global.html
@@ -107,12 +107,11 @@ $defaultfiletypes = "PDF,TXT,HTML,PPT,XML,DOC,HTM";
if(isset($CFG->block_search_pdf_to_text_cmd)) {
p($CFG->block_search_pdf_to_text_cmd);
} else {
- $encoding = ($CFG->unicodedb) ? "-enc UTF-8" : "-enc ISO-8859-1" ;
if ($CFG->ostype == 'WINDOWS'){
- p("lib/xpdf/win32/pdftotext.exe -eol dos $encoding -q");
+ p("lib/xpdf/win32/pdftotext.exe -eol dos -enc UTF-8 -q");
}
else{
- p("lib/xpdf/linux/pdftotext $encoding -eol unix -q");
+ p("lib/xpdf/linux/pdftotext -enc UTF-8 -eol unix -q");
}
} ?>"/>
diff --git a/blocks/search/db/upgrade.php b/blocks/search/db/upgrade.php
index 80ce4c4b5a5..78089ee4d88 100644
--- a/blocks/search/db/upgrade.php
+++ b/blocks/search/db/upgrade.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_block_search_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_block_search_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/blocks/search_forums/db/upgrade.php b/blocks/search_forums/db/upgrade.php
index 99ae3c9ae85..19579a98de8 100644
--- a/blocks/search_forums/db/upgrade.php
+++ b/blocks/search_forums/db/upgrade.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_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
diff --git a/blocks/section_links/db/upgrade.php b/blocks/section_links/db/upgrade.php
index 2e1c6dfab74..69475c56e80 100644
--- a/blocks/section_links/db/upgrade.php
+++ b/blocks/section_links/db/upgrade.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_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
diff --git a/blocks/social_activities/db/upgrade.php b/blocks/social_activities/db/upgrade.php
index 914bd22ca95..e5b70b051ce 100644
--- a/blocks/social_activities/db/upgrade.php
+++ b/blocks/social_activities/db/upgrade.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_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
diff --git a/course/format/README.txt b/course/format/README.txt
index efc3a9b5d1f..e8fecdb5eeb 100644
--- a/course/format/README.txt
+++ b/course/format/README.txt
@@ -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
diff --git a/enrol/authorize/db/upgrade.php b/enrol/authorize/db/upgrade.php
index 37034a2ffae..7bbf8cc9aa7 100644
--- a/enrol/authorize/db/upgrade.php
+++ b/enrol/authorize/db/upgrade.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 ======//
diff --git a/enrol/paypal/db/upgrade.php b/enrol/paypal/db/upgrade.php
index 7c39348e9a0..8a0aa93eb30 100644
--- a/enrol/paypal/db/upgrade.php
+++ b/enrol/paypal/db/upgrade.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_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
diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php
index 2ddd315a802..b8415409413 100644
--- a/lang/en_utf8/admin.php
+++ b/lang/en_utf8/admin.php
@@ -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.
Please note that this process can take a long time.
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';
diff --git a/lang/en_utf8/data.php b/lang/en_utf8/data.php
index 5fac4e6ad99..4d7476faf5e 100644
--- a/lang/en_utf8/data.php
+++ b/lang/en_utf8/data.php
@@ -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';
diff --git a/lang/en_utf8/debug.php b/lang/en_utf8/debug.php
index 365bcba1c41..c28513a0442 100644
--- a/lang/en_utf8/debug.php
+++ b/lang/en_utf8/debug.php
@@ -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:
You have:
\$CFG->dirroot = \"$a[0]\";
but it should be:
\$CFG->dirroot = \"$a[1]\"
';
+$string['fixsetting'] = 'Please fix your settings in config.php:
You have:
\$CFG->dirroot = \"$a->current\";
but it should be:
\$CFG->dirroot = \"$a->found\"
';
$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';
?>
diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php
index 828347917d6..0683e58772c 100644
--- a/lang/en_utf8/error.php
+++ b/lang/en_utf8/error.php
@@ -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)';
diff --git a/lang/en_utf8/forum.php b/lang/en_utf8/forum.php
index bb85d6b9d4d..e3ed99252f6 100644
--- a/lang/en_utf8/forum.php
+++ b/lang/en_utf8/forum.php
@@ -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:';
diff --git a/lib/accesslib.php b/lib/accesslib.php
index 23897aa975f..bc88fc89ae2 100755
--- a/lib/accesslib.php
+++ b/lib/accesslib.php
@@ -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));
}
}
}
diff --git a/lib/adminlib.php b/lib/adminlib.php
index 974fabc4dda..9c205190dc6 100644
--- a/lib/adminlib.php
+++ b/lib/adminlib.php
@@ -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 '
';
+ echo '
';
}
} 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, ' ', ' ');
- }
+ }
}
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 '
';
+ echo '
';
}
} 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,28 +885,38 @@ 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;
+/**
+ * Marks start of upgrade, blocks any other access to site.
+ * The upgrade is finished at the end of script or after timeout.
+ */
+function start_upgrade() {
+ global $CFG;
+
+ 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;
+ }
+}
/**
- * 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
+ * Internal function - executed at the very end of each upgrade.
*/
-function upgrade_check_running($message, $timeout) {
- global $SESSION;
-
- if (!empty($SESSION->upgraderunning)) {
- print_header();
- redirect(me(), $message, $timeout);
- }
+function upgrade_finished_handler() {
+ upgrade_log_finish();
+ unset_config('upgraderunning');
+ ignore_user_abort(false);
}
/**
@@ -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
+
+ if ($upgradeloghandle and ($upgradeloghandle !== 'error')) {
+ return;
}
- @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
- }
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;
}
function load_choices() {
@@ -3450,13 +3502,13 @@ class admin_setting_pickroles extends admin_setting_configmulticheckbox {
function get_defaultsetting() {
global $CFG;
if (empty($CFG->rolesactive)) {
- return array(0);
+ return null;
}
$result = array();
foreach($this->types as $capability) {
if ($caproles = get_roles_with_capability($capability, CAP_ALLOW)) {
foreach ($caproles as $caprole) {
- if(!in_array($caprole->id,$result)) {
+ if (!in_array($caprole->id, $result)) {
$result[] = $caprole->id;
}
}
@@ -3472,7 +3524,8 @@ class admin_setting_pickroles extends admin_setting_configmulticheckbox {
class admin_setting_special_gradebookroles extends admin_setting_pickroles {
function admin_setting_special_gradebookroles() {
parent::admin_setting_pickroles('gradebookroles', get_string('gradebookroles', 'admin'),
- get_string('configgradebookroles', 'admin'));
+ get_string('configgradebookroles', 'admin'),
+ array('moodle/legacy:student'));
}
}
@@ -3501,7 +3554,7 @@ class admin_setting_special_coursemanager extends admin_setting_pickroles {
function admin_setting_special_coursemanager() {
parent::admin_setting_pickroles('coursemanager', get_string('coursemanager', 'admin'),
get_string('configcoursemanager', 'admin'),
- 'moodle/legacy:editingteacher');
+ array('moodle/legacy:editingteacher'));
}
}
@@ -4674,9 +4727,7 @@ function admin_search_settings_html($query) {
$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, $query);
}
@@ -5090,7 +5141,7 @@ class admin_setting_managerepository extends admin_setting {
parent::admin_setting('managerepository', get_string('managerepository', 'repository'), '', '');
$this->baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/repository.php?sesskey=' . sesskey();
}
-
+
function get_setting() {
return true;
}
diff --git a/lib/blocklib.php b/lib/blocklib.php
index bb33e3ad2e7..9b1b648ca2f 100644
--- a/lib/blocklib.php
+++ b/lib/blocklib.php
@@ -1326,7 +1326,7 @@ function upgrade_blocks_plugins($continueto) {
}
} else {
upgrade_log_start();
- print_error('cannotdowngrade', 'debug', '', array($currblock->version, $block->version));
+ print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$currblock->version, 'newversion'=>$block->version));
}
} else { // block not installed yet, so install it
@@ -1345,11 +1345,7 @@ function upgrade_blocks_plugins($continueto) {
if($conflictblock !== false && $conflictblock !== NULL) {
// Duplicate block titles are not allowed, they confuse people
// AND PHP's associative arrays ;)
- if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- print_error('blocknameconflict', '', '', array($block->name, $conflictblock));
- } else if (CLI_UPGRADE) {
- print_error('blocknameconflict', '', '', array($block->name, $conflictblock));
- }
+ print_error('blocknameconflict', '', '', (object)array('name'=>$block->name, 'conflict'=>$conflictblock));
}
if (empty($updated_blocks)) {
$strblocksetup = get_string('blocksetup');
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 9994486abf3..872e255e19a 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -15,9 +15,11 @@
//
// 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_main_upgrade($oldversion=0) {
+function xmldb_main_upgrade($oldversion) {
global $CFG, $THEME, $USER, $DB;
$result = true;
@@ -29,6 +31,7 @@ function xmldb_main_upgrade($oldversion=0) {
////////////////////////////////////////
if ($result && $oldversion < 2008030700) {
+ upgrade_set_timeout(60*20); // this may take a while
/// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters
$table = new xmldb_table('grade_letters');
@@ -61,6 +64,8 @@ function xmldb_main_upgrade($oldversion=0) {
}
if ($result && $oldversion < 2008050700) {
+ upgrade_set_timeout(60*20); // this may take a while
+
/// Fix minor problem caused by MDL-5482.
require_once($CFG->dirroot . '/question/upgrade.php');
$result = $result && question_fix_random_question_parents();
@@ -85,6 +90,7 @@ function xmldb_main_upgrade($oldversion=0) {
if ($result && $oldversion < 2008051201) {
notify('Increasing size of user idnumber field, this may take a while...', 'notifysuccess');
+ upgrade_set_timeout(60*20); // this may take a while
/// Under MySQL and Postgres... detect old NULL contents and change them by correct empty string. MDL-14859
if ($CFG->dbfamily == 'mysql' || $CFG->dbfamily == 'postgres') {
@@ -135,6 +141,8 @@ function xmldb_main_upgrade($oldversion=0) {
}
if ($result && $oldversion < 2008063001) {
+ upgrade_set_timeout(60*20); // this may take a while
+
// table to be modified
$table = new xmldb_table('tag_instance');
// add field
@@ -262,28 +270,15 @@ function xmldb_main_upgrade($oldversion=0) {
/// Main savepoint reached
upgrade_main_savepoint($result, 2008070701);
}
-
- if ($result && $oldversion < 2008072400) {
- /// Create the database tables for message_processors and message_providers
- $table = new xmldb_table('message_providers');
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
- $table->add_field('modulename', XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null, null, null);
- $table->add_field('modulefile', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
- $dbman->create_table($table);
+ if ($result && $oldversion < 2008072400) {
+ /// Create the database tables for message_processors
$table = new xmldb_table('message_processors');
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->add_field('name', XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null, null, null);
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$dbman->create_table($table);
-
- $provider = new object();
- $provider->modulename = 'moodle';
- $provider->modulefile = 'index.php';
- $DB->insert_record('message_providers', $provider);
-
/// delete old and create new fields
$table = new xmldb_table('message');
$field = new xmldb_field('messagetype');
@@ -355,17 +350,17 @@ function xmldb_main_upgrade($oldversion=0) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'defaultrole');
/// Launch add field enablecompletion
- if(!$dbman->field_exists($table,$field)) {
+ if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
-
+
/// Define field completion to be added to course_modules
$table = new xmldb_table('course_modules');
$field = new xmldb_field('completion');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'groupmembersonly');
/// Launch add field completion
- if(!$dbman->field_exists($table,$field)) {
+ if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
@@ -374,7 +369,7 @@ function xmldb_main_upgrade($oldversion=0) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'completion');
/// Launch add field completiongradeitemnumber
- if(!$dbman->field_exists($table,$field)) {
+ if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
@@ -383,7 +378,7 @@ function xmldb_main_upgrade($oldversion=0) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completiongradeitemnumber');
/// Launch add field completionview
- if(!$dbman->field_exists($table,$field)) {
+ if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
@@ -392,13 +387,13 @@ function xmldb_main_upgrade($oldversion=0) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completionview');
/// Launch add field completionexpected
- if(!$dbman->field_exists($table,$field)) {
+ if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
/// Define table course_modules_completion to be created
$table = new xmldb_table('course_modules_completion');
- if(!$dbman->table_exists($table)) {
+ if (!$dbman->table_exists($table)) {
/// Adding fields to table course_modules_completion
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
@@ -407,14 +402,14 @@ function xmldb_main_upgrade($oldversion=0) {
$table->add_field('completionstate', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->add_field('viewed', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-
+
/// Adding keys to table course_modules_completion
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
-
+
/// Adding indexes to table course_modules_completion
$table->add_index('coursemoduleid', XMLDB_INDEX_NOTUNIQUE, array('coursemoduleid'));
$table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
-
+
/// Launch create table for course_modules_completion
$dbman->create_table($table);
}
@@ -422,7 +417,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Main savepoint reached
upgrade_main_savepoint($result, 2008072800);
}
-
+
if ($result && $oldversion < 2008073000) {
/// Define table portfolio_log to be created
@@ -602,6 +597,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Main savepoint reached
upgrade_main_savepoint($result, 2008080600);
}
+
if ($result && $oldversion < 2008080701) {
/// Define field visible to be added to repository
@@ -667,6 +663,15 @@ function xmldb_main_upgrade($oldversion=0) {
upgrade_main_savepoint($result, 2008081506);
}
+ if ($result && $oldversion < 2008081600) {
+
+ /// all 1.9 sites and fresh installs must already be unicode, not needed anymore
+ unset_config('unicodedb');
+
+ /// Main savepoint reached
+ upgrade_main_savepoint($result, 2008081600);
+ }
+
return $result;
}
diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php
index cf08fead391..0c5686c25e7 100644
--- a/lib/db/upgradelib.php
+++ b/lib/db/upgradelib.php
@@ -73,6 +73,7 @@ function upgrade_migrate_files_courses() {
$i = 0;
foreach ($rs as $course) {
$i++;
+ upgrade_set_timeout(60*5); // set up timeout, may also abort execution
$context = get_context_instance(CONTEXT_COURSE, $course->id);
upgrade_migrate_files_course($context, '/', true);
$pbar->update($i, $count, "Migrated course files - course $i/$count.");
@@ -102,7 +103,7 @@ function upgrade_migrate_files_course($context, $path, $delete) {
}
if ($item->isLink()) {
- // do not delete symbolic links or its children
+ // do not delete symbolic links or its children
$delete_this = false;
} else {
$delete_this = $delete;
@@ -174,6 +175,8 @@ function upgrade_migrate_files_blog() {
if ($rs = $DB->get_recordset_select('post', "module='blog' AND attachment IS NOT NULL AND attachment <> 1")) {
+ upgrade_set_timeout(60*20); // set up timeout, may also abort execution
+
$pbar = new progress_bar('migrateblogfiles', 500, true);
$olddebug = $DB->get_debug();
@@ -183,9 +186,8 @@ function upgrade_migrate_files_blog() {
$i++;
$pathname = "$CFG->dataroot/blog/attachments/$entry->id/$entry->attachment";
if (!file_exists($pathname)) {
- // hmm, we could set atatchment NULL here, but it would break badly in concurrent ugprades, disabling for now
- //$entry->attachment = NULL;
- //$DB->update_record('post', $entry);
+ $entry->attachment = NULL;
+ $DB->update_record('post', $entry);
continue;
}
@@ -204,7 +206,7 @@ function upgrade_migrate_files_blog() {
if (!$fs->file_exists(SYSCONTEXTID, 'blog', $entry->id, '/', $filename)) {
$file_record = array('contextid'=>SYSCONTEXTID, 'filearea'=>'blog', 'itemid'=>$entry->id, 'filepath'=>'/', 'filename'=>$filename,
- 'timecreated'=>filectime($pathname), 'timemodified'=>filemtime($pathname), 'userid'=>$post->userid);
+ 'timecreated'=>filectime($pathname), 'timemodified'=>filemtime($pathname), 'userid'=>$entry->userid);
$fs->create_file_from_pathname($file_record, $pathname);
}
@unlink($pathname);
@@ -217,7 +219,7 @@ function upgrade_migrate_files_blog() {
$DB->set_debug($olddebug); // reset debug level
$rs->close();
}
-
+
@rmdir("$CFG->dataroot/blog/attachments/");
@rmdir("$CFG->dataroot/blog/");
}
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 3d81952eea3..18063497594 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -2597,7 +2597,7 @@ function fullname($user, $override=false) {
$CFG->fullnamedisplay = $SESSION->fullnamedisplay;
}
- if ($CFG->fullnamedisplay == 'firstname lastname') {
+ if (!isset($CFG->fullnamedisplay) or $CFG->fullnamedisplay === 'firstname lastname') {
return $user->firstname .' '. $user->lastname;
} else if ($CFG->fullnamedisplay == 'lastname firstname') {
@@ -6418,6 +6418,45 @@ function moodle_needs_upgrading() {
return false;
}
+/**
+ * Sets maximum expected time needed for upgrade task.
+ * Please always make sure that upgrade will not run longer!
+ *
+ * The script may be automatically aborted if upgrade times out.
+ *
+ * @param int $max_execution_time in seconds (can not be less than 60 s)
+ * @return void
+ */
+function upgrade_set_timeout($max_execution_time=300) {
+ global $CFG;
+
+ if (!isset($CFG->upgraderunning) or $CFG->upgraderunning < time()) {
+ $upgraderunning = get_config(null, 'upgraderunning');
+ } else {
+ $upgraderunning = $CFG->upgraderunning;
+ }
+
+ if (!$upgraderunning) {
+ // upgrade not running or aborted
+ print_error('upgradetimedout', 'admin', "$CFG->wwroot/$CFG->admin/");
+ die;
+ }
+
+ if ($max_execution_time < 60) {
+ // protection against 0 here
+ $max_execution_time = 60;
+ }
+
+ $expected_end = time() + $max_execution_time;
+
+ if ($expected_end < $upgraderunning + 10 and $expected_end > $upgraderunning - 10) {
+ // no need to store new end, it is nearly the same ;-)
+ return;
+ }
+
+ set_time_limit($max_execution_time);
+ set_config('upgraderunning', $expected_end); // keep upgrade locked until this time
+}
/// MISCELLANEOUS ////////////////////////////////////////////////////////////////////
diff --git a/lib/pagelib.php b/lib/pagelib.php
index 73d0dbe6680..c1ad669a0e9 100644
--- a/lib/pagelib.php
+++ b/lib/pagelib.php
@@ -314,7 +314,7 @@ class page_course extends page_base {
// Do NOT load up "expensive" resouces (e.g. SQL data) here!
function init_quick($data) {
if(empty($data->pageid) && !defined('ADMIN_STICKYBLOCKS')) {
- print_error('cannotinitpage', '', '', null);
+ print_error('cannotinitpage', 'debug', '', (object)array('name'=>'course', 'id'=>'?'));
}
parent::init_quick($data);
}
@@ -339,7 +339,7 @@ class page_course extends page_base {
}
if(empty($this->courserecord) && !defined('ADMIN_STICKYBLOCKS')) {
- print_error('cannotinitpage', '', '', $this->id);
+ print_error('cannotinitpage', 'debug', '', (object)array('name'=>'course', 'id'=>$this->id));
}
$this->context = get_context_instance(CONTEXT_COURSE, $this->id);
@@ -594,7 +594,7 @@ class page_generic_activity extends page_base {
print_error('noactivityname', 'debug');
}
if (!$this->modulerecord = get_coursemodule_from_instance($this->activityname, $this->id)) {
- print_error('cannotinitpager', 'debug', '', array($this->activityname, $this->id));
+ print_error('cannotinitpager', 'debug', '', (object)array('name'=>$this->activityname, 'id'=>$this->id));
}
$this->courserecord = $DB->get_record('course', array('id'=>$this->modulerecord->course));
if(empty($this->courserecord)) {
@@ -602,7 +602,7 @@ class page_generic_activity extends page_base {
}
$this->activityrecord = $DB->get_record($this->activityname, array('id'=>$this->id));
if(empty($this->activityrecord)) {
- print_error('cannotinitpager', 'debug', '', array($this->activityname, $this->id));
+ print_error('cannotinitpager', 'debug', '', (object)array('name'=>$this->activityname, 'id'=>$this->id));
}
$this->full_init_done = true;
}
diff --git a/lib/setup.php b/lib/setup.php
index 30282a63481..97dc128ad4f 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -159,6 +159,15 @@ global $HTTPSPAGEREQUIRED;
/// Load up any configuration from the config table
$CFG = get_config();
+/// Verify upgrade is not running
+ if (isset($CFG->upgraderunning)) {
+ if ($CFG->upgraderunning < time()) {
+ unset_config('upgraderunning');
+ } else {
+ print_error('upgraderunning');
+ }
+ }
+
/// Turn on SQL logging if required
if (!empty($CFG->logsql)) {
$DB->set_logging(true);
diff --git a/lib/weblib.php b/lib/weblib.php
index c6e81b9e448..5cab18a80bb 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -5677,7 +5677,7 @@ function print_error($errorcode, $module='', $link='', $a=NULL) {
$module = 'error';
}
- if (!isset($CFG->theme)) {
+ if (!isset($CFG->theme) or !isset($CFG->stylesheets)) {
// error found before setup.php finished
_print_early_error($errorcode, $module, $a);
} else {
diff --git a/message/output/email/db/upgrade.php b/message/output/email/db/upgrade.php
index 3b8c0da0c55..0191416c5d5 100644
--- a/message/output/email/db/upgrade.php
+++ b/message/output/email/db/upgrade.php
@@ -32,10 +32,10 @@
* @package
*/
-function xmldb_message_email_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_message_email_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
if ($result && $oldversion < 2008072401) {
diff --git a/message/output/jabber/db/upgrade.php b/message/output/jabber/db/upgrade.php
index ec1578f74fe..bfb70d836bf 100644
--- a/message/output/jabber/db/upgrade.php
+++ b/message/output/jabber/db/upgrade.php
@@ -32,10 +32,10 @@
* @package
*/
-function xmldb_message_jabber_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_message_jabber_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
if ($result && $oldversion < 2008072401) {
diff --git a/message/output/popup/db/upgrade.php b/message/output/popup/db/upgrade.php
index 05783400b46..ecbcabea870 100644
--- a/message/output/popup/db/upgrade.php
+++ b/message/output/popup/db/upgrade.php
@@ -32,10 +32,10 @@
* @package
*/
-function xmldb_message_popup_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_message_popup_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
if ($result && $oldversion < 2008072401) {
diff --git a/mod/assignment/db/upgrade.php b/mod/assignment/db/upgrade.php
index 914b399363c..5ebd22c63a6 100644
--- a/mod/assignment/db/upgrade.php
+++ b/mod/assignment/db/upgrade.php
@@ -16,23 +16,22 @@
//
// 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_assignment_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_assignment_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
//===== 1.9.0 upgrade line ======//
if ($result && $oldversion < 2007101511) {
- notify('Processing assignment grades, this may take a while if there are many assignments...', 'notifysuccess');
// change grade typo to text if no grades MDL-13920
require_once $CFG->dirroot.'/mod/assignment/lib.php';
- // too much debug output
- $DB->set_debug(false);
- assignment_update_grades();
- $DB->set_debug(true);
+ assignment_upgrade_grades();
upgrade_mod_savepoint($result, 2007101511, 'assignment');
}
@@ -59,10 +58,11 @@ function xmldb_assignment_upgrade($oldversion=0) {
$pbar = new progress_bar('migrateassignmentfiles', 500, true);
$olddebug = $DB->get_debug();
-// $DB->set_debug(false); // lower debug level, there might be many files
+ $DB->set_debug(false); // lower debug level, there might be many files
$i = 0;
foreach ($rs as $submission) {
$i++;
+ upgrade_set_timeout(180); // set up timeout, may also abort execution
$basepath = "$CFG->dataroot/$submission->course/$CFG->moddata/assignment/$submission->assignment/$submission->userid/";
if (!file_exists($basepath)) {
//no files
diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php
index 30ef3c3bf5b..ecfae647fd5 100644
--- a/mod/assignment/lib.php
+++ b/mod/assignment/lib.php
@@ -2212,41 +2212,60 @@ function assignment_get_user_grades($assignment, $userid=0) {
}
/**
- * Update grades by firing grade_updated event
+ * Update activity grades
*
- * @param object $assignment null means all assignments
- * @param int $userid specific user only, 0 mean all
+ * @param object $assignment
+ * @param int $userid specific user only, 0 means all
*/
-function assignment_update_grades($assignment=null, $userid=0, $nullifnone=true) {
+function assignment_update_grades($assignment, $userid=0, $nullifnone=true) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
- if ($assignment != null) {
- if ($grades = assignment_get_user_grades($assignment, $userid)) {
- foreach($grades as $k=>$v) {
- if ($v->rawgrade == -1) {
- $grades[$k]->rawgrade = null;
- }
+ if ($assignment->grade == 0) {
+ assignment_grade_item_update($assignment);
+
+ } else if ($grades = assignment_get_user_grades($assignment, $userid)) {
+ foreach($grades as $k=>$v) {
+ if ($v->rawgrade == -1) {
+ $grades[$k]->rawgrade = null;
}
- assignment_grade_item_update($assignment, $grades);
- } else {
- assignment_grade_item_update($assignment);
}
+ assignment_grade_item_update($assignment, $grades);
} else {
- $sql = "SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid
- FROM {assignment} a, {course_modules} cm, {modules} m
- WHERE m.name='assignment' AND m.id=cm.module AND cm.instance=a.id";
- if ($rs = $DB->get_recordset_sql($sql)) {
- foreach ($rs as $assignment) {
- if ($assignment->grade != 0) {
- assignment_update_grades($assignment);
- } else {
- assignment_grade_item_update($assignment);
- }
- }
- $rs->close();
+ assignment_grade_item_update($assignment);
+ }
+}
+
+/**
+ * Update all grades in gradebook.
+ */
+function assignment_upgrade_grades() {
+ global $DB;
+
+ $sql = "SELECT COUNT('x')
+ FROM {assignment} a, {course_modules} cm, {modules} m
+ WHERE m.name='assignment' AND m.id=cm.module AND cm.instance=a.id";
+ $count = $DB->count_records_sql($sql);
+
+ $sql = "SELECT a.*, cm.idnumber AS cmidnumber, a.course AS courseid
+ FROM {assignment} a, {course_modules} cm, {modules} m
+ WHERE m.name='assignment' AND m.id=cm.module AND cm.instance=a.id";
+ if ($rs = $DB->get_recordset_sql($sql)) {
+ // too much debug output
+ $prevdebug = $DB->get_debug();
+ $DB->set_debug(false);
+ $pbar = new progress_bar('assignmentupgradegrades', 500, true);
+ $i=0;
+ foreach ($rs as $assignment) {
+ $i++;
+ upgrade_set_timeout(60*5); // set up timeout, may also abort execution
+ assignment_update_grades($assignment);
+ $pbar->update($i, $count, "Updating Assignment grades ($i/$count).");
}
+ $DB->set_debug($prevdebug);
+ $rs->close();
+ upgrade_set_timeout(); // reset to default timeout
}
}
diff --git a/mod/chat/db/upgrade.php b/mod/chat/db/upgrade.php
index 284e69c84ac..acf4d72a887 100644
--- a/mod/chat/db/upgrade.php
+++ b/mod/chat/db/upgrade.php
@@ -16,15 +16,18 @@
//
// 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_chat_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_chat_upgrade($oldversion) {
+ global $CFG, $DB;
$dbman = $DB->get_manager();
-
$result = true;
+//===== 1.9.0 upgrade line ======//
+
if ($result && $oldversion < 2008072400) {
/// Define table chat_messages_current to be created
@@ -48,10 +51,8 @@ function xmldb_chat_upgrade($oldversion=0) {
$table->add_index('groupid', XMLDB_INDEX_NOTUNIQUE, array('groupid'));
$table->add_index('timestamp-chatid', XMLDB_INDEX_NOTUNIQUE, array('timestamp', 'chatid'));
- /// Conditionally launch create table for chat_messages_current
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
+ /// create table for chat_messages_current
+ $dbman->create_table($table);
/// chat savepoint reached
upgrade_mod_savepoint($result, 2008072400, 'chat');
diff --git a/mod/choice/db/upgrade.php b/mod/choice/db/upgrade.php
index b8e04bc27b4..e57af619591 100644
--- a/mod/choice/db/upgrade.php
+++ b/mod/choice/db/upgrade.php
@@ -16,22 +16,16 @@
//
// 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_choice_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_choice_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of database_manager methods
-/// }
-
//===== 1.9.0 upgrade line ======//
return $result;
diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php
index 3bc3fdb13fd..e0731452ec1 100644
--- a/mod/data/db/upgrade.php
+++ b/mod/data/db/upgrade.php
@@ -16,13 +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_data_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_data_upgrade($oldversion) {
+ global $CFG, $DB;
$dbman = $DB->get_manager();
-
$result = true;
//===== 1.9.0 upgrade line ======//
diff --git a/mod/data/lib.php b/mod/data/lib.php
index 2f9aafd25e0..807a835968f 100755
--- a/mod/data/lib.php
+++ b/mod/data/lib.php
@@ -798,43 +798,60 @@ function data_get_user_grades($data, $userid=0) {
}
/**
- * Update grades by firing grade_updated event
+ * Update activity grades
*
- * @param object $data null means all databases
- * @param int $userid specific user only, 0 mean all
+ * @param object $data
+ * @param int $userid specific user only, 0 means all
*/
-function data_update_grades($data=null, $userid=0, $nullifnone=true) {
+function data_update_grades($data, $userid=0, $nullifnone=true) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
- if ($data != null) {
- if ($grades = data_get_user_grades($data, $userid)) {
- data_grade_item_update($data, $grades);
+ if (!$data->assessed) {
+ data_grade_item_update($data);
- } else if ($userid and $nullifnone) {
- $grade = new object();
- $grade->userid = $userid;
- $grade->rawgrade = NULL;
- data_grade_item_update($data, $grade);
+ } else if ($grades = data_get_user_grades($data, $userid)) {
+ data_grade_item_update($data, $grades);
- } else {
- data_grade_item_update($data);
- }
+ } else if ($userid and $nullifnone) {
+ $grade = new object();
+ $grade->userid = $userid;
+ $grade->rawgrade = NULL;
+ data_grade_item_update($data, $grade);
} else {
- $sql = "SELECT d.*, cm.idnumber as cmidnumber
- FROM {data} d, {course_modules} cm, {modules} m
- WHERE m.name='data' AND m.id=cm.module AND cm.instance=d.id";
- if ($rs = $DB->get_recordset_sql($sql)) {
- foreach ($rs as $data) {
- if ($data->assessed) {
- data_update_grades($data, 0, false);
- } else {
- data_grade_item_update($data);
- }
- }
- $rs->close();
+ data_grade_item_update($data);
+ }
+}
+
+/**
+ * Update all grades in gradebook.
+ */
+function data_upgrade_grades() {
+ global $DB;
+
+ $sql = "SELECT COUNT('x')
+ FROM {data} d, {course_modules} cm, {modules} m
+ WHERE m.name='data' AND m.id=cm.module AND cm.instance=d.id";
+ $count = $DB->count_records_sql($sql);
+
+ $sql = "SELECT d.*, cm.idnumber AS cmidnumber, d.course AS courseid
+ FROM {data} d, {course_modules} cm, {modules} m
+ WHERE m.name='data' AND m.id=cm.module AND cm.instance=d.id";
+ if ($rs = $DB->get_recordset_sql($sql)) {
+ // too much debug output
+ $prevdebug = $DB->get_debug();
+ $DB->set_debug(false);
+ $pbar = new progress_bar('dataupgradegrades', 500, true);
+ $i=0;
+ foreach ($rs as $data) {
+ $i++;
+ upgrade_set_timeout(60*5); // set up timeout, may also abort execution
+ data_update_grades($data, 0, false);
+ $pbar->update($i, $count, "Updating Database grades ($i/$count).");
}
+ $DB->set_debug($prevdebug);
+ $rs->close();
}
}
diff --git a/mod/data/rate.php b/mod/data/rate.php
index eff04e9f60a..45155a25cfe 100755
--- a/mod/data/rate.php
+++ b/mod/data/rate.php
@@ -64,7 +64,7 @@
} else if ($rating != $oldrating->rating) {
$oldrating->rating = $rating;
if (!$DB->update_record('data_ratings', $oldrating)) {
- print_error('cannotupdaterate', 'data', '', array($record->id, $rating));
+ print_error('cannotupdaterate', 'error', '', (object)array('id'=>$record->id, 'rating'=>$rating));
}
data_update_grades($data, $record->userid);
@@ -76,7 +76,7 @@
$newrating->recordid = $record->id;
$newrating->rating = $rating;
if (! $DB->insert_record('data_ratings', $newrating)) {
- print_error('cannotinsertrate', 'data', '', array($record->id, $rating));
+ print_error('cannotinsertrate', 'error', '', (object)array('id'=>$record->id, 'rating'=>$rating));
}
data_update_grades($data, $record->userid);
}
diff --git a/mod/feedback/db/upgrade.php b/mod/feedback/db/upgrade.php
index feb2535046f..8d5fc1661d8 100644
--- a/mod/feedback/db/upgrade.php
+++ b/mod/feedback/db/upgrade.php
@@ -16,13 +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_feedback_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_feedback_upgrade($oldversion) {
+ global $CFG, $DB;
$dbman = $DB->get_manager();
-
$result = true;
if ($result && $oldversion < 2007012310) {
diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php
index b11246cd964..a7a0c220345 100644
--- a/mod/forum/db/upgrade.php
+++ b/mod/forum/db/upgrade.php
@@ -16,35 +16,22 @@
//
// 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_forum_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_forum_upgrade($oldversion) {
+ global $CFG, $DB;
$dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
-
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of database_manager methods
-/// }
-
//===== 1.9.0 upgrade line ======//
if ($result and $oldversion < 2007101511) {
- notify('Processing forum grades, this may take a while if there are many forums...', 'notifysuccess');
//MDL-13866 - send forum ratins to gradebook again
require_once($CFG->dirroot.'/mod/forum/lib.php');
- // too much debug output
- $DB->set_debug(false);
- forum_update_grades();
- $DB->set_debug(true);
-
+ forum_upgrade_grades();
upgrade_mod_savepoint($result, 2007101511, 'forum');
}
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index 3c88ccf74f7..d5c9a3580a8 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -1424,45 +1424,62 @@ function forum_get_user_grades($forum, $userid=0) {
}
/**
- * Update grades by firing grade_updated event
+ * Update activity grades
*
- * @param object $forum null means all forums
- * @param int $userid specific user only, 0 mean all
+ * @param object $forum
+ * @param int $userid specific user only, 0 means all
* @param boolean $nullifnone return null if grade does not exist
* @return void
*/
-function forum_update_grades($forum=null, $userid=0, $nullifnone=true) {
+function forum_update_grades($forum, $userid=0, $nullifnone=true) {
global $CFG, $DB;
+ require_once($CFG->libdir.'/gradelib.php');
- if ($forum != null) {
- require_once($CFG->libdir.'/gradelib.php');
- if ($grades = forum_get_user_grades($forum, $userid)) {
- forum_grade_item_update($forum, $grades);
+ if (!$forum->assessed) {
+ forum_grade_item_update($forum);
- } else if ($userid and $nullifnone) {
- $grade = new object();
- $grade->userid = $userid;
- $grade->rawgrade = NULL;
- forum_grade_item_update($forum, $grade);
+ } else if ($grades = forum_get_user_grades($forum, $userid)) {
+ forum_grade_item_update($forum, $grades);
- } else {
- forum_grade_item_update($forum);
- }
+ } else if ($userid and $nullifnone) {
+ $grade = new object();
+ $grade->userid = $userid;
+ $grade->rawgrade = NULL;
+ forum_grade_item_update($forum, $grade);
} else {
- $sql = "SELECT f.*, cm.idnumber as cmidnumber
- FROM {forum} f, {course_modules} cm, {modules} m
- WHERE m.name='forum' AND m.id=cm.module AND cm.instance=f.id";
- if ($rs = $DB->get_recordset_sql($sql)) {
- foreach ($rs as $forum) {
- if ($forum->assessed) {
- forum_update_grades($forum, 0, false);
- } else {
- forum_grade_item_update($forum);
- }
- }
- $rs->close();
+ forum_grade_item_update($forum);
+ }
+}
+
+/**
+ * Update all grades in gradebook.
+ */
+function forum_upgrade_grades() {
+ global $DB;
+
+ $sql = "SELECT COUNT('x')
+ FROM {forum} f, {course_modules} cm, {modules} m
+ WHERE m.name='forum' AND m.id=cm.module AND cm.instance=f.id";
+ $count = $DB->count_records_sql($sql);
+
+ $sql = "SELECT f.*, cm.idnumber AS cmidnumber, f.course AS courseid
+ FROM {forum} f, {course_modules} cm, {modules} m
+ WHERE m.name='forum' AND m.id=cm.module AND cm.instance=f.id";
+ if ($rs = $DB->get_recordset_sql($sql)) {
+ // too much debug output
+ $prevdebug = $DB->get_debug();
+ $DB->set_debug(false);
+ $pbar = new progress_bar('forumupgradegrades', 500, true);
+ $i=0;
+ foreach ($rs as $forum) {
+ $i++;
+ upgrade_set_timeout(60*5); // set up timeout, may also abort execution
+ forum_update_grades($forum, 0, false);
+ $pbar->update($i, $count, "Updating Forum grades ($i/$count).");
}
+ $DB->set_debug($prevdebug);
+ $rs->close();
}
}
diff --git a/mod/forum/rate.php b/mod/forum/rate.php
index 276c04e33b3..b9d8afd3c48 100644
--- a/mod/forum/rate.php
+++ b/mod/forum/rate.php
@@ -71,8 +71,7 @@
$oldrating->rating = $rating;
$oldrating->time = time();
if (!$DB->update_record('forum_ratings', $oldrating)) {
- print_error('cannotupdaterate', 'forum', '',
- array($post->id, $rating));
+ print_error('cannotupdaterate', 'error', '', (object)array('id'=>$post->id, 'rating'=>$rating));
}
forum_update_grades($forum, $post->userid);
}
@@ -85,8 +84,7 @@
$newrating->rating = $rating;
if (! $DB->insert_record('forum_ratings', $newrating)) {
- print_error('cannotinsertrate', 'forum', '',
- array($postid, $rating));
+ print_error('cannotinsertrate', 'error', '', (object)array('id'=>$postid, 'rating'=>$rating));
}
forum_update_grades($forum, $post->userid);
}
diff --git a/mod/glossary/db/upgrade.php b/mod/glossary/db/upgrade.php
index ca1a3991231..876148fca38 100644
--- a/mod/glossary/db/upgrade.php
+++ b/mod/glossary/db/upgrade.php
@@ -16,22 +16,16 @@
//
// 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_glossary_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_glossary_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of database_manager methods
-/// }
-
//===== 1.9.0 upgrade line ======//
return $result;
diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php
index ae8a016ec03..48681cbd9cc 100644
--- a/mod/glossary/lib.php
+++ b/mod/glossary/lib.php
@@ -323,43 +323,59 @@ function glossary_get_user_grades($glossary, $userid=0) {
}
/**
- * Update grades by firing grade_updated event
+ * Update activity grades
*
* @param object $glossary null means all glossaries
- * @param int $userid specific user only, 0 mean all
+ * @param int $userid specific user only, 0 means all
*/
function glossary_update_grades($glossary=null, $userid=0, $nullifnone=true) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
- if ($glossary != null) {
- if ($grades = glossary_get_user_grades($glossary, $userid)) {
- glossary_grade_item_update($glossary, $grades);
+ if (!$glossary->assessed) {
+ glossary_grade_item_update($glossary);
- } else if ($userid and $nullifnone) {
- $grade = new object();
- $grade->userid = $userid;
- $grade->rawgrade = NULL;
- glossary_grade_item_update($glossary, $grade);
+ } else if ($grades = glossary_get_user_grades($glossary, $userid)) {
+ glossary_grade_item_update($glossary, $grades);
- } else {
- glossary_grade_item_update($glossary);
- }
+ } else if ($userid and $nullifnone) {
+ $grade = new object();
+ $grade->userid = $userid;
+ $grade->rawgrade = NULL;
+ glossary_grade_item_update($glossary, $grade);
} else {
- $sql = "SELECT g.*, cm.idnumber as cmidnumber
- FROM {glossary} g, {course_modules} cm, {modules} m
- WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
- if ($rs = $DB->get_recordset_sql($sql)) {
- foreach ($rs as $glossary) {
- if ($glossary->assessed) {
- glossary_update_grades($glossary, 0, false);
- } else {
- glossary_grade_item_update($glossary);
- }
- }
- $rs->close();
+ glossary_grade_item_update($glossary);
+ }
+}
+
+/**
+ * Update all grades in gradebook.
+ */
+function glossary_upgrade_grades() {
+ global $DB;
+
+ $sql = "SELECT COUNT('x')
+ FROM {glossary} g, {course_modules} cm, {modules} m
+ WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
+ $count = $DB->count_records_sql($sql);
+
+ $sql = "SELECT g.*, cm.idnumber AS cmidnumber, g.course AS courseid
+ FROM {glossary} g, {course_modules} cm, {modules} m
+ WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
+ if ($rs = $DB->get_recordset_sql($sql)) {
+ $prevdebug = $DB->get_debug();
+ $DB->set_debug(false);
+ $pbar = new progress_bar('glossaryupgradegrades', 500, true);
+ $i=0;
+ foreach ($rs as $glossary) {
+ $i++;
+ upgrade_set_timeout(60*5); // set up timeout, may also abort execution
+ glossary_update_grades($glossary, 0, false);
+ $pbar->update($i, $count, "Updating Glossary grades ($i/$count).");
}
+ $DB->set_debug($prevdebug);
+ $rs->close();
}
}
diff --git a/mod/glossary/rate.php b/mod/glossary/rate.php
index 2dd714a73cc..58f2a9f6900 100644
--- a/mod/glossary/rate.php
+++ b/mod/glossary/rate.php
@@ -77,7 +77,7 @@
$oldrating->rating = $rating;
$oldrating->time = time();
if (! $DB->update_record("glossary_ratings", $oldrating)) {
- print_error('cannotinsertrate', '', '', array($entry, $rating));
+ print_error('cannotinsertrate', 'error', '', (object)array('id'=>$entry->id, 'rating'=>$rating));
}
glossary_update_grades($glossary, $entry->userid);
}
@@ -90,7 +90,7 @@
$newrating->rating = $rating;
if (! $DB->insert_record("glossary_ratings", $newrating)) {
- print_error('cannotinsertrate', '', '', array($entry->id, $rating));
+ print_error('cannotinsertrate', 'error', '', (object)array('id'=>$entry->id, 'rating'=>$rating));
}
glossary_update_grades($glossary, $entry->userid);
}
diff --git a/mod/hotpot/db/upgrade.php b/mod/hotpot/db/upgrade.php
index ec2d495ba22..158927a6ea4 100644
--- a/mod/hotpot/db/upgrade.php
+++ b/mod/hotpot/db/upgrade.php
@@ -1,29 +1,23 @@
get_manager();
$result = true;
//===== 1.9.0 upgrade line ======//
// update hotpot grades from sites earlier than Moodle 1.9, 27th March 2008
if ($result && $oldversion < 2007101511) {
-
- // ensure "hotpot_update_grades" function is available
+ // ensure "hotpot_upgrade_grades" function is available
require_once $CFG->dirroot.'/mod/hotpot/lib.php';
-
- // disable display of debugging messages
- $DB->set_debug(false);
-
- notify('Processing hotpot grades, this may take a while if there are many hotpots...', 'notifysuccess');
- hotpot_update_grades();
-
- // restore debug
- $DB->set_debug(true);
+ hotpot_upgrade_grades();
}
return $result;
diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php
index 6dbc93fd95d..eceecb02247 100644
--- a/mod/hotpot/lib.php
+++ b/mod/hotpot/lib.php
@@ -1256,46 +1256,63 @@ function hotpot_get_user_grades($hotpot, $userid=0) {
/**
* Update grades in central gradebook
- * this function is called from db/upgrade.php
- * it is initially called with no arguments, which forces it to get a list of all hotpots
- * it then iterates through the hotpots, calling itself to create a grade record for each hotpot
- *
- * @param object $hotpot null means all hotpots
+ * @param object $hotpot
* @param int $userid specific user only, 0 means all users
*/
-function hotpot_update_grades($hotpot=null, $userid=0, $nullifnone=true) {
+function hotpot_update_grades($hotpot, $userid=0, $nullifnone=true) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
- if (is_null($hotpot)) {
- // update (=create) grades for all hotpots
- $sql = "
- SELECT h.*, cm.idnumber as cmidnumber
- FROM {hotpot} h, {course_modules} cm, {modules} m
- WHERE m.name='hotpot' AND m.id=cm.module AND cm.instance=h.id"
- ;
- if ($rs = $DB->get_recordset_sql($sql)) {
- foreach ($rs as $hotpot) {
- hotpot_update_grades($hotpot, 0, false);
- }
- $rs->close();
- }
+ // update (=create) grade for a single hotpot
+ if ($grades = hotpot_get_user_grades($hotpot, $userid)) {
+ hotpot_grade_item_update($hotpot, $grades);
+
+ } else if ($userid && $nullifnone) {
+ // no grades for this user, but we must force the creation of a "null" grade record
+ $grade = new object();
+ $grade->userid = $userid;
+ $grade->rawgrade = null;
+ hotpot_grade_item_update($hotpot, $grade);
+
} else {
- // update (=create) grade for a single hotpot
- if ($grades = hotpot_get_user_grades($hotpot, $userid)) {
- hotpot_grade_item_update($hotpot, $grades);
+ // no grades and no userid
+ hotpot_grade_item_update($hotpot);
+ }
+}
- } else if ($userid && $nullifnone) {
- // no grades for this user, but we must force the creation of a "null" grade record
- $grade = new object();
- $grade->userid = $userid;
- $grade->rawgrade = null;
- hotpot_grade_item_update($hotpot, $grade);
+/**
+ * Update all grades in gradebook.
+ * this function is called from db/upgrade.php
+ * it iterates through the hotpots, calling hotpot_update_grades() to create a grade record for each hotpot
+ */
+function hotpot_upgrade_grades() {
+ global $DB;
- } else {
- // no grades and no userid
- hotpot_grade_item_update($hotpot);
+ // upgrade (=create) grades for all hotpots
+ $sql = "
+ SELECT COUNT('x')
+ FROM {hotpot} h, {course_modules} cm, {modules} m
+ WHERE m.name='hotpot' AND m.id=cm.module AND cm.instance=h.id";
+ $count = $DB->count_records_sql($sql);
+
+ $sql = "
+ SELECT h.*, cm.idnumber AS cmidnumber
+ FROM {hotpot} h, {course_modules} cm, {modules} m
+ WHERE m.name='hotpot' AND m.id=cm.module AND cm.instance=h.id";
+ if ($rs = $DB->get_recordset_sql($sql)) {
+ // too much debug output
+ $prevdebug = $DB->get_debug();
+ $DB->set_debug(false);
+ $pbar = new progress_bar('hotpotupgradegrades', 500, true);
+ $i=0;
+ foreach ($rs as $hotpot) {
+ $i++;
+ upgrade_set_timeout(60*5); // set up timeout, may also abort execution
+ hotpot_update_grades($hotpot, 0, false);
+ $pbar->update($i, $count, "Updating Hotpot grades ($i/$count).");
}
+ $DB->set_debug($prevdebug);
+ $rs->close();
}
}
@@ -1479,9 +1496,6 @@ class hotpot_xml_tree {
if (empty($str)) {
$this->xml = array();
} else {
- if (empty($CFG->unicodedb)) {
- $str = utf8_encode($str);
- }
$this->xml = xmlize($str, 0);
}
$this->xml_root = $xml_root;
@@ -1492,9 +1506,6 @@ class hotpot_xml_tree {
eval('$value = &$this->xml'.$this->xml_root.$tags.$more_tags.';');
if (is_string($value)) {
- if (empty($CFG->unicodedb)) {
- $value = utf8_decode($value);
- }
// decode angle brackets
$value = strtr($value, array('<'=>'<', '>'=>'>', '&'=>'&'));
diff --git a/mod/label/db/upgrade.php b/mod/label/db/upgrade.php
index 9f5c5a5a680..b975c183656 100644
--- a/mod/label/db/upgrade.php
+++ b/mod/label/db/upgrade.php
@@ -16,22 +16,18 @@
//
// 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_label_upgrade($oldversion=0) {
- global $CFG, $THEME, $DB;
+function xmldb_label_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of database_manager methods
-/// }
-
//===== 1.9.0 upgrade line ======//
+
if ($oldversion < 2007101510) {
$sql = "UPDATE {log_display} SET mtable = 'label' WHERE module = 'label'";
$result = $DB->execute($sql);
diff --git a/mod/lesson/db/upgrade.php b/mod/lesson/db/upgrade.php
index 91b1f0a3cb6..cf44533725d 100644
--- a/mod/lesson/db/upgrade.php
+++ b/mod/lesson/db/upgrade.php
@@ -16,13 +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_lesson_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_lesson_upgrade($oldversion) {
+ global $CFG, $DB;
$dbman = $DB->get_manager();
-
$result = true;
//===== 1.9.0 upgrade line ======//
diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php
index 173726dadee..9b7998b7787 100644
--- a/mod/lesson/lib.php
+++ b/mod/lesson/lib.php
@@ -385,43 +385,57 @@ function lesson_get_user_grades($lesson, $userid=0) {
/**
* Update grades in central gradebook
*
- * @param object $lesson null means all lessons
- * @param int $userid specific user only, 0 mean all
+ * @param object $lesson
+ * @param int $userid specific user only, 0 means all
*/
-function lesson_update_grades($lesson=null, $userid=0, $nullifnone=true) {
+function lesson_update_grades($lesson, $userid=0, $nullifnone=true) {
global $CFG, $DB;
- if (!function_exists('grade_update')) { //workaround for buggy PHP versions
- require_once($CFG->libdir.'/gradelib.php');
- }
+ require_once($CFG->libdir.'/gradelib.php');
- if ($lesson != null) {
- if ($grades = lesson_get_user_grades($lesson, $userid)) {
- lesson_grade_item_update($lesson, $grades);
+ if ($lesson->grade == 0) {
+ lesson_grade_item_update($lesson);
- } else if ($userid and $nullifnone) {
- $grade = new object();
- $grade->userid = $userid;
- $grade->rawgrade = NULL;
- lesson_grade_item_update($lesson, $grade);
+ } else if ($grades = lesson_get_user_grades($lesson, $userid)) {
+ lesson_grade_item_update($lesson, $grades);
- } else {
- lesson_grade_item_update($lesson);
- }
+ } else if ($userid and $nullifnone) {
+ $grade = new object();
+ $grade->userid = $userid;
+ $grade->rawgrade = NULL;
+ lesson_grade_item_update($lesson, $grade);
} else {
- $sql = "SELECT l.*, cm.idnumber as cmidnumber, l.course as courseid
- FROM {lesson} l, {course_modules} cm, {modules} m
- WHERE m.name='lesson' AND m.id=cm.module AND cm.instance=l.id";
- if ($rs = $DB->get_recordset_sql($sql)) {
- foreach ($rs as $lesson) {
- if ($lesson->grade != 0) {
- lesson_update_grades($lesson, 0, false);
- } else {
- lesson_grade_item_update($lesson);
- }
- }
- $rs->close();
+ lesson_grade_item_update($lesson);
+ }
+}
+
+/**
+ * Update all grades in gradebook.
+ */
+function lesson_upgrade_grades() {
+ global $DB;
+
+ $sql = "SELECT COUNT('x')
+ FROM {lesson} l, {course_modules} cm, {modules} m
+ WHERE m.name='lesson' AND m.id=cm.module AND cm.instance=l.id";
+ $count = $DB->count_records_sql($sql);
+
+ $sql = "SELECT l.*, cm.idnumber AS cmidnumber, l.course AS courseid
+ FROM {lesson} l, {course_modules} cm, {modules} m
+ WHERE m.name='lesson' AND m.id=cm.module AND cm.instance=l.id";
+ if ($rs = $DB->get_recordset_sql($sql)) {
+ $prevdebug = $DB->get_debug();
+ $DB->set_debug(false);
+ $pbar = new progress_bar('lessonupgradegrades', 500, true);
+ $i=0;
+ foreach ($rs as $lesson) {
+ $i++;
+ upgrade_set_timeout(60*5); // set up timeout, may also abort execution
+ lesson_update_grades($lesson, 0, false);
+ $pbar->update($i, $count, "Updating Lesson grades ($i/$count).");
}
+ $DB->set_debug($prevdebug);
+ $rs->close();
}
}
diff --git a/mod/quiz/db/upgrade.php b/mod/quiz/db/upgrade.php
index 6a0b0420f73..d3ec9b890d3 100644
--- a/mod/quiz/db/upgrade.php
+++ b/mod/quiz/db/upgrade.php
@@ -16,13 +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_quiz_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_quiz_upgrade($oldversion) {
+ global $CFG, $DB;
$dbman = $DB->get_manager();
-
$result = true;
//===== 1.9.0 upgrade line ======//
diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php
index df5ce08c768..6492cd9702b 100644
--- a/mod/quiz/lib.php
+++ b/mod/quiz/lib.php
@@ -310,43 +310,57 @@ function quiz_format_grade($quiz, $grade) {
/**
* Update grades in central gradebook
*
- * @param object $quiz null means all quizs
- * @param int $userid specific user only, 0 mean all
+ * @param object $quiz
+ * @param int $userid specific user only, 0 means all
*/
-function quiz_update_grades($quiz=null, $userid=0, $nullifnone=true) {
+function quiz_update_grades($quiz, $userid=0, $nullifnone=true) {
global $CFG, $DB;
- if (!function_exists('grade_update')) { //workaround for buggy PHP versions
- require_once($CFG->libdir.'/gradelib.php');
- }
+ require_once($CFG->libdir.'/gradelib.php');
- if ($quiz != null) {
- if ($grades = quiz_get_user_grades($quiz, $userid)) {
- quiz_grade_item_update($quiz, $grades);
+ if ($quiz->grade == 0) {
+ quiz_grade_item_update($quiz);
- } else if ($userid and $nullifnone) {
- $grade = new object();
- $grade->userid = $userid;
- $grade->rawgrade = NULL;
- quiz_grade_item_update($quiz, $grade);
+ } else if ($grades = quiz_get_user_grades($quiz, $userid)) {
+ quiz_grade_item_update($quiz, $grades);
- } else {
- quiz_grade_item_update($quiz);
- }
+ } else if ($userid and $nullifnone) {
+ $grade = new object();
+ $grade->userid = $userid;
+ $grade->rawgrade = NULL;
+ quiz_grade_item_update($quiz, $grade);
} else {
- $sql = "SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid
- FROM {quiz} a, {course_modules} cm, {modules} m
- WHERE m.name='quiz' AND m.id=cm.module AND cm.instance=a.id";
- if ($rs = $DB->get_recordset_sql($sql)) {
- foreach ($rs as $quiz) {
- if ($quiz->grade != 0) {
- quiz_update_grades($quiz, 0, false);
- } else {
- quiz_grade_item_update($quiz);
- }
- }
- $rs->close();
+ quiz_grade_item_update($quiz);
+ }
+}
+
+/**
+ * Update all grades in gradebook.
+ */
+function quiz_upgrade_grades() {
+ global $DB;
+
+ $sql = "SELECT COUNT('x')
+ FROM {quiz} a, {course_modules} cm, {modules} m
+ WHERE m.name='quiz' AND m.id=cm.module AND cm.instance=a.id";
+ $count = $DB->count_records_sql($sql);
+
+ $sql = "SELECT a.*, cm.idnumber AS cmidnumber, a.course AS courseid
+ FROM {quiz} a, {course_modules} cm, {modules} m
+ WHERE m.name='quiz' AND m.id=cm.module AND cm.instance=a.id";
+ if ($rs = $DB->get_recordset_sql($sql)) {
+ $prevdebug = $DB->get_debug();
+ $DB->set_debug(false);
+ $pbar = new progress_bar('quizupgradegrades', 500, true);
+ $i=0;
+ foreach ($rs as $quiz) {
+ $i++;
+ upgrade_set_timeout(60*5); // set up timeout, may also abort execution
+ quiz_update_grades($quiz, 0, false);
+ $pbar->update($i, $count, "Updating Quiz grades ($i/$count).");
}
+ $DB->set_debug($prevdebug);
+ $rs->close();
}
}
diff --git a/mod/quiz/pagelib.php b/mod/quiz/pagelib.php
index fc2c59e3729..884a227f09d 100644
--- a/mod/quiz/pagelib.php
+++ b/mod/quiz/pagelib.php
@@ -20,7 +20,7 @@ class page_quiz extends page_generic_activity {
function init_quick($data) {
if(empty($data->pageid)) {
- print_error('cannotinitpage', '', '', null);
+ print_error('cannotinitpage', 'debug', '', (object)array('name'=>'quiz', 'id'=>'?'));
}
$this->activityname = 'quiz';
parent::init_quick($data);
diff --git a/mod/quiz/report/overview/db/upgrade.php b/mod/quiz/report/overview/db/upgrade.php
index bee8b66ce1b..57ae3a93b9e 100644
--- a/mod/quiz/report/overview/db/upgrade.php
+++ b/mod/quiz/report/overview/db/upgrade.php
@@ -1,11 +1,9 @@
get_manager();
-
$result = true;
//===== 1.9.0 upgrade line ======//
diff --git a/mod/quiz/report/statistics/db/upgrade.php b/mod/quiz/report/statistics/db/upgrade.php
index e8e007870fb..d6ec6023a8d 100644
--- a/mod/quiz/report/statistics/db/upgrade.php
+++ b/mod/quiz/report/statistics/db/upgrade.php
@@ -1,6 +1,6 @@
get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of database_manager methods
-/// }
-
//===== 1.9.0 upgrade line ======//
return $result;
diff --git a/mod/scorm/db/upgrade.php b/mod/scorm/db/upgrade.php
index 31064785e6d..1a0c0ab9b09 100644
--- a/mod/scorm/db/upgrade.php
+++ b/mod/scorm/db/upgrade.php
@@ -16,13 +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_scorm_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_scorm_upgrade($oldversion) {
+ global $CFG, $DB;
$dbman = $DB->get_manager();
-
$result = true;
//===== 1.9.0 upgrade line ======//
@@ -34,7 +35,7 @@ function xmldb_scorm_upgrade($oldversion=0) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'grademethod');
/// Launch add field whatgrade
- if(!$dbman->field_exists($table,$field)) {
+ if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php
index c7e61fed8ed..f82f8357d24 100755
--- a/mod/scorm/lib.php
+++ b/mod/scorm/lib.php
@@ -441,39 +441,54 @@ function scorm_get_user_grades($scorm, $userid=0) {
/**
* Update grades in central gradebook
*
- * @param object $scorm null means all scormbases
+ * @param object $scorm
* @param int $userid specific user only, 0 mean all
*/
-function scorm_update_grades($scorm=null, $userid=0, $nullifnone=true) {
+function scorm_update_grades($scorm, $userid=0, $nullifnone=true) {
global $CFG, $DB;
- if (!function_exists('grade_update')) { //workaround for buggy PHP versions
- require_once($CFG->libdir.'/gradelib.php');
- }
+ require_once($CFG->libdir.'/gradelib.php');
- if ($scorm != null) {
- if ($grades = scorm_get_user_grades($scorm, $userid)) {
- scorm_grade_item_update($scorm, $grades);
+ if ($grades = scorm_get_user_grades($scorm, $userid)) {
+ scorm_grade_item_update($scorm, $grades);
- } else if ($userid and $nullifnone) {
- $grade = new object();
- $grade->userid = $userid;
- $grade->rawgrade = NULL;
- scorm_grade_item_update($scorm, $grade);
-
- } else {
- scorm_grade_item_update($scorm);
- }
+ } else if ($userid and $nullifnone) {
+ $grade = new object();
+ $grade->userid = $userid;
+ $grade->rawgrade = NULL;
+ scorm_grade_item_update($scorm, $grade);
} else {
- $sql = "SELECT s.*, cm.idnumber as cmidnumber
- FROM {scorm} s, {course_modules} cm, {modules} m
- WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id";
- if ($rs = $DB->get_recordset_sql($sql)) {
- foreach ($rs as $scorm) {
- scorm_update_grades($scorm, 0, false);
- }
- $rs->close();
+ scorm_grade_item_update($scorm);
+ }
+}
+
+/**
+ * Update all grades in gradebook.
+ */
+function scorm_upgrade_grades() {
+ global $DB;
+
+ $sql = "SELECT COUNT('x')
+ FROM {scorm} s, {course_modules} cm, {modules} m
+ WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id";
+ $count = $DB->count_records_sql($sql);
+
+ $sql = "SELECT s.*, cm.idnumber AS cmidnumber, s.course AS courseid
+ FROM {scorm} s, {course_modules} cm, {modules} m
+ WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id";
+ if ($rs = $DB->get_recordset_sql($sql)) {
+ $prevdebug = $DB->get_debug();
+ $DB->set_debug(false);
+ $pbar = new progress_bar('scormupgradegrades', 500, true);
+ $i=0;
+ foreach ($rs as $scorm) {
+ $i++;
+ upgrade_set_timeout(60*5); // set up timeout, may also abort execution
+ scorm_update_grades($scorm, 0, false);
+ $pbar->update($i, $count, "Updating Scorm grades ($i/$count).");
}
+ $DB->set_debug($prevdebug);
+ $rs->close();
}
}
diff --git a/mod/survey/db/upgrade.php b/mod/survey/db/upgrade.php
index cb26e843180..18dde0c6365 100644
--- a/mod/survey/db/upgrade.php
+++ b/mod/survey/db/upgrade.php
@@ -16,22 +16,16 @@
//
// 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_survey_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_survey_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of database_manager methods
-/// }
-
//===== 1.9.0 upgrade line ======//
return $result;
diff --git a/mod/wiki/db/upgrade.php b/mod/wiki/db/upgrade.php
index 24806e82c99..86bb4c28e48 100644
--- a/mod/wiki/db/upgrade.php
+++ b/mod/wiki/db/upgrade.php
@@ -16,22 +16,16 @@
//
// 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_wiki_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_wiki_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of database_manager methods
-/// }
-
//===== 1.9.0 upgrade line ======//
return $result;
diff --git a/question/type/calculated/db/upgrade.php b/question/type/calculated/db/upgrade.php
index 05c6c2823d9..925230445fa 100644
--- a/question/type/calculated/db/upgrade.php
+++ b/question/type/calculated/db/upgrade.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_qtype_calculated_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_calculated_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/question/type/datasetdependent/db/upgrade.php b/question/type/datasetdependent/db/upgrade.php
index d3017c73686..b4675ceece0 100644
--- a/question/type/datasetdependent/db/upgrade.php
+++ b/question/type/datasetdependent/db/upgrade.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_qtype_datasetdependent_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_datasetdependent_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/question/type/essay/db/upgrade.php b/question/type/essay/db/upgrade.php
index b98d8fb5a50..0ec034a1151 100644
--- a/question/type/essay/db/upgrade.php
+++ b/question/type/essay/db/upgrade.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_qtype_essay_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_essay_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/question/type/match/db/upgrade.php b/question/type/match/db/upgrade.php
index 16d352b3a45..77f555cefc9 100644
--- a/question/type/match/db/upgrade.php
+++ b/question/type/match/db/upgrade.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_qtype_match_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_match_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/question/type/multianswer/db/upgrade.php b/question/type/multianswer/db/upgrade.php
index e1d5b2ffaa2..c0f732b6a04 100644
--- a/question/type/multianswer/db/upgrade.php
+++ b/question/type/multianswer/db/upgrade.php
@@ -16,22 +16,16 @@
//
// 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_qtype_multianswer_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_multianswer_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of database_manager methods
-/// }
-
if ($result && $oldversion < 2008050800) {
question_multianswer_fix_subquestion_parents_and_categories();
}
diff --git a/question/type/multichoice/db/upgrade.php b/question/type/multichoice/db/upgrade.php
index c2ec89247d7..cc8041c11b0 100644
--- a/question/type/multichoice/db/upgrade.php
+++ b/question/type/multichoice/db/upgrade.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_qtype_multichoice_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_multichoice_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
return $result;
diff --git a/question/type/numerical/db/upgrade.php b/question/type/numerical/db/upgrade.php
index 75d80651adf..57813f207f9 100644
--- a/question/type/numerical/db/upgrade.php
+++ b/question/type/numerical/db/upgrade.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_qtype_numerical_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_numerical_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
//===== 1.9.0 upgrade line ======//
diff --git a/question/type/randomsamatch/db/upgrade.php b/question/type/randomsamatch/db/upgrade.php
index 02ac7a2b36b..dcefd68934a 100644
--- a/question/type/randomsamatch/db/upgrade.php
+++ b/question/type/randomsamatch/db/upgrade.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_qtype_randomsamatch_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_randomsamatch_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/question/type/shortanswer/db/upgrade.php b/question/type/shortanswer/db/upgrade.php
index d38673d9ce8..e0097e0abb7 100644
--- a/question/type/shortanswer/db/upgrade.php
+++ b/question/type/shortanswer/db/upgrade.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_qtype_shortanswer_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_shortanswer_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/question/type/truefalse/db/upgrade.php b/question/type/truefalse/db/upgrade.php
index c10321a9bb3..c2b85e99bbc 100644
--- a/question/type/truefalse/db/upgrade.php
+++ b/question/type/truefalse/db/upgrade.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_qtype_truefalse_upgrade($oldversion=0) {
-
- global $CFG, $THEME, $DB;
+function xmldb_qtype_truefalse_upgrade($oldversion) {
+ global $CFG, $DB;
+ $dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
diff --git a/search/query.php b/search/query.php
index 89d07652225..e1c99e53b73 100644
--- a/search/query.php
+++ b/search/query.php
@@ -337,9 +337,6 @@
$iconpath = $CFG->modpixpath.'/'.$listing->doctype.'/icon.gif';
$coursename = get_field('course', 'fullname', 'id', $listing->courseid);
$courseword = mb_convert_case(get_string('course', 'moodle'), MB_CASE_LOWER, 'UTF-8');
- //if ($CFG->unicodedb) {
- //$listing->title = mb_convert_encoding($listing->title, 'auto', 'UTF8');
- //}
$title_post_processing_function = $listing->doctype.'_link_post_processing';
$searchable_instance = $searchables[$listing->doctype];
if ($searchable_instance->location == 'internal'){
diff --git a/user/editlib.php b/user/editlib.php
index ba316786583..45e975e52cc 100644
--- a/user/editlib.php
+++ b/user/editlib.php
@@ -100,7 +100,7 @@ function useredit_shared_definition(&$mform) {
$mform->setType('lastname', PARAM_NOTAGS);
// Do not show email field if change confirmation is pending
- if ($CFG->emailchangeconfirmation && !empty($user->preference_newemail)) {
+ if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
$notice = get_string('auth_emailchangepending', 'auth', $user);
$notice .= '
'
. get_string('auth_emailchangecancel', 'auth') . '';
@@ -167,7 +167,7 @@ function useredit_shared_definition(&$mform) {
$mform->setAdvanced('trackforums');
}
- if ($CFG->htmleditor) {
+ if (!empty($CFG->htmleditor)) {
$choices = array();
$choices['0'] = get_string('texteditor');
$choices['1'] = get_string('htmleditor');
diff --git a/version.php b/version.php
index 30ea002f3c3..6b18babaaea 100644
--- a/version.php
+++ b/version.php
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2008081506; // YYYYMMDD = date of the last version bump
+ $version = 2008081600; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20080816)'; // Human-friendly version name