diff --git a/backup/util/loggers/database_logger.class.php b/backup/util/loggers/database_logger.class.php index dcfddec7e19..1897af5b6a7 100644 --- a/backup/util/loggers/database_logger.class.php +++ b/backup/util/loggers/database_logger.class.php @@ -59,7 +59,13 @@ class database_logger extends base_logger { if ($this->levelcol) { $columns[$this->levelcol] = $level; } - $columns[$this->messagecol] = $message; //TODO: should this be cleaned? + $message = clean_param($message, PARAM_NOTAGS); + // Check if the message exceeds the 255 character limit in the database, + // if it does, shorten it so that it can be inserted successfully. + if (textlib::strlen($message) > 255) { + $message = textlib::substr($message, 0, 252) . '...'; + } + $columns[$this->messagecol] = $message; return $this->insert_log_record($this->logtable, $columns); } @@ -69,6 +75,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 } }