Commit 795a08ad authored by skodak's avatar skodak
Browse files

MDL-17458 upgrade logging implemented + a lot more refactoring + exceptions...

MDL-17458 upgrade logging implemented + a lot more refactoring + exceptions implemented in install/upgrade code + lang pack cleanup + some more improvements
parent 9c421fab
......@@ -1119,8 +1119,6 @@ if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) {
// create default course category
$cat = get_course_category();
} else {
print_error('cannotsetupsite', 'error');
}
}
......
......@@ -130,7 +130,6 @@
}
$strdatabasesetup = get_string("databasesetup");
$strdatabasesuccess = get_string("databasesuccess");
$navigation = build_navigation(array(array('name'=>$strdatabasesetup, 'link'=>null, 'type'=>'misc')));
print_header($strdatabasesetup, $strdatabasesetup, $navigation,
......@@ -147,31 +146,31 @@
}
}
upgrade_started(true); // does not store ugprade runnign flag
print_heading('coresystem');
$DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml");
upgrade_started(); // we want the flag to be stored in config table ;-)
try {
print_upgrade_part_start('moodle', true); // does not store upgrade running flag
/// set all core default records and default settings
require_once("$CFG->libdir/db/install.php");
xmldb_main_install();
$DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml");
upgrade_started(); // we want the flag to be stored in config table ;-)
/// store version
upgrade_main_savepoint(true, $version, false);
/// set all core default records and default settings
require_once("$CFG->libdir/db/install.php");
xmldb_main_install();
/// Continue with the instalation
/// store version
upgrade_main_savepoint(true, $version, false);
// Install core event handlers
events_update_definition('moodle');
/// Continue with the instalation
events_update_definition('moodle');
message_update_providers('moodle');
message_update_providers('message');
// Install core message providers
message_update_providers('moodle');
message_update_providers('message');
/// Write default settings unconditionlly
admin_apply_default_settings(NULL, true);
// Write default settings unconditionally
admin_apply_default_settings(NULL, true);
notify($strdatabasesuccess, 'notifysuccess');
print_upgrade_separator();
print_upgrade_part_end(null, true);
} catch (exception $ex) {
upgrade_handle_exception($ex);
}
}
......@@ -197,16 +196,9 @@
$CFG->debug = DEBUG_MINIMAL;
error_reporting($CFG->debug);
// logo ut in case we are upgrading from pre 1.9 version in order to prevent
// weird session/role problems caused by incorrect data in USER and SESSION
if ($CFG->version < 2007101500) {
require_logout();
}
if (empty($confirmupgrade)) {
$navigation = build_navigation(array(array('name'=>$strdatabasechecking, 'link'=>null, 'type'=>'misc')));
print_header($strdatabasechecking, $stradministration, $navigation,
"", "", false, "&nbsp;", "&nbsp;");
print_header($strdatabasechecking, $stradministration, $navigation, "", "", false, "&nbsp;", "&nbsp;");
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=1', 'index.php');
print_footer('none');
......@@ -260,42 +252,36 @@
die();
} else {
/// return to original debugging level
$CFG->debug = $origdebug;
error_reporting($CFG->debug);
upgrade_started();
/// Upgrade current language pack if we can
if (empty($CFG->skiplangupgrade)) {
upgrade_language_pack();
}
print_heading($strdatabasechecking);
/// Launch the old main upgrade (if exists)
$status = xmldb_main_upgrade($CFG->version);
/// If successful, continue upgrading roles and setting everything properly
if ($status) {
update_capabilities('moodle');
/// Launch main upgrade
try {
print_upgrade_part_start('moodle', false);
// Update core events
events_update_definition('moodle');
$result = xmldb_main_upgrade($CFG->version);
if ($version > $CFG->version) {
// store version if not already there
upgrade_main_savepoint($result, $version, false);
}
// Update core message providers
// perform all other component upgrade routines
update_capabilities('moodle');
events_update_definition('moodle');
message_update_providers('moodle');
message_update_providers('message');
set_config("version", $version);
remove_dir($CFG->dataroot . '/cache', true); // flush cache
notify(get_string("databasesuccess"), "green");
print_upgrade_separator();
/// Main upgrade not success
} else {
notify('Main Upgrade failed! See lib/db/upgrade.php');
print_continue('index.php?confirmupgrade=1&amp;confirmrelease=1&amp;confirmplugincheck=1');
print_footer('none');
die;
print_upgrade_part_end('moodle', false);
} catch (Exception $ex) {
upgrade_handle_exception($ex);
}
}
} else if ($version < $CFG->version) {
......@@ -312,19 +298,31 @@
/// upgrade all plugins types
$plugintypes = get_plugin_types();
foreach ($plugintypes as $type=>$location) {
upgrade_plugins($type, $location);
try {
foreach ($plugintypes as $type=>$location) {
upgrade_plugins($type, $location, 'print_upgrade_part_start', 'print_upgrade_part_end');
}
} catch (Exception $ex) {
upgrade_handle_exception($ex);
}
/// Check for changes to RPC functions
if ($CFG->mnet_dispatcher_mode != 'off') {
require_once("$CFG->dirroot/$CFG->admin/mnet/adminlib.php");
upgrade_RPC_functions(); // Return here afterwards
try {
require_once("$CFG->dirroot/$CFG->admin/mnet/adminlib.php");
upgrade_RPC_functions(); // Return here afterwards
} catch (Exception $ex) {
upgrade_handle_exception($ex);
}
}
/// Check for local database customisations
require_once("$CFG->dirroot/lib/locallib.php");
upgrade_local_db(); // Return here afterwards
try {
require_once("$CFG->dirroot/lib/locallib.php");
upgrade_local_db('print_upgrade_part_start', 'print_upgrade_part_end');
} catch (Exception $ex) {
upgrade_handle_exception($ex);
}
/// indicate that this site is fully configured except the admin password
if (empty($CFG->rolesactive)) {
......
......@@ -103,14 +103,10 @@
$aclrecord->mnet_host_id = $user->mnethostid;
$aclrecord->username = $user->username;
$aclrecord->accessctrl = $accessctrl;
if (!$DB->insert_record('mnet_sso_access_control', $aclrecord)) {
print_error('dbnotinsert', 'debug', '', 'the MNET access control list');
}
$DB->insert_record('mnet_sso_access_control', $aclrecord);
} else {
$aclrecord->accessctrl = $accessctrl;
if (!$DB->update_record('mnet_sso_access_control', $aclrecord)) {
print_error('dbnotupdate', 'debug', '', 'the MNET access control list');
}
$DB->update_record('mnet_sso_access_control', $aclrecord);
}
$mnethosts = $DB->get_records('mnet_host', null, 'id', 'id,wwwroot,name');
notify("MNET access control list updated: username '$user->username' from host '"
......
......@@ -107,13 +107,6 @@ class block_base {
$this->block_base();
}
/**
* Function that can be overridden to do extra setup after
* the database install. (Called once per block, not per instance!)
*/
function after_install() {
}
/**
* Function that can be overridden to do extra cleanup before
* the database tables are deleted. (Called once per block, not per instance!)
......
This files describes API changes in /blocks/* - activity modules,
information provided here is intended especially for developers.
=== 2.0 ===
required changes in code:
* use new DML syntax everywhere
* use new DDL syntax in db/upgrade.php
* replace defaults.php by settings.php and db/install.php
* replace STATEMENTS section in db/install.xml by db/install.php
* move post instalation code from install() method into db/install.php
* completely rewrite file handling
* rewrite backup/restore
optional - no changes needed in older code:
*
TODO: add links to docs
\ No newline at end of file
......@@ -795,6 +795,7 @@ $string['uploadpicture_userskipped'] = 'Skipping user $a (already has a picture)
$string['uploadpicture_userupdated'] = 'Picture updated for user $a.';
$string['uploadpicture_cannotsave'] = 'Cannot save picture for user $a. Check original picture file.';
$string['updatetimezones'] = 'Update timezones';
$string['upgradeerror'] = 'Unknown error upgrading $a->plugin to version $a->version, can not continue.';
$string['upgradeforumread'] = 'A new feature has been added in Moodle 1.5 to track read/unread forum posts.<br />To use this functionality you need to <a href=\"$a\">update your tables</a>.';
$string['upgradeforumreadinfo'] = 'A new feature has been added in Moodle 1.5 to track read/unread forum posts. To use this functionality you need to update your tables with all the tracking information for existing posts. Depending on the size of your site this can take a long time (hours) and can be quite taxing on the database, so it\'s best to do it during a quiet period. However, your site will continue functioning during this upgrade and users won\'t be affected. Once you start this process you should let it finish (keep your browser window open). However, if you stop the process by closing the window: don\'t worry, you can start over.<br /><br />Do you want to start the upgrading process now?';
$string['upgradelogs'] = 'For full functionality, your old logs need to be upgraded. <a href=\"$a\">More information</a>';
......
......@@ -5,23 +5,12 @@
$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->oldversion to $a->newversion.';
$string['cannotdowngrade'] = 'Cannot downgrade $a->plugin 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!!';
$string['cannotsetupsite'] = 'Serious Error! Could not set up the site!';
$string['cannotsetuptable'] = '$a tables could NOT be set up successfully!';
$string['cannotfindadmin'] = 'Could not find an admin user!';
$string['cannotupgradedbcustom'] = 'Upgrade of local database customisations failed! (Could not update version in config table)';
$string['codingerror'] = 'Coding error detected, it must be fixed by a programmer: $a';
$string['configmoodle'] = 'Moodle has not been configured yet. You need to edit config.php first.';
$string['dbnotinsert'] = 'Database error - Cannot insert ($a)';
$string['dbnotupdate'] = 'Database error - Cannot update ($a)';
$string['dbnotsupport'] = 'Error: Your database ($a) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory.';
$string['dbnotsetup'] = 'Error: Main databases NOT set up successfully';
$string['doesnotworkwitholdversion'] = 'This script does not work with this old version of Moodle';
$string['erroroccur'] = 'An error has occurred during this process';
$string['fixsetting'] = 'Please fix your settings in config.php: <p>You have:</p> <p>\$CFG->dirroot = \"$a->current\";</p> <p>but it should be:</p> <p>\$CFG->dirroot = \"$a->found\"</p>';
$string['invalideventdata'] = 'Incorrect eventadata submitted: $a';
......@@ -32,8 +21,6 @@ $string['morethanonerecordinfetch'] = 'Found more than one record in fetch() !';
$string['noadminrole'] = 'No admin role could be found';
$string['noactivityname'] = 'Page object derived from page_generic_activity but did not define $this->activityname';
$string['noblocks'] = 'No blocks installed!';
$string['noblockbase'] = 'Class block_base is not defined or file not found for /blocks/moodleblock.class.php';
$string['nocaps'] = 'Error: no capabilitites defined!';
$string['nocate'] = 'No categories!';
$string['notables'] = 'No Tables!';
$string['nopageclass'] = 'Imported $a but found no page classes';
......@@ -45,7 +32,6 @@ $string['phpvaron'] = 'The PHP server variable \'$a->name\' is not turned On - $
$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 file is missing, not readable or broken.';
$string['xmlizeunavailable'] = 'xmlize functions are not available';
......
......@@ -127,12 +127,10 @@ $string['cannotsetupblock'] = 'Blocks tables could NOT be set up successfully!';
$string['cannotsetupcategory'] = 'Serious error! Could not set up a default course category!';
$string['cannotsetupcapforplugin'] = 'Could not set up the capabilities for $a';
$string['cannotsetupcapformod'] = 'Could not set up the capabilities for $a';
$string['cannotsetupsite'] = 'Serious error! Could not set up the site!';
$string['cannotshowhidecoursesincategory'] = 'Cannot show/hide the courses in category $a.';
$string['cannotunzipfile'] = 'Cannot unzip file';
$string['cannotupgradeblock'] = 'Upgrade of blocks system failed! (Could not update version in config table.)';
$string['cannotupgradecaps'] = 'Had difficulties upgrading the core capabilities for the Roles system';
$string['cannotupdateblock'] = 'Could not update block $a record in block table!';
$string['cannotupdatecategory'] = 'Could not update the category ($a)';
$string['cannotupdatecoursemodule'] = 'Could not update the course module';
$string['cannotupdatecomment'] = 'Could not update this comment';
......@@ -202,6 +200,7 @@ $string['ddlxmlfileerror'] = 'XML database file errors found';
$string['dmlreadexception'] = 'Error reading from database';
$string['dmlwriteexception'] = 'Error writing to database';
$string['destinationcmnotexit'] = 'The destination course module does not exist';
$string['detectedbrokenplugin'] = 'Plugin \"$a\" is defective, can not continue, sorry.';
$string['downloadedfilecheckfailed'] = 'Downloaded file check failed';
$string['duplicateusername'] = 'Duplicate username - skipping record';
$string['duplicateparaminsql'] = 'ERROR: duplicate parameter name in query';
......@@ -331,7 +330,6 @@ $string['moduledoesnotexist'] = 'This module does not exist';
$string['moduleinstancedoesnotexist'] = 'The instance of this module does not exist';
$string['moduledisable'] = 'This module ($a) has been disabled for this particular course';
$string['modulemissingcode'] = 'Module $a is missing the code needed to perform this function';
$string['modulerequirementsnotmet'] = 'Module \"$a->modulename\" ($a->moduleversion) could not be installed. It requires a newer version of Moodle (currently you are using $a->currentmoodle, you need $a->requiremoodle).';
$string['mustbeteacher'] = 'You must be a teacher to look at this page';
$string['multiplerestorenotallow'] = 'Multiple restore execution not allowed!';
$string['mustbeloggedin'] = 'You must be logged in to do this';
......@@ -364,7 +362,6 @@ $string['nopermissiontolock'] = 'No permission to lock!';
$string['nopermissiontomkdir'] = 'Cannot create folder. The site administrator needs to fix the file permissions';
$string['nopermissiontoshow'] = 'No permission to see this!';
$string['nopermissiontounlock'] = 'No permission to unlock!';
$string['nopermissiontoupdateblock'] = 'No permission to update $a!';
$string['nopermissiontoviewpage'] = 'You are not allowed to look at this page';
$string['nopermissiontoviewletergrade'] = 'Missing permission to view letter grades';
$string['nopermissiontomanagegroup'] = 'You do not have the required permissions to manage groups';
......@@ -472,8 +469,6 @@ $string['usernotupdatederror'] = 'User not updated - error';
$string['usernotupdatednotexists'] = 'User not updated - does not exist';
$string['userselectortoomany'] = 'user_selector got more than one selected user, even though multiselect is false.';
$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';
......
......@@ -3099,9 +3099,7 @@ function get_cached_capabilities($component='moodle') {
*/
function get_default_capabilities($legacyrole) {
global $DB;
if (!$allcaps = $DB->get_records('capabilities')) {
print_error('nocaps', 'debug');
}
$allcaps = $DB->get_records('capabilities');
$alldefs = array();
$defaults = array();
$components = array();
......
......@@ -95,7 +95,7 @@ function get_plugin_types() {
return array('mod' => 'mod',
'qtype' => 'question/type',
'blocks' => 'blocks',
'block' => 'blocks',
'auth' => 'auth',
'enrol' => 'enrol',
'format' => 'course/format',
......@@ -105,11 +105,12 @@ function get_plugin_types() {
'message' => 'message/output',
'coursereport' => 'course/report',
'report' => $CFG->admin.'/report',
'quizreport' => 'mod/quiz/report',
'portfolio' => 'portfolio/type',
'trackerexport' => 'tracker/export',
'trackerimport' => 'tracker/import',
'trackerreport' => 'tracker/report',
// following types a very ugly hacks - we should not make exceptions like this - all plugins should be equal;
// these plugins may cause problems such as when wanting to uninstall them
'quizreport' => 'mod/quiz/report',
'assignment_type' => 'mod/assignment/type',
);
}
......
......@@ -18,70 +18,6 @@ define('BLOCKS_PINNED_BOTH',2);
require_once($CFG->libdir.'/pagelib.php');
require_once($CFG->dirroot.'/course/lib.php'); // needed to solve all those: Call to undefined function: print_recent_activity() when adding Recent Activity
// Returns false if this block is incompatible with the current version of Moodle.
function block_is_compatible($blockname) {
global $CFG;
$file = @file($CFG->dirroot.'/blocks/'.$blockname.'/block_'.$blockname.'.php'); // ignore errors when file does not exist
if(empty($file)) {
return NULL;
}
foreach($file as $line) {
// If you find MoodleBlock (appearing in the class declaration) it's not compatible
if(strpos($line, 'MoodleBlock')) {
return false;
}
// But if we find a { it means the class declaration is over, so it's compatible
else if(strpos($line, '{')) {
return true;
}
}
return NULL;
}
// Returns the case-sensitive name of the class' constructor function. This includes both
// PHP5- and PHP4-style constructors. If no appropriate constructor can be found, returns NULL.
// If there is no such class, returns boolean false.
function get_class_constructor($classname) {
// Caching
static $constructors = array();
if(!class_exists($classname)) {
return false;
}
// Tests indicate this doesn't hurt even in PHP5.
$classname = strtolower($classname);
// Return cached value, if exists
if(isset($constructors[$classname])) {
return $constructors[$classname];
}
// Get a list of methods. After examining several different ways of
// doing the check, (is_callable, method_exists, function_exists etc)
// it seems that this is the most reliable one.
$methods = get_class_methods($classname);
// PHP5 constructor?
if(phpversion() >= '5') {
if(in_array('__construct', $methods)) {
return $constructors[$classname] = '__construct';
}
}
// If we have PHP5 but no magic constructor, we have to lowercase the methods
$methods = array_map('strtolower', $methods);
if(in_array($classname, $methods)) {
return $constructors[$classname] = $classname;
}
return $constructors[$classname] = NULL;
}
//This function retrieves a method-defined property of a class WITHOUT instantiating an object
function block_method_result($blockname, $method, $param = NULL) {
if(!block_load_class($blockname)) {
......@@ -1069,227 +1005,4 @@ function blocks_repopulate_page($page) {
return true;
}
//This function finds all available blocks and install them
//into blocks table or do all the upgrade process if newer
function upgrade_blocks_plugins() {
global $CFG, $interactive, $DB, $SITE;
require_once($CFG->dirroot .'/blocks/moodleblock.class.php');
$updated_blocks = false;
$blocktitles = array();
$invalidblocks = array();
$validblocks = array();
$notices = array();
//Count the number of blocks in db
$blockcount = $DB->count_records('block');
//If there isn't records. This is the first install, so I remember it
$first_install = ($blockcount == 0);
if (!$blocks = get_list_of_plugins('blocks') ) {
print_error('noblocks', 'debug');
}
if (!class_exists('block_base')) {
print_error('noblockbase');
}
foreach ($blocks as $blockname) {
if ($blockname == 'NEWBLOCK') { // Someone has unzipped the template, ignore it
continue;
}
if(!block_is_compatible($blockname)) {
// This is an old-style block
//$notices[] = 'Block '. $blockname .' is not compatible with the current version of Mooodle and needs to be updated by a programmer.';
$invalidblocks[] = $blockname;
continue;
}
$fullblock = $CFG->dirroot .'/blocks/'. $blockname;
if ( is_readable($fullblock.'/block_'.$blockname.'.php')) {
include_once($fullblock.'/block_'.$blockname.'.php');
} else {
$notices[] = 'Block '. $blockname .': '. $fullblock .'/block_'. $blockname .'.php was not readable';
continue;
}
$newupgrade = false;
if ( @is_dir($fullblock .'/db/')) {
if ( @is_readable($fullblock .'/db/upgrade.php')) {
include_once($fullblock .'/db/upgrade.php'); // defines new upgrading function
$newupgrade = true;
}
}
$classname = 'block_'.$blockname;
if(!class_exists($classname)) {
$notices[] = 'Block '. $blockname .': '. $classname .' not implemented';
continue;
}
// Here is the place to see if the block implements a constructor (old style),
// an init() function (new style) or nothing at all (error time).
$constructor = get_class_constructor($classname);
if(empty($constructor)) {
// No constructor
$notices[] = 'Block '. $blockname .': class does not have a constructor';
$invalidblocks[] = $blockname;
continue;
}
$block = new stdClass; // This may be used to update the db below
$blockobj = new $classname; // This is what we 'll be testing
// Inherits from block_base?
if(!is_subclass_of($blockobj, 'block_base')) {
$notices[] = 'Block '. $blockname .': class does not inherit from block_base';
continue;
}
// OK, it's as we all hoped. For further tests, the object will do them itself.
if(!$blockobj->_self_test()) {
$notices[] = 'Block '. $blockname .': self test failed';
continue;
}
$block->version = $blockobj->get_version();
if (!isset($block->version)) {
$notices[] = 'Block '. $blockname .': has no version support. It must be updated by a programmer.';
continue;
}
$block->name = $blockname; // The name MUST match the directory
$blocktitle = $blockobj->get_title();
if ($currblock = $DB->get_record('block', array('name'=>$block->name))) {
if ($currblock->version == $block->version) {
// do nothing
} else if ($currblock->version < $block->version) {
$updated_blocks = true;
upgrade_started();
print_heading('New version of '.$blocktitle.' ('.$block->name.') exists');
@set_time_limit(0); // To allow slow databases to complete the long SQL
/// Run de old and new upgrade functions for the module
$newupgrade_function = 'xmldb_block_' . $block->name .'_upgrade';
/// Then, the new function if exists and the old one was ok
$newupgrade_status = true;
if ($newupgrade && function_exists($newupgrade_function)) {
$newupgrade_status = $newupgrade_function($currblock->version, $block);
} else if ($newupgrade) {
notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' .
$fullblock . '/db/upgrade.php');
}
/// Now analyze upgrade results
if ($newupgrade_status) { // No upgrading failed
// Set the block cron on upgrade
$block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
// OK so far, now update the block record
$block->id = $currblock->id;
if (!$DB->update_record('block', $block)) {
print_error('cannotupdateblock', '', '', $block->name);
}
$component = 'block/'.$block->name;
if (!update_capabilities($component)) {
print_error('nopermissiontoupdateblock', '', '', $block->name);
}
// Update events
events_update_definition($component);
// Update message providers
require_once($CFG->libdir .'/messagelib.php'); // Messagelib functions
message_update_providers($component);
notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess');
} else {
notify('Upgrading block '. $block->name .' from '. $currblock->version .' to '. $block->version .' FAILED!');
}
print_upgrade_separator();
} else {
print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$currblock->version, 'newversion'=>$block->version));
}
} else { // block not installed yet, so install it
// If it allows multiples, start with it enabled
if ($blockobj->instance_allow_multiple()) {
$block->multiple = 1;
}
// Set the block cron on install
$block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
// [pj] Normally this would be inline in the if, but we need to
// check for NULL (necessary for 4.0.5 <= PHP < 4.2.0)
$conflictblock = array_search($blocktitle, $blocktitles);
if ($conflictblock !== false && $conflictblock !== NULL) {
// Duplicate block titles are not allowed, they confuse people
// AND PHP's associative arrays ;)
print_error('blocknameconflict', '', '', (object)array('name'=>$block->name, 'conflict'=>$conflictblock));
}
$updated_blocks = true;
upgrade_started();
print_heading($block->name);
@set_time_limit(0); // To allow slow databases to complete the long SQL
/// Both old .sql files and new install.xml are supported
/// but we priorize install.xml (XMLDB) if present