Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorsgiehl <stefan@piwik.org>2014-11-18 01:29:42 +0300
committersgiehl <stefan@piwik.org>2014-11-18 01:29:42 +0300
commit432a8c813b2b3ecba46abfe3c95cbdc03d43ec15 (patch)
tree01a37c39b3bf0b47930d26138c36b1068217c5c4 /core
parent0d1d7055fddadb641975eefdf8eb18fcad699bf0 (diff)
refactored duplicate code
Diffstat (limited to 'core')
-rw-r--r--core/Updates/2.10.0-b1.php49
1 files changed, 18 insertions, 31 deletions
diff --git a/core/Updates/2.10.0-b1.php b/core/Updates/2.10.0-b1.php
index 1224221064..6d1ccb4d54 100644
--- a/core/Updates/2.10.0-b1.php
+++ b/core/Updates/2.10.0-b1.php
@@ -134,24 +134,7 @@ class Updates_2_10_0_b1 extends Updates
// rebuild archives without versions
$browserBlobs = Db::get()->fetchAll(sprintf("SELECT * FROM %s WHERE name = 'DevicesDetection_browserVersions'", $table));
foreach ($browserBlobs as $blob) {
-
- $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) === 0) {
- return $label;
- }
-
- return $matches[1];
- }));
-
- $newData = $datatable->getSerialized();
-
- $blob['value'] = $newData[0];
- $blob['name'] = 'DevicesDetection_browsers';
-
- Db::get()->query(sprintf('REPLACE INTO %s (`idarchive`, `name`, `idsite`, `date1`, `date2`, `period`, `ts_archived`, `value`) VALUES (?, ? , ?, ?, ?, ?, ?, ?)', $table), array_values($blob));
+ self::createArchiveBlobWithoutVersions($blob, 'DevicesDetection_browsers', $table);
}
}
@@ -176,24 +159,28 @@ class Updates_2_10_0_b1 extends Updates
// rebuild archives without versions
$osBlobs = Db::get()->fetchAll(sprintf("SELECT * FROM %s WHERE name = 'DevicesDetection_osVersions'", $table));
foreach ($osBlobs as $blob) {
+ self::createArchiveBlobWithoutVersions($blob, 'DevicesDetection_os', $table);
+ }
+ }
- $blob['value'] = @gzuncompress($blob['value']);
+ protected static function createArchiveBlobWithoutVersions($blob, $newName, $table)
+ {
+ $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) === 0) {
- return $label;
- }
+ $datatable = DataTable::fromSerializedArray($blob['value']);
+ $datatable->filter('GroupBy', array('label', function ($label) {
+ if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $label, $matches) === 0) {
+ return $label;
+ }
- return $matches[1];
- }));
+ return $matches[1];
+ }));
- $newData = $datatable->getSerialized();
+ $newData = $datatable->getSerialized();
- $blob['value'] = $newData[0];
- $blob['name'] = 'DevicesDetection_os';
+ $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($blobData));
}
}