From aa803ceba25ce158ad72c1d4709e20ed301cee6b Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 14 Feb 2012 14:51:46 +0800 Subject: [PATCH] MDL-29254 blog: added check in upgrade for summary and content to be null fields --- lib/db/upgrade.php | 30 ++++++++++++++++++++++++++++++ version.php | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 2c28ba359ef..454adc10435 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -145,6 +145,36 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2012020200.06); } + if ($oldversion < 2012021700.02) { + // Somewhere before 1.9 summary and content column in post table were not null. In 1.9+ + // not null became false. + $columns = $DB->get_columns('post'); + + // Fix discrepancies in summary field after upgrade from 1.9 + if (array_key_exists('summary', $columns) && $columns['summary']->not_null != false) { + $table = new xmldb_table('post'); + $summaryfield = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'big', null, null, null, null, 'subject'); + + if ($dbman->field_exists($table, $summaryfield)) { + $dbman->change_field_notnull($table, $summaryfield); + } + + } + + // Fix discrepancies in content field after upgrade from 1.9 + if (array_key_exists('content', $columns) && $columns['content']->not_null != false) { + $table = new xmldb_table('post'); + $contentfield = new xmldb_field('content', XMLDB_TYPE_TEXT, 'big', null, null, null, null, 'summary'); + + if ($dbman->field_exists($table, $contentfield)) { + $dbman->change_field_notnull($table, $contentfield); + } + + } + + upgrade_main_savepoint(true, 2012021700.02); + } + return true; } diff --git a/version.php b/version.php index 59d1d9b97fc..c863fe07479 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2012021700.00; // YYYYMMDD = weekly release date of this DEV branch +$version = 2012021700.02; // YYYYMMDD = weekly release date of this DEV branch // RR = release increments - 00 in DEV branches // .XX = incremental changes