Skip to content

Commit

Permalink
Merge pull request #12914 from jeabakker/system-log-archive
Browse files Browse the repository at this point in the history
fix(system_log): check archive engine availability before changing
  • Loading branch information
jdalsem committed Nov 22, 2019
2 parents 8368adf + 99e3c92 commit e605389
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions mod/system_log/classes/Elgg/SystemLog/SystemLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,21 @@ public function archive(DateTime $created_before) {
return false;
}

// alter table to engine
if (!$this->db->updateData("ALTER TABLE {$dbprefix}system_log_{$now} ENGINE=ARCHIVE")) {
return false;
// alter table to archive engine (when available)
$available_engines = elgg()->db->getData('SHOW ENGINES');
$available_engines = array_filter($available_engines, function($row) {
// filter only enabled engines
return in_array($row->Support, ['YES', 'DEFAULT']);
});
array_walk($available_engines, function(&$row) {
// only need engine names
$row = $row->Engine;
});

if (in_array('ARCHIVE', $available_engines)) {
if (!$this->db->updateData("ALTER TABLE {$dbprefix}system_log_{$now} ENGINE=ARCHIVE")) {
return false;
}
}

return true;
Expand Down

0 comments on commit e605389

Please sign in to comment.