MDL-36126 backup: changed the message column in the table backup_logs to a text field to prevent DB errors

This commit is contained in:
Mark Nelson 2013-08-22 15:31:03 +08:00
parent d2aa53be1b
commit 6d8627cb6b
4 changed files with 16 additions and 4 deletions

View File

@ -59,7 +59,7 @@ class database_logger extends base_logger {
if ($this->levelcol) {
$columns[$this->levelcol] = $level;
}
$columns[$this->messagecol] = $message; //TODO: should this be cleaned?
$columns[$this->messagecol] = clean_param($message, PARAM_NOTAGS);
return $this->insert_log_record($this->logtable, $columns);
}
@ -69,6 +69,6 @@ class database_logger extends base_logger {
// to preserve DB logs if the whole backup/restore transaction is
// rollback
global $DB;
return $DB->insert_record($this->logtable, $columns, false); // Don't return inserted id
return $DB->insert_record($table, $columns, false); // Don't return inserted id
}
}

View File

@ -2750,7 +2750,7 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="backupid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="backupid the log record belongs to"/>
<FIELD NAME="loglevel" TYPE="int" LENGTH="4" NOTNULL="true" SEQUENCE="false" COMMENT="level of the log (debug...error)"/>
<FIELD NAME="message" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="text logged"/>
<FIELD NAME="message" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="text logged"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="timestamp this log entry was created"/>
</FIELDS>
<KEYS>

View File

@ -2327,5 +2327,17 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013081200.00);
}
if ($oldversion < 2013082300.01) {
// Define the table 'backup_logs' and the field 'message' which we will be changing from a char to a text field.
$table = new xmldb_table('backup_logs');
$field = new xmldb_field('message', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null, 'loglevel');
// Perform the change.
$dbman->change_field_type($table, $field);
// Main savepoint reached.
upgrade_main_savepoint(true, 2013082300.01);
}
return true;
}

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2013082300.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2013082300.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.