From 1be9192173bb70267673b790e1c9386e8789d4d6 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Fri, 24 Dec 2010 11:55:35 +0800 Subject: [PATCH 1/2] mod-wiki MDL-25793 Fixed database discrepancies between a fresh install and an upgraded site within the Wiki module --- mod/wiki/db/upgrade.php | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/mod/wiki/db/upgrade.php b/mod/wiki/db/upgrade.php index b594ca3f29c4a..d439b0b6d099a 100644 --- a/mod/wiki/db/upgrade.php +++ b/mod/wiki/db/upgrade.php @@ -64,8 +64,8 @@ * 1. Use recordset instead of record when migrating historic * 2. Select only usefull data on block 06 * + * @global moodle_database $DB */ - function xmldb_wiki_upgrade($oldversion) { global $CFG, $DB, $OUTPUT; @@ -359,6 +359,37 @@ function xmldb_wiki_upgrade($oldversion) { upgrade_mod_savepoint(true, 2010102800, 'wiki'); } + + if ($oldversion < 2010122300) { + // Fix wiki in the post table after upgrade from 1.9 + $table = new xmldb_table('wiki'); + + // name should default to Wiki + $field = new xmldb_field('name', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL, null, 'Wiki', 'course'); + if ($dbman->field_exists($table, $field)) { + $dbman->change_field_default($table, $field); + } + + // timecreated field is missing after 1.9 upgrade + $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'introformat'); + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // timemodified field is missing after 1.9 upgrade + $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'timecreated'); + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // scaleid is not there any more + $field = new xmldb_field('scaleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null); + if ($dbman->field_exists($table, $field)) { + $dbman->drop_field($table, $field); + } + + upgrade_mod_savepoint(true, 2010122300, 'wiki'); + } return true; } From d481e2a8e34387437064ef4c67516a5871493a30 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Mon, 10 Jan 2011 17:31:40 +0800 Subject: [PATCH 2/2] mod-wiki MDL-25793 Bumped version number and adjusted version number in new upgrade code. --- mod/wiki/db/upgrade.php | 4 ++-- mod/wiki/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/wiki/db/upgrade.php b/mod/wiki/db/upgrade.php index d439b0b6d099a..923352f69ad78 100644 --- a/mod/wiki/db/upgrade.php +++ b/mod/wiki/db/upgrade.php @@ -360,7 +360,7 @@ function xmldb_wiki_upgrade($oldversion) { upgrade_mod_savepoint(true, 2010102800, 'wiki'); } - if ($oldversion < 2010122300) { + if ($oldversion < 2011011000) { // Fix wiki in the post table after upgrade from 1.9 $table = new xmldb_table('wiki'); @@ -388,7 +388,7 @@ function xmldb_wiki_upgrade($oldversion) { $dbman->drop_field($table, $field); } - upgrade_mod_savepoint(true, 2010122300, 'wiki'); + upgrade_mod_savepoint(true, 2011011000, 'wiki'); } return true; diff --git a/mod/wiki/version.php b/mod/wiki/version.php index f9873a33f9d7a..c7f3582c50a2f 100644 --- a/mod/wiki/version.php +++ b/mod/wiki/version.php @@ -33,6 +33,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$module->version = 2010122700; // The current module version (Date: YYYYMMDDXX) +$module->version = 2011011000; // The current module version (Date: YYYYMMDDXX) $module->requires = 2010080300; $module->cron = 0; // Period for cron to check this module (secs)