Skip to content

Commit

Permalink
refs matomo-org#6750 - added try catch to avoid errors with possibly …
Browse files Browse the repository at this point in the history
…invalid datatables
  • Loading branch information
sgiehl committed Nov 30, 2014
1 parent eb752f0 commit 61b5307
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions core/Updates/2.10.0-b1.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,28 @@ protected static function createArchiveBlobWithoutVersions($blob, $newName, $tab
{
$blob['value'] = @gzuncompress($blob['value']);

$datatable = DataTable::fromSerializedArray($blob['value']);
$datatable->filter('GroupBy', array('label', function ($label) {
if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $label, $matches)) {
return $matches[1]; // should match for browsers
}
try {
$datatable = DataTable::fromSerializedArray($blob['value']);
$datatable->filter('GroupBy', array('label', function ($label) {
if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $label, $matches)) {
return $matches[1]; // should match for browsers
}

if (strpos($label, ';')) {
return substr($label, 0, 3); // should match for os
}
if (strpos($label, ';')) {
return substr($label, 0, 3); // should match for os
}

return $label;
}));
return $label;
}));

$newData = $datatable->getSerialized();
$newData = $datatable->getSerialized();

$blob['value'] = @gzcompress($newData[0]);
$blob['name'] = $newName;
$blob['value'] = @gzcompress($newData[0]);
$blob['name'] = $newName;

Db::get()->query(sprintf('REPLACE INTO %s (`idarchive`, `name`, `idsite`, `date1`, `date2`, `period`, `ts_archived`, `value`) VALUES (?, ? , ?, ?, ?, ?, ?, ?)', $table), array_values($blob));
Db::get()->query(sprintf('REPLACE INTO %s (`idarchive`, `name`, `idsite`, `date1`, `date2`, `period`, `ts_archived`, `value`) VALUES (?, ? , ?, ?, ?, ?, ?, ?)', $table), array_values($blob));
} catch (\Exception $e) {
// fail silently and simply skip the current record
}
}
}

0 comments on commit 61b5307

Please sign in to comment.