diff --git a/mod/data/db/install.xml b/mod/data/db/install.xml index e3b260391ba..a9bfdd1ebc9 100644 --- a/mod/data/db/install.xml +++ b/mod/data/db/install.xml @@ -1,5 +1,5 @@ - @@ -35,7 +35,7 @@ - + diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index 68db1f71e97..f8a3c094c63 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -132,6 +132,20 @@ function xmldb_data_upgrade($oldversion=0) { } } + if ($result && $oldversion < 2007101515) { + // Upgrade all the data->notification currently being + // NULL to 0 + $sql = "UPDATE {$CFG->prefix}data SET notification=0 WHERE notification IS NULL"; + $result = execute_sql($sql); + $table = new XMLDBTable('data'); + $field = new XMLDBField('notification'); + // First step, Set NOT NULL + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'editany'); + $result = $result && change_field_notnull($table, $field); + // Second step, Set default to 0 + $result = $result && change_field_default($table, $field); + } + return $result; } diff --git a/mod/data/restorelib.php b/mod/data/restorelib.php index 984a5b894c7..b5d0a72c373 100644 --- a/mod/data/restorelib.php +++ b/mod/data/restorelib.php @@ -97,6 +97,12 @@ function data_restore_mods($mod,$restore) { $database->defaultsortdir = backup_todb($info['MOD']['#']['DEFAULTSORTDIR']['0']['#']); $database->editany = backup_todb($info['MOD']['#']['EDITANY']['0']['#']); $database->notification = backup_todb($info['MOD']['#']['NOTIFICATION']['0']['#']); + + //fix related to MDL-24470: if someone restore a backup previous to this fix it would fail + //if notification = NULL as the column can not be NULL anymore + if (empty($database->notification)) { + $database->notification = 0; + } // We have to recode the scale field if it's <0 (positive is a grade, not a scale) if ($database->scale < 0) { diff --git a/mod/data/version.php b/mod/data/version.php index 1eedf9b8dbb..4cdf9747287 100644 --- a/mod/data/version.php +++ b/mod/data/version.php @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2007101514; +$module->version = 2007101515; $module->requires = 2007101509; // Requires this Moodle version $module->cron = 60;