Fixed event db snapshot record mismatch

This commit is contained in:
Brendan Heywood
2020-02-13 10:50:04 +11:00
parent 75d872564b
commit 51f6f5ef5c
2 changed files with 16 additions and 4 deletions

View File

@@ -130,9 +130,6 @@ class outagedb {
// Create calendar entry.
calendar::create($outage);
} else {
// Remove the createdby field so it does not get updated.
unset($outage->createdby);
$DB->update_record('auth_outage', $outage);
$other = (array) $outage;
$other['title'] = $outage->get_title();
@@ -140,9 +137,14 @@ class outagedb {
'objectid' => $outage->id,
'other' => $other,
]);
$event->add_record_snapshot('auth_outage', (object)(array) $outage);
$event->trigger();
// Remove the createdby field so it does not get updated.
unset($outage->createdby);
$DB->update_record('auth_outage', $outage);
// Update calendar entry.
calendar::update($outage);
}

View File

@@ -281,7 +281,17 @@ class outage {
*/
private function adjust_field_types() {
// Adjust int fields.
$fs = ['createdby', 'id', 'lastmodified', 'modifiedby', 'starttime', 'stoptime', 'warntime', 'finished'];
$fs = [
'id',
'starttime',
'stoptime',
'warntime',
'finished',
'createdby',
'lastmodified',
'modifiedby',
];
foreach ($fs as $f) {
$this->$f = ($this->$f === null) ? null : (int)$this->$f;
}