blob: fbd9d52fd8e7217b3d1b544cfa6fe1d58ffd750a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<?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\Archive\ArchiveInvalidator;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Container\StaticContainer;
use Piwik\Date;
use Piwik\Updater;
use Piwik\Updates as PiwikUpdates;
use Piwik\Updater\Migration\Factory as MigrationFactory;
class Updates_4_1_2_b1 extends PiwikUpdates
{
/**
* @var MigrationFactory
*/
private $migration;
public function __construct(MigrationFactory $factory)
{
$this->migration = $factory;
}
public function getMigrations(Updater $updater)
{
$migrations = [];
if (!Rules::isBrowserTriggerEnabled()) {
$dateOfMatomo4Release = Date::factory('2020-11-23');
$cmdStr = $this->getInvalidateCommand($dateOfMatomo4Release);
$migrations[] = new Updater\Migration\Custom(function () use ($dateOfMatomo4Release) {
$invalidator = StaticContainer::get(ArchiveInvalidator::class);
$invalidator->scheduleReArchiving('all', 'VisitFrequency', null, $dateOfMatomo4Release);
}, $cmdStr);
}
return $migrations;
}
public function doUpdate(Updater $updater)
{
$updater->executeMigrations(__FILE__, $this->getMigrations($updater));
}
private function getInvalidateCommand(Date $dateOfMatomo4Release)
{
$command = "php " . PIWIK_INCLUDE_PATH . '/console core:invalidate-report-data --sites=all';
$command .= ' --dates=' . $dateOfMatomo4Release->toString() . ',' . Date::factory('today')->toString();
$command .= ' --plugin=VisitFrequency';
return $command;
}
}
|