diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2021-04-24 06:34:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-24 06:34:04 +0300 |
commit | 88800290a3f997b84101bd874b143e6c5021261f (patch) | |
tree | bfbff5655d30f62d4970fbabf5f0e335d879e75e /core | |
parent | 6227cb05197d4dfd0aa0d695eb665b6c1ef455d6 (diff) |
Add new update to make sure deleted segments also have a computed hash. (#17485)
* Add new update to make sure deleted segments also have a computed hash.
* Update 4.3.0-b4.php
Diffstat (limited to 'core')
-rw-r--r-- | core/Updates/4.3.0-b4.php | 53 | ||||
-rw-r--r-- | core/Version.php | 2 |
2 files changed, 54 insertions, 1 deletions
diff --git a/core/Updates/4.3.0-b4.php b/core/Updates/4.3.0-b4.php new file mode 100644 index 0000000000..37474ab0b9 --- /dev/null +++ b/core/Updates/4.3.0-b4.php @@ -0,0 +1,53 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ + +namespace Piwik\Updates; + +use Piwik\Updater; +use Piwik\Updates as PiwikUpdates; +use Piwik\Updater\Migration; +use Piwik\Updater\Migration\Factory as MigrationFactory; +use Piwik\Db; +use Piwik\Common; + +/** + * Update for version 4.3.0-b4. + */ +class Updates_4_3_0_b4 extends PiwikUpdates +{ + /** + * @var MigrationFactory + */ + private $migration; + + public function __construct(MigrationFactory $factory) + { + $this->migration = $factory; + } + + public function getMigrations(Updater $updater) + { + $migrations = []; + + $segmentTable = Common::prefixTable('segment'); + $segments = Db::fetchAll("SELECT idsegment, hash, definition FROM $segmentTable"); + foreach ($segments as $segment) { + if (empty($segment['hash'])) { + $hash = md5(urldecode($segment['definition'])); + $migrations[] = $this->migration->db->sql("UPDATE `$segmentTable` SET `hash` = '$hash' WHERE `idsegment` = '{$segment['idsegment']}'"); + } + } + return $migrations; + } + + public function doUpdate(Updater $updater) + { + $updater->executeMigrations(__FILE__, $this->getMigrations($updater)); + } +} diff --git a/core/Version.php b/core/Version.php index e38899c779..26773d4c85 100644 --- a/core/Version.php +++ b/core/Version.php @@ -20,7 +20,7 @@ final class Version * The current Matomo version. * @var string */ - const VERSION = '4.3.0-b3'; + const VERSION = '4.3.0-b4'; const MAJOR_VERSION = 4; public function isStableVersion($version) |