From 1045a0074c2518b37ccf1aa4bc5a127960c82c05 Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 12 Jan 2009 16:52:53 +0000 Subject: [PATCH] MDL-17849 sql queries not printed by default during upgrade anymore, there is a new config.php only setting $CFG->upgradeshowsql instead --- admin/index.php | 19 +++---- admin/report/unittest/test_tables.php | 3 -- config-dist.php | 16 ++++-- lib/accesslib.php | 11 +++- lib/adminlib.php | 73 ++++++++++++++------------- lib/blocklib.php | 20 +------- lib/db/install.php | 3 +- lib/db/upgradelib.php | 8 --- lib/ddl/database_manager.php | 30 ----------- lib/ddl/sql_generator.php | 7 --- lib/locallib.php | 7 +-- mod/assignment/db/upgrade.php | 3 -- mod/assignment/lib.php | 3 -- mod/data/db/upgrade.php | 3 -- mod/data/lib.php | 3 -- mod/forum/db/upgrade.php | 5 -- mod/forum/lib.php | 4 -- mod/glossary/db/upgrade.php | 3 -- mod/glossary/lib.php | 3 -- mod/hotpot/lib.php | 3 -- mod/lesson/lib.php | 3 -- mod/quiz/lib.php | 3 -- mod/scorm/db/upgrade.php | 3 -- mod/scorm/lib.php | 3 -- 24 files changed, 70 insertions(+), 169 deletions(-) diff --git a/admin/index.php b/admin/index.php index 95f7c8e1de..d8f1cb6ae9 100644 --- a/admin/index.php +++ b/admin/index.php @@ -142,7 +142,6 @@ /// return to original debugging level $CFG->debug = $origdebug; error_reporting($CFG->debug); - $DB->set_debug(true); if (!$DB->setup_is_unicodedb()) { if (!$DB->change_db_encoding()) { @@ -151,8 +150,10 @@ } } + upgrade_log_start(true); // does not store ugprade runnign flag + print_heading('coresystem'); $DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml"); - upgrade_log_start(); // move here because we want the flag to be stored in config table ;-) + upgrade_log_start(); // we want the flag to be stored in config table ;-) /// set all core default records and default settings require_once("$CFG->libdir/db/install.php"); @@ -173,9 +174,7 @@ // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it) admin_apply_default_settings(NULL, true); notify($strdatabasesuccess, 'notifysuccess'); - - /// do not show certificates in log ;-) - $DB->set_debug(false); + print_upgrade_separator(); } @@ -277,7 +276,6 @@ } else { - $strdatabasesuccess = get_string("databasesuccess"); upgrade_log_start(); /// return to original debugging level @@ -291,15 +289,11 @@ } print_heading($strdatabasechecking); - $DB->set_debug(true); /// Launch the old main upgrade (if exists) $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_capabilities(); // Update core events events_update_definition(); @@ -310,7 +304,8 @@ set_config("version", $version); remove_dir($CFG->dataroot . '/cache', true); // flush cache - notify($strdatabasesuccess, "green"); + notify(get_string("databasesuccess"), "green"); + print_upgrade_separator(); /// Main upgrade not success } else { diff --git a/admin/report/unittest/test_tables.php b/admin/report/unittest/test_tables.php index 45fc4c9c99..ffa358e2b0 100644 --- a/admin/report/unittest/test_tables.php +++ b/admin/report/unittest/test_tables.php @@ -81,9 +81,6 @@ die;die;die; // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it) admin_apply_default_settings(NULL, true); - /// do not show certificates in log ;-) - $DB->set_debug(false); - /// upgrade all plugins types $upgradedplugins = false; diff --git a/config-dist.php b/config-dist.php index 4f80db927a..cfe4c75d2d 100644 --- a/config-dist.php +++ b/config-dist.php @@ -294,16 +294,16 @@ $CFG->admin = 'admin'; // NOTE: course, category, session, user themes still require the // respective settings to be enabled // -// When working with production data on test servers, no emails should ever be send to real users -// $CFG->noemailever = true; -// //========================================================================= // 8. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!! //========================================================================= // +// When working with production data on test servers, no emails should ever be send to real users +// $CFG->noemailever = true; +// // Specify prefix for fake unit test tables. If not specified only tests -// taht do not need fake tables will be executed. +// that do not need fake tables will be executed. // $CFG->unittestprefix = 'tst_'; // // special magic evil developer only wanting to edit the xmldb files manually @@ -312,12 +312,18 @@ $CFG->admin = 'admin'; // $CFG->xmldbdisablecommentchecking = true; // $CFG->xmldbdisablenextprevchecking = true; // -// special magig evil developer only wanting to edit xmldb files manually +// Special magic - evil developer only wanting to edit xmldb files manually // AND allowing the XMLDBEditor to recostruct the prev/next elements every // time one file is loaded and saved (Moodle). // Uncomment this if you're lazy like Petr // $CFG->xmldbreconstructprevnext = true; // +// +// Since 2.0 sql queries are not shown during upgrade by default. +// Please note that this setting may produce very long upgrade page on large sites. +// $CFG->upgradeshowsql = true; + + //========================================================================= // ALL DONE! To continue installation, visit your main page with a browser diff --git a/lib/accesslib.php b/lib/accesslib.php index 5c1dc6483f..a6e26dfd48 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1614,6 +1614,10 @@ function compact_rdefs(&$rdefs) { function load_all_capabilities() { global $USER, $CFG, $DIRTYCONTEXTS; + if (empty($CFG->rolesactive)) { + return; + } + $base = '/'.SYSCONTEXTID; if (isguestuser()) { @@ -4728,7 +4732,7 @@ function get_users_by_capability($context, $capability, $fields='', $sort='', // is the default role interesting? does it have // a relevant rolecap? (we use this a lot later) - if (in_array((int)$CFG->defaultuserroleid, $roleids, true)) { + if (isset($CFG->defaultuserroleid) and in_array((int)$CFG->defaultuserroleid, $roleids, true)) { $defaultroleinteresting = true; } else { $defaultroleinteresting = false; @@ -5993,6 +5997,11 @@ function get_dirty_contexts($time) { */ function mark_context_dirty($path) { global $CFG, $DIRTYCONTEXTS; + + if (empty($CFG->rolesactive)) { + return; + } + // only if it is a non-empty string if (is_string($path) && $path !== '') { set_cache_flag('accesslib/dirtycontexts', $path, 1, time()+$CFG->sessiontimeout); diff --git a/lib/adminlib.php b/lib/adminlib.php index 01d8b30bac..a5a591a930 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -390,9 +390,6 @@ function upgrade_plugins($type, $dir) { $updated_plugins = true; upgrade_log_start(); print_heading($dir.'/'. $plugin->name .' plugin needs upgrading'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(true); - } @set_time_limit(0); // To allow slow databases to complete the long SQL if ($installedversion == 0) { // It's a new install of this plugin @@ -402,9 +399,6 @@ function upgrade_plugins($type, $dir) { $DB->get_manager()->install_from_xmldb_file($fullplug . '/db/install.xml'); //New method } $status = true; - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(false); - } /// Continue with the instalation, roles and other stuff if ($status) { /// OK so far, now update the plugins record @@ -439,17 +433,11 @@ function upgrade_plugins($type, $dir) { $newupgrade_function = 'xmldb_' .$plugin->fullname .'_upgrade'; $newupgrade_status = true; if ($newupgrade && function_exists($newupgrade_function)) { - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(true); - } $newupgrade_status = $newupgrade_function($installedversion); } else if ($newupgrade) { notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' . $fullplug . '/db/upgrade.php'); } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(false); - } /// Now analyze upgrade results if ($newupgrade_status) { // No upgrading failed /// OK so far, now update the plugins record @@ -466,9 +454,7 @@ function upgrade_plugins($type, $dir) { notify('Upgrading '. $plugin->name .' from '. $installedversion .' to '. $plugin->version .' FAILED!'); } } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - echo '
'; - } + print_upgrade_separator(); } else { print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$installedversion, 'newversion'=>$plugin->version)); } @@ -559,17 +545,11 @@ function upgrade_activity_modules() { /// Then, the new function if exists and the old one was ok $newupgrade_status = true; if ($newupgrade && function_exists($newupgrade_function)) { - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(true); - } $newupgrade_status = $newupgrade_function($currmodule->version, $module); } else if ($newupgrade) { notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' . $mod . ': ' . $fullmod . '/db/upgrade.php'); } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(false); - } /// Now analyze upgrade results if ($newupgrade_status) { // No upgrading failed // OK so far, now update the modules record @@ -577,9 +557,7 @@ function upgrade_activity_modules() { $DB->update_record('modules', $module); remove_dir($CFG->dataroot . '/cache', true); // flush cache notify(get_string('modulesuccess', '', $module->name), 'notifysuccess'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) { - echo '
'; - } + print_upgrade_separator(); } else { notify('Upgrading '. $module->name .' from '. $currmodule->version .' to '. $module->version .' FAILED!'); } @@ -604,9 +582,6 @@ function upgrade_activity_modules() { print_heading($module->name); $updated_modules = true; // To avoid unnecessary output from the SQL queries in the CLI version - if (!defined('CLI_UPGRADE')|| !CLI_UPGRADE ) { - $DB->set_debug(true); - } @set_time_limit(0); // To allow slow databases to complete the long SQL /// Both old .sql files and new install.xml are supported @@ -615,9 +590,6 @@ function upgrade_activity_modules() { $DB->get_manager()->install_from_xmldb_file($fullmod . '/db/install.xml'); //New method $status = true; } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(false); - } /// Continue with the installation, roles and other stuff if ($status) { @@ -641,9 +613,7 @@ function upgrade_activity_modules() { } notify(get_string('modulesuccess', '', $module->name), 'notifysuccess'); - if (!defined('CLI_UPGRADE')|| !CLI_UPGRADE ) { - echo '
'; - } + print_upgrade_separator(); } else { print_error('cannotaddmodule', '', '', $module->name); } @@ -852,12 +822,16 @@ function create_admin_user($user_input=NULL) { * Marks start of upgrade, blocks any other access to site. * The upgrade is finished at the end of script or after timeout. */ -function upgrade_log_start() { +function upgrade_log_start($preinstall=false) { global $CFG, $DB; static $started = false; - if ($started) { + if ($preinstall) { + ignore_user_abort(true); + upgrade_setup_debug(true); + + } else if ($started) { upgrade_set_timeout(120); } else { @@ -868,9 +842,11 @@ function upgrade_log_start() { build_navigation(array(array('name' => $strupgrade, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, ' ', ' '); } + //$DB->set_debug(true); // should be configurable soon ignore_user_abort(true); register_shutdown_function('upgrade_finished_handler'); + upgrade_setup_debug(true); set_config('upgraderunning', time()+300); $started = true; } @@ -889,9 +865,11 @@ function upgrade_finished_handler() { * This function may be called repeatedly. */ function upgrade_log_finish($continueurl=null) { - global $CFG; + global $CFG, $DB; + if (!empty($CFG->upgraderunning)) { unset_config('upgraderunning'); + upgrade_setup_debug(false); ignore_user_abort(false); if ($continueurl) { print_continue($continueurl); @@ -901,6 +879,29 @@ function upgrade_log_finish($continueurl=null) { } } +function upgrade_setup_debug($starting) { + global $CFG, $DB; + + static $originaldebug = null; + + if ($starting) { + if ($originaldebug === null) { + $originaldebug = $DB->get_debug(); + } + if (!empty($CFG->upgradeshowsql)) { + $DB->set_debug(true); + } + } else { + $DB->set_debug($originaldebug); + } +} + +function print_upgrade_separator() { + if (!CLI_SCRIPT) { + echo '
'; + } +} + /** * Test if and critical warnings are present * @return bool diff --git a/lib/blocklib.php b/lib/blocklib.php index ec7f57df73..4727e40fc6 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1183,17 +1183,11 @@ function upgrade_blocks_plugins() { /// Then, the new function if exists and the old one was ok $newupgrade_status = true; if ($newupgrade && function_exists($newupgrade_function)) { - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(true); - } $newupgrade_status = $newupgrade_function($currblock->version, $block); } else if ($newupgrade) { notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' . $fullblock . '/db/upgrade.php'); } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(false); - } /// Now analyze upgrade results if ($newupgrade_status) { // No upgrading failed @@ -1221,9 +1215,7 @@ function upgrade_blocks_plugins() { } else { notify('Upgrading block '. $block->name .' from '. $currblock->version .' to '. $block->version .' FAILED!'); } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - echo '
'; - } + print_upgrade_separator(); } else { print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$currblock->version, 'newversion'=>$block->version)); } @@ -1249,9 +1241,6 @@ function upgrade_blocks_plugins() { $updated_blocks = true; upgrade_log_start(); print_heading($block->name); - if (!defined('CLI_UPGRADE')||!CLI_UPGRADE) { - $DB->set_debug(true); - } @set_time_limit(0); // To allow slow databases to complete the long SQL /// Both old .sql files and new install.xml are supported @@ -1259,9 +1248,6 @@ function upgrade_blocks_plugins() { if (file_exists($fullblock . '/db/install.xml')) { $DB->get_manager()->install_from_xmldb_file($fullblock . '/db/install.xml'); //New method } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(false); - } $block->id = $DB->insert_record('block', $block); $blockobj->after_install(); $component = 'block/'.$block->name; @@ -1275,9 +1261,7 @@ function upgrade_blocks_plugins() { message_update_providers($component); notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess'); - if (!defined('CLI_UPGRADE')|| !CLI_UPGRADE) { - echo '
'; - } + print_upgrade_separator(); } $blocktitles[$block->name] = $blocktitle; diff --git a/lib/db/install.php b/lib/db/install.php index f7520596ae..c286782b62 100644 --- a/lib/db/install.php +++ b/lib/db/install.php @@ -45,7 +45,8 @@ function xmldb_main_install($version) { $cat = get_course_category(); - $defaults = array('auth' => 'email', + $defaults = array('rolesactive' => '0', // marks fully set up system + 'auth' => 'email', 'auth_pop3mailbox' => 'INBOX', 'enrol' => 'manual', 'enrol_plugins_enabled' => 'manual', diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index e054542ba2..f2f0d3ee95 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -37,14 +37,12 @@ function upgrade_fix_category_depths() { FROM {course_categories} c, {course_categories} pc WHERE c.parent=pc.id AND c.depth=0 AND pc.depth=?"; if ($rs = $DB->get_recordset_sql($sql, array($parentdepth))) { - $DB->set_debug(false); foreach ($rs as $cat) { $cat->depth = $parentdepth+1; $cat->path = $cat->path.'/'.$cat->id; $DB->update_record('course_categories', $cat); } $rs->close(); - $DB->set_debug(false); } $parentdepth++; if ($parentdepth > 100) { @@ -68,8 +66,6 @@ function upgrade_migrate_files_courses() { $pbar = new progress_bar('migratecoursefiles', 500, true); $rs = $DB->get_recordset('course'); - $olddebug = $DB->get_debug(); - $DB->set_debug(false); // lower debug level, there might be many files $i = 0; foreach ($rs as $course) { $i++; @@ -78,7 +74,6 @@ function upgrade_migrate_files_courses() { upgrade_migrate_files_course($context, '/', true); $pbar->update($i, $count, "Migrated course files - course $i/$count."); } - $DB->set_debug($olddebug); // reset debug level $rs->close(); return true; @@ -179,8 +174,6 @@ function upgrade_migrate_files_blog() { $pbar = new progress_bar('migrateblogfiles', 500, true); - $olddebug = $DB->get_debug(); - $DB->set_debug(false); // lower debug level, there might be many files $i = 0; foreach ($rs as $entry) { $i++; @@ -216,7 +209,6 @@ function upgrade_migrate_files_blog() { $DB->update_record('post', $entry); $pbar->update($i, $count, "Migrated blog attachments - $i/$count."); } - $DB->set_debug($olddebug); // reset debug level $rs->close(); } diff --git a/lib/ddl/database_manager.php b/lib/ddl/database_manager.php index 9612127255..7ac8ba71de 100644 --- a/lib/ddl/database_manager.php +++ b/lib/ddl/database_manager.php @@ -141,10 +141,6 @@ class database_manager { throw new ddl_table_missing_exception($tablename); } - /// Do this function silenty (to avoid output in install/upgrade process) - $olddbdebug = $this->mdb->get_debug(); - $this->mdb->set_debug(false); - if (is_string($field)) { $fieldname = $field; } else { @@ -157,9 +153,6 @@ class database_manager { $exists = array_key_exists($fieldname, $columns); - /// Re-set original debug - $this->mdb->set_debug($olddbdebug); - return $exists; } @@ -180,10 +173,6 @@ class database_manager { throw new ddl_table_missing_exception($tablename); } - /// Do this function silenty (to avoid output in install/upgrade process) - $olddbdebug = $this->mdb->get_debug(); - $this->mdb->set_debug(false); - /// Extract index columns $indcolumns = $xmldb_index->getFields(); @@ -197,13 +186,11 @@ class database_manager { $diferences = array_merge(array_diff($columns, $indcolumns), array_diff($indcolumns, $columns)); /// If no diferences, we have find the index if (empty($diferences)) { - $this->mdb->set_debug($olddbdebug); return $indexname; } } /// Arriving here, index not found - $this->mdb->set_debug($olddbdebug); return false; } @@ -243,10 +230,6 @@ class database_manager { throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName()); } - /// Do this function silenty (to avoid output in install/upgrade process) - $olddbdebug = $this->mdb->get_debug(); - $this->mdb->set_debug(false); - /// Get list of check_constraints in table/field $checks = false; if ($objchecks = $this->generator->getCheckConstraintsFromDB($xmldb_table, $xmldb_field)) { @@ -258,7 +241,6 @@ class database_manager { } /// Arriving here, check not found - $this->mdb->set_debug($olddbdebug); return $checks; } @@ -336,13 +318,8 @@ class database_manager { $sequencename = false; - /// Do this function silenty (to avoid output in install/upgrade process) - $olddbdebug = $this->mdb->get_debug(); - $this->mdb->set_debug(false); - $sequencename = $this->generator->getSequenceFromDB($xmldb_table); - $this->mdb->set_debug($olddbdebug); return $sequencename; } @@ -441,16 +418,9 @@ class database_manager { */ public function install_from_xmldb_structure($xmldb_structure) { - /// Do this function silenty (to avoid output in install/upgrade process) - $olddbdebug = $this->mdb->get_debug(); - $this->mdb->set_debug(false); - if (!$sqlarr = $this->generator->getCreateStructureSQL($xmldb_structure)) { return; // nothing to do } - - $this->mdb->set_debug($olddbdebug); - $this->execute_sql_arr($sqlarr); } diff --git a/lib/ddl/sql_generator.php b/lib/ddl/sql_generator.php index 44f977ce29..bdea4d9efc 100644 --- a/lib/ddl/sql_generator.php +++ b/lib/ddl/sql_generator.php @@ -166,10 +166,6 @@ abstract class sql_generator { * @return boolean true/false */ public function table_exists($table, $temptable=false) { - /// Do this function silenty (to avoid output in install/upgrade process) - $olddbdebug = $this->mdb->get_debug(); - $this->mdb->set_debug(false); - if (is_string($table)) { $tablename = $table; } else { @@ -181,9 +177,6 @@ abstract class sql_generator { $tables = $this->mdb->get_tables(); $exists = in_array($tablename, $tables); - /// Re-set original debug - $this->mdb->set_debug($olddbdebug); - return $exists; } diff --git a/lib/locallib.php b/lib/locallib.php index 375c9977f3..42df368f0a 100644 --- a/lib/locallib.php +++ b/lib/locallib.php @@ -134,16 +134,11 @@ function upgrade_local_db() { upgrade_log_start(); require_once ($CFG->dirroot .'/local/db/upgrade.php'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(true); - } xmldb_local_upgrade($CFG->local_version); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $DB->set_debug(false); - } set_config('local_version', $local_version); notify(get_string('databasesuccess'), 'notifysuccess'); notify(get_string('databaseupgradelocal', '', $local_version), 'notifysuccess'); + print_upgrade_separator(); return true; diff --git a/mod/assignment/db/upgrade.php b/mod/assignment/db/upgrade.php index 167ba81b57..81fedf5f4a 100644 --- a/mod/assignment/db/upgrade.php +++ b/mod/assignment/db/upgrade.php @@ -54,8 +54,6 @@ function xmldb_assignment_upgrade($oldversion) { $pbar = new progress_bar('migrateassignmentfiles', 500, true); - $olddebug = $DB->get_debug(); - $DB->set_debug(false); // lower debug level, there might be many files $i = 0; foreach ($rs as $submission) { $i++; @@ -127,7 +125,6 @@ function xmldb_assignment_upgrade($oldversion) { @rmdir("$CFG->dataroot/$submission->course/$CFG->moddata/assignment/$submission->assignment"); @rmdir("$CFG->dataroot/$submission->course/$CFG->moddata/assignment"); } - $DB->set_debug($olddebug); // reset debug level $rs->close(); } diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index c8d65126d9..8f08fc5f8b 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -2254,8 +2254,6 @@ function assignment_upgrade_grades() { 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) { @@ -2264,7 +2262,6 @@ function assignment_upgrade_grades() { 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/data/db/upgrade.php b/mod/data/db/upgrade.php index 416a2ede75..eccbde4de7 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -94,8 +94,6 @@ function xmldb_data_upgrade($oldversion) { $pbar = new progress_bar('migratedatafiles', 500, true); - $olddebug = $DB->get_debug(); - $DB->set_debug(false); // lower debug level, there might be very many files $i = 0; foreach ($rs as $content) { $i++; @@ -143,7 +141,6 @@ function xmldb_data_upgrade($oldversion) { @rmdir("$CFG->dataroot/$content->course/$CFG->moddata/data"); @rmdir("$CFG->dataroot/$content->course/$CFG->moddata"); } - $DB->set_debug($olddebug); // reset debug level $rs->close(); } upgrade_mod_savepoint($result, 2008091400, 'data'); diff --git a/mod/data/lib.php b/mod/data/lib.php index 943902111e..0bfbfb40c4 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -848,8 +848,6 @@ function data_upgrade_grades() { 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) { @@ -858,7 +856,6 @@ function data_upgrade_grades() { 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/forum/db/upgrade.php b/mod/forum/db/upgrade.php index d5f13c1dd9..07cb48cf24 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -53,12 +53,10 @@ function xmldb_forum_upgrade($oldversion) { WHERE ra.id IS NULL"; if ($rs = $DB->get_recordset_sql($sql, $params)) { - $DB->set_debug(false); foreach ($rs as $remove) { $DB->delete_records('forum_subscriptions', array('userid'=>$remove->userid, 'forum'=>$remove->forumid)); echo '.'; } - $DB->set_debug(true); $rs->close(); } @@ -118,8 +116,6 @@ function xmldb_forum_upgrade($oldversion) { $pbar = new progress_bar('migrateforumfiles', 500, true); - $olddebug = $DB->get_debug(); - $DB->set_debug(false); // lower debug level, there might be very many files $i = 0; foreach ($rs as $post) { $i++; @@ -159,7 +155,6 @@ function xmldb_forum_upgrade($oldversion) { @rmdir("$CFG->dataroot/$post->course/$CFG->moddata/forum/$post->forum"); @rmdir("$CFG->dataroot/$post->course/$CFG->moddata/forum"); } - $DB->set_debug($olddebug); // reset debug level $rs->close(); } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 6376f7052b..f3eb8e49fa 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1485,9 +1485,6 @@ function forum_upgrade_grades() { 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) { @@ -1496,7 +1493,6 @@ function forum_upgrade_grades() { 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/glossary/db/upgrade.php b/mod/glossary/db/upgrade.php index 790c0aa090..9f6ae723d4 100644 --- a/mod/glossary/db/upgrade.php +++ b/mod/glossary/db/upgrade.php @@ -50,8 +50,6 @@ function xmldb_glossary_upgrade($oldversion) { $pbar = new progress_bar('migrateglossaryfiles', 500, true); - $olddebug = $DB->get_debug(); - $DB->set_debug(false); // lower debug level, there might be very many files $i = 0; foreach ($rs as $entry) { $i++; @@ -96,7 +94,6 @@ function xmldb_glossary_upgrade($oldversion) { @rmdir("$CFG->dataroot/$entry->course/$CFG->moddata/glossary/$entry->glossaryid"); @rmdir("$CFG->dataroot/$entry->course/$CFG->moddata/glossary"); } - $DB->set_debug($olddebug); // reset debug level $rs->close(); } diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 419c85ba66..85024cf4a9 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -386,8 +386,6 @@ function glossary_upgrade_grades() { 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) { @@ -396,7 +394,6 @@ function glossary_upgrade_grades() { 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/hotpot/lib.php b/mod/hotpot/lib.php index 89d95702fe..cb6541bb13 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -1291,8 +1291,6 @@ function hotpot_upgrade_grades() { 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) { @@ -1301,7 +1299,6 @@ function hotpot_upgrade_grades() { hotpot_update_grades($hotpot, 0, false); $pbar->update($i, $count, "Updating Hotpot grades ($i/$count)."); } - $DB->set_debug($prevdebug); $rs->close(); } } diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index 693d59cc6b..176c6e00fa 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -424,8 +424,6 @@ function lesson_upgrade_grades() { 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) { @@ -434,7 +432,6 @@ function lesson_upgrade_grades() { 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/lib.php b/mod/quiz/lib.php index 89dc61f9ff..b5f57eeebd 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -390,8 +390,6 @@ function quiz_upgrade_grades() { 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) { @@ -400,7 +398,6 @@ function quiz_upgrade_grades() { 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/scorm/db/upgrade.php b/mod/scorm/db/upgrade.php index 03705f2c0c..aa6788f899 100644 --- a/mod/scorm/db/upgrade.php +++ b/mod/scorm/db/upgrade.php @@ -186,8 +186,6 @@ function xmldb_scorm_upgrade($oldversion) { $pbar = new progress_bar('migratescormfiles', 500, true); - $olddebug = $DB->get_debug(); - $DB->set_debug(false); // lower debug level, there might be many files $i = 0; foreach ($rs as $scorm) { $i++; @@ -226,7 +224,6 @@ function xmldb_scorm_upgrade($oldversion) { @rmdir("$CFG->dataroot/$scorm->course/$CFG->moddata/scorm/"); @rmdir("$CFG->dataroot/$scorm->course/$CFG->moddata/"); } - $DB->set_debug($olddebug); // reset debug level $rs->close(); } diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 8247b1bd3b..3c0bd534b0 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -512,8 +512,6 @@ function scorm_upgrade_grades() { 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) { @@ -522,7 +520,6 @@ function scorm_upgrade_grades() { scorm_update_grades($scorm, 0, false); $pbar->update($i, $count, "Updating Scorm grades ($i/$count)."); } - $DB->set_debug($prevdebug); $rs->close(); } } -- 2.39.5