Commit a7acb6a5 authored by Ghada El-Zoghbi's avatar Ghada El-Zoghbi

Bug#1735072: Upgrade error with event_log updated columns

Several issues resolved: 1. The event_log.time column has been removed and replaced by ctime. The handl_event() call is using the new column even though the new column has not been created yet in the upgrade script. Therefore, include both columns in the event handling. 2. The 'deleteartefacts' event stores multiple artefact IDs in the one event_log record. Therefore, there is not a one-to-one relationship when converting the record to the new format. Ignore the record when setting the resourceid and resourcetype. 3. In the 'saveartefact' and 'deleteartefact' events, not all of the event_log records have 'id' and 'artefact'. Ignore setting the resourceid and resourcetype fields when the data is not available. 4. For newer versions of Postgres and MySql, utilise the json dattype to convert the data held in the event_log.data column. This will speed up the processing of the table for sites with large data in the event_log table. Sponsored by Australian National University behatnotneeded Change-Id: If068dac825b9cef6301cd970f0a368124a67b3f1
parent c06a3565
This diff is collapsed.
......@@ -1907,3 +1907,17 @@ function mysql_get_variable($name) {
$result = $db->Execute("SHOW VARIABLES LIKE ?", array($name));
return $result->fields['Value'];
}
function get_db_version() {
global $db;
$version = '0';
if (is_postgres()) {
$sql = "SHOW server_version";
$result = $db->Execute($sql);
$version = $result->fields['server_version'];
}
else {
$version = mysql_get_variable('innodb_version');
}
return $version;
}
......@@ -2001,6 +2001,14 @@ function handle_event($event, $data, $ignorefields = array()) {
'parentresourceid' => $parentrefid,
'parentresourcetype' => $parentreftype,
);
// Include the old time column as well to cater for
// older versions of Mahara getting upgraded.
// Their event_log table will have not gone
// through the table alters during this
// part of the upgrade.
// The date it changed was 2017090800.
$logentry->time = $logentry->ctime;
// find out who 'owns' the event
list ($ownerid, $ownertype) = event_find_owner_type($logentry);
$logentry->ownerid = $ownerid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment