Skip to content

Commit

Permalink
MDL-29254 blog: added check in upgrade for summary and content to be …
Browse files Browse the repository at this point in the history
…null fields
  • Loading branch information
Rajesh Taneja committed Feb 20, 2012
1 parent e0d5a17 commit 3c5ea52
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions lib/db/upgrade.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6724,6 +6724,36 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2011070103.04); upgrade_main_savepoint(true, 2011070103.04);
} }


if ($oldversion < 2011070104.09) {
// 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, 2011070104.09);
}

return true; return true;
} }


2 changes: 1 addition & 1 deletion version.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();




$version = 2011070104.07; // 20110701 = branching date YYYYMMDD - do not modify! $version = 2011070104.09; // 20110701 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches // RR = release increments - 00 in DEV branches
// .XX = incremental changes // .XX = incremental changes


Expand Down

0 comments on commit 3c5ea52

Please sign in to comment.