PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.2.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.2.0
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / Updates / 4.6.0-b4.php
matomo / app / core / Updates Last commit date
3.12.0-b1.php 2 years ago 3.12.0-b7.php 2 years ago 4.0.0-b1.php 1 year ago 4.0.0-b3.php 2 years ago 4.0.0-rc3.php 2 years ago 4.0.0-rc4.php 1 year ago 4.0.1-b1.php 2 years ago 4.0.4-b1.php 2 years ago 4.1.2-b1.php 2 years ago 4.1.2-b2.php 2 years ago 4.10.0-b1.php 2 years ago 4.11.0-b1.php 2 years ago 4.11.0-rc2.php 2 years ago 4.12.0-b1.php 2 years ago 4.12.0-b2.php 2 years ago 4.12.0-b3.php 1 year ago 4.12.0-b4.php 2 years ago 4.3.0-b3.php 2 years ago 4.3.0-b4.php 2 years ago 4.3.0-rc2.php 2 years ago 4.4.0-b1.php 2 years ago 4.5.0-b1.php 2 years ago 4.6.0-b1.php 2 years ago 4.6.0-b4.php 1 year ago 4.6.2-rc2.php 1 year ago 4.7.0-b2.php 2 years ago 4.7.1-b1.php 2 years ago 5.0.0-b1.php 1 year ago 5.0.0-rc2.php 2 years ago 5.0.0-rc5.php 2 years ago 5.2.0-b2.php 1 year ago 5.2.0-b6.php 1 year ago
4.6.0-b4.php
104 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 */
9 namespace Piwik\Updates;
10
11 use Piwik\ArchiveProcessor\Rules;
12 use Piwik\Common;
13 use Piwik\DataAccess\ArchiveTableCreator;
14 use Piwik\Db;
15 use Piwik\Plugins\SitesManager\Model;
16 use Piwik\Plugins\VisitFrequency\API as VisitFrequencyAPI;
17 use Piwik\Segment;
18 use Piwik\Segment\SegmentExpression;
19 use Piwik\Updater;
20 use Piwik\Updates as PiwikUpdates;
21 use Piwik\Updater\Migration;
22 use Piwik\Updater\Migration\Factory as MigrationFactory;
23 /**
24 * Update for version 4.6.0-b2.
25 */
26 class Updates_4_6_0_b4 extends PiwikUpdates
27 {
28 /**
29 * @var MigrationFactory
30 */
31 private $migration;
32 public function __construct(MigrationFactory $factory)
33 {
34 $this->migration = $factory;
35 }
36 /**
37 * @param Updater $updater
38 * @return Migration\Db[]
39 */
40 public function getMigrations(Updater $updater)
41 {
42 $migrations = [];
43 $sites = new Model();
44 $idSites = $sites->getSitesId();
45 $doneFlagsToMigrate = [];
46 foreach ($idSites as $idSite) {
47 $segmentStrings = Rules::getSegmentsToProcess([$idSite]);
48 foreach ($segmentStrings as $segmentString) {
49 try {
50 $segment = new Segment($segmentString, [$idSite]);
51 } catch (\Exception $e) {
52 continue;
53 }
54 if ($segment->getOriginalString() === $segment->getString()) {
55 continue;
56 }
57 $segmentsToAppend = [VisitFrequencyAPI::NEW_VISITOR_SEGMENT, VisitFrequencyAPI::RETURNING_VISITOR_SEGMENT];
58 foreach ($segmentsToAppend as $segmentToAppend) {
59 // we need to migrate the existing archive
60 $oldSegmentString = Segment::combine($segment->getString(), SegmentExpression::AND_DELIMITER, $segmentToAppend);
61 $newSegmentString = Segment::combine($segment->getOriginalString(), SegmentExpression::AND_DELIMITER, $segmentToAppend);
62 $oldSegmentHash = Segment::getSegmentHash($oldSegmentString);
63 $newSegmentHash = Segment::getSegmentHash($newSegmentString);
64 if ($oldSegmentHash === $newSegmentHash) {
65 continue;
66 }
67 $doneFlagsToMigrate['done' . $oldSegmentHash . '.Goals'] = 'done' . $newSegmentHash . '.Goals';
68 $doneFlagsToMigrate['done' . $oldSegmentHash . '.VisitsSummary'] = 'done' . $newSegmentHash . '.VisitsSummary';
69 $doneFlagsToMigrate['done' . $oldSegmentHash . '.UserCountry'] = 'done' . $newSegmentHash . '.UserCountry';
70 }
71 }
72 }
73 if (!empty($doneFlagsToMigrate)) {
74 foreach (ArchiveTableCreator::getTablesArchivesInstalled() as $table) {
75 if (strpos($table, 'numeric') === \false) {
76 continue;
77 }
78 $sqlPlaceholders = Common::getSqlStringFieldsArray($doneFlagsToMigrate);
79 $bind = array_keys($doneFlagsToMigrate);
80 $selectSql = sprintf('SELECT 1 FROM %s where `name` in (%s) LIMIT 1', $table, $sqlPlaceholders);
81 $archiveTableHasDoneFlags = Db::fetchOne($selectSql, $bind);
82 if (!$archiveTableHasDoneFlags) {
83 continue;
84 }
85 $sql = 'update ' . $table . ' set `name` = (case';
86 foreach ($doneFlagsToMigrate as $oldDoneFlag => $newDoneFlag) {
87 $sql .= " when `name` = '{$oldDoneFlag}' then '{$newDoneFlag}' ";
88 }
89 $sql .= ' else `name` end) where `name` in (' . $sqlPlaceholders . ')';
90 Db::query($sql, $bind);
91 $migrations[] = $this->migration->db->boundSql($sql, $bind, [Migration\Db\Sql::ERROR_CODE_DUPLICATE_ENTRY]);
92 }
93 }
94 return $migrations;
95 }
96 /**
97 * @param Updater $updater
98 */
99 public function doUpdate(Updater $updater)
100 {
101 $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
102 }
103 }
104