diff options
13 files changed, 248 insertions, 41 deletions
diff --git a/core/ArchiveProcessor/Loader.php b/core/ArchiveProcessor/Loader.php index 4180f659b8..1df58adbf4 100644 --- a/core/ArchiveProcessor/Loader.php +++ b/core/ArchiveProcessor/Loader.php @@ -127,8 +127,7 @@ class Loader // with a ts_archived >= the DONE_OK/DONE_INVALIDATED date. list($idArchives, $visits, $visitsConverted, $isAnyArchiveExists, $tsArchived, $value) = $this->loadExistingArchiveIdFromDb(); if (!empty($idArchives) - && !$this->params->getArchiveOnlyReport() - && !Rules::isForceArchivingSinglePlugin() + && !Rules::isActuallyForceArchivingSinglePlugin() && !$this->shouldForceInvalidatedArchive($value, $tsArchived) ) { // we have a usable idarchive (it's not invalidated and it's new enough), and we are not archiving @@ -184,16 +183,22 @@ class Loader if ($createSeparateArchiveForCoreMetrics) { $requestedPlugin = $this->params->getRequestedPlugin(); $requestedReport = $this->params->getArchiveOnlyReport(); + $isPartialArchive = $this->params->isPartialArchive(); $this->params->setRequestedPlugin('VisitsSummary'); $this->params->setArchiveOnlyReport(null); + $this->params->setIsPartialArchive(false); - $pluginsArchiver = new PluginsArchiver($this->params); - $metrics = $pluginsArchiver->callAggregateCoreMetrics(); - $pluginsArchiver->finalizeArchive(); + $metrics = Context::executeWithQueryParameters(['requestedReport' => ''], function () { + $pluginsArchiver = new PluginsArchiver($this->params); + $metrics = $pluginsArchiver->callAggregateCoreMetrics(); + $pluginsArchiver->finalizeArchive(); + return $metrics; + }); $this->params->setRequestedPlugin($requestedPlugin); $this->params->setArchiveOnlyReport($requestedReport); + $this->params->setIsPartialArchive($isPartialArchive); $visits = $metrics['nb_visits']; $visitsConverted = $metrics['nb_visits_converted']; diff --git a/core/ArchiveProcessor/Rules.php b/core/ArchiveProcessor/Rules.php index 27d505a7ea..a3a523b653 100644 --- a/core/ArchiveProcessor/Rules.php +++ b/core/ArchiveProcessor/Rules.php @@ -62,7 +62,7 @@ class Rules public static function shouldProcessReportsAllPlugins(array $idSites, Segment $segment, $periodLabel) { - if (self::isForceArchivingSinglePlugin()) { + if (self::isRequestingToAndAbleToForceArchiveSinglePlugin()) { return false; } @@ -334,17 +334,20 @@ class Rules return $possibleValues; } - public static function isForceArchivingSinglePlugin() + public static function isRequestingToAndAbleToForceArchiveSinglePlugin() { - if (!SettingsServer::isArchivePhpTriggered() - || Loader::getArchivingDepth() > 1 - ) { + if (!SettingsServer::isArchivePhpTriggered()) { return false; } return !empty($_GET['pluginOnly']) || !empty($_POST['pluginOnly']); } + public static function isActuallyForceArchivingSinglePlugin() + { + return Loader::getArchivingDepth() <= 1 && self::isRequestingToAndAbleToForceArchiveSinglePlugin(); + } + public static function shouldProcessSegmentsWhenReArchivingReports() { return Config::getInstance()->General['rearchive_reports_in_past_exclude_segments'] != 1; diff --git a/core/DataAccess/ArchiveSelector.php b/core/DataAccess/ArchiveSelector.php index 1e7ad4117a..fc2a7fae39 100644 --- a/core/DataAccess/ArchiveSelector.php +++ b/core/DataAccess/ArchiveSelector.php @@ -148,7 +148,7 @@ class ArchiveSelector } $getArchiveIdsSql = "SELECT idsite, date1, date2, - GROUP_CONCAT(CONCAT(idarchive,'|',`name`) ORDER BY idarchive DESC SEPARATOR ',') AS archives + GROUP_CONCAT(CONCAT(idarchive,'|',`name`,'|',`value`) ORDER BY idarchive DESC SEPARATOR ',') AS archives FROM %s WHERE idsite IN (" . implode(',', $siteIds) . ") AND " . self::getNameCondition($plugins, $segment, $includeInvalidated) . " @@ -208,10 +208,14 @@ class ArchiveSelector $archives = $row['archives']; $pairs = explode(',', $archives); foreach ($pairs as $pair) { - list($idarchive, $doneFlag) = explode('|', $pair); + list($idarchive, $doneFlag, $value) = explode('|', $pair); $result[$doneFlag][$dateStr][] = $idarchive; - if (strpos($doneFlag, '.') === false) { // all plugins archive + if (strpos($doneFlag, '.') === false // all plugins archive + // sanity check: DONE_PARTIAL shouldn't be used w/ done archives, but in case we see one, + // don't treat it like an all plugins archive + && $value != ArchiveWriter::DONE_PARTIAL + ) { break; // found the all plugins archive, don't need to look in older archives since we have everything here } } diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php index 49d8a52104..05fb6d6c6b 100644 --- a/core/DataAccess/ArchiveWriter.php +++ b/core/DataAccess/ArchiveWriter.php @@ -12,9 +12,11 @@ use Exception; use Piwik\Archive\Chunk; use Piwik\ArchiveProcessor\Rules; use Piwik\ArchiveProcessor; +use Piwik\Container\StaticContainer; use Piwik\Date; use Piwik\Db; use Piwik\Db\BatchInsert; +use Psr\Log\LoggerInterface; /** * This class is used to create a new Archive. @@ -165,6 +167,8 @@ class ArchiveWriter $idArchive = $this->getIdArchive(); $doneValue = $this->parameters->isPartialArchive() ? self::DONE_PARTIAL : self::DONE_OK; + $this->checkDoneValueIsOnlyPartialForPluginArchives($doneValue); // check and log + $this->getModel()->updateArchiveStatus($numericTable, $idArchive, $this->doneFlag, $doneValue); if (!$this->parameters->isPartialArchive() @@ -333,4 +337,17 @@ class ArchiveWriter { return is_numeric($value); } + + private function checkDoneValueIsOnlyPartialForPluginArchives($doneValue) + { + // if the done flag is not like done%.PluginName, then it shouldn't be a partial archive. + // log a warning. + if ($doneValue == self::DONE_PARTIAL && strpos($this->doneFlag, '.') == false) { + $ex = new \Exception(sprintf("Trying to create a partial archive w/ an all plugins done flag (done flag = %s). This should not happen.", + $this->doneFlag)); + StaticContainer::get(LoggerInterface::class)->warning('{exception}', [ + 'exception' => $ex, + ]); + } + } } diff --git a/plugins/CoreConsole/tests/System/ArchiveCronTest.php b/plugins/CoreConsole/tests/System/ArchiveCronTest.php index 1872a55157..bbc48d31c9 100644 --- a/plugins/CoreConsole/tests/System/ArchiveCronTest.php +++ b/plugins/CoreConsole/tests/System/ArchiveCronTest.php @@ -24,14 +24,10 @@ use Piwik\Container\StaticContainer; use Piwik\DataAccess\ArchiveTableCreator; use Piwik\Date; use Piwik\Db; -use Piwik\Option; use Piwik\Segment; -use Piwik\Sequence; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Tests\Fixtures\ManySitesImportedLogs; use Piwik\Tests\Framework\Fixture; -use Exception; -use Psr\Log\LoggerInterface; /** * Tests to call the cron core:archive command script and check there is no error, @@ -83,6 +79,8 @@ class ArchiveCronTest extends SystemTestCase self::$fixture->getTestEnvironment()->overrideConfig('General', 'enable_browser_archiving_triggering', 0); self::$fixture->getTestEnvironment()->save(); + Rules::setBrowserTriggerArchiving(false); + // add one segment and set it's created/updated time to some time in the past so we don't re-archive for it $idSegment = API::getInstance()->add(self::NEW_SEGMENT_NAME, self::NEW_SEGMENT, self::$fixture->idSite, $autoArchive = 1, $enabledAllUsers = 1); @@ -109,6 +107,8 @@ class ArchiveCronTest extends SystemTestCase self::$fixture->getTestEnvironment()->overrideConfig('General', 'enable_browser_archiving_triggering', 1); self::$fixture->getTestEnvironment()->save(); + Rules::setBrowserTriggerArchiving(true); + Db::exec("UPDATE " . Common::prefixTable('segment') . ' SET ts_created = \'2015-01-02 00:00:00\', ts_last_edit = \'2015-01-02 00:00:00\' WHERE idsegment IN (' . $idSegment . ", " . $idSegment2 . ")"); } @@ -213,6 +213,8 @@ class ArchiveCronTest extends SystemTestCase Config::getInstance()->General['enable_browser_archiving_triggering'] = 0; Config::getInstance()->General['browser_archiving_disabled_enforce'] = 1; + Rules::setBrowserTriggerArchiving(false); + // invalidate exampleplugin only archives in past $invalidator = StaticContainer::get(ArchiveInvalidator::class); $invalidator->markArchivesAsInvalidated( @@ -273,7 +275,20 @@ class ArchiveCronTest extends SystemTestCase Config::getInstance()->General['enable_browser_archiving_triggering'] = 0; Config::getInstance()->General['browser_archiving_disabled_enforce'] = 1; - $table = ArchiveTableCreator::getNumericTable(Date::factory('2007-04-05')); + Rules::setBrowserTriggerArchiving(false); + + // request a different date than other tests so we can test that only the single requested metric is archived + $dateToRequest = '2007-04-04'; + + // track a visit so archiving will go through + $tracker = Fixture::getTracker(1, '2007-04-04'); + $tracker->setUrl('http://example.com/test/url2'); + Fixture::checkResponse($tracker->doTrackPageView('jkl')); + + $invalidator = StaticContainer::get(ArchiveInvalidator::class); + $invalidator->forgetRememberedArchivedReportsToInvalidate(1, Date::factory('2007-04-04')); + + $table = ArchiveTableCreator::getNumericTable(Date::factory($dateToRequest)); // three whole plugin archives from previous tests $countOfDoneExamplePluginArchives = Db::fetchOne("SELECT COUNT(*) FROM `$table` WHERE name = 'done.ExamplePlugin'"); @@ -281,18 +296,13 @@ class ArchiveCronTest extends SystemTestCase // invalidate a report so we get a partial archive (using the metric that gets incremented each time it is archived) // (do it after the last run so we don't end up just re-using the ExamplePlugin archive) - $invalidator = StaticContainer::get(ArchiveInvalidator::class); - $invalidator->markArchivesAsInvalidated([1], ['2007-04-05'], 'day', new Segment('', [1]), false, false, 'ExamplePlugin.ExamplePlugin_example_metric2'); + $invalidator->markArchivesAsInvalidated([1], [$dateToRequest], 'day', new Segment('', [1]), false, false, 'ExamplePlugin.ExamplePlugin_example_metric'); - $output = $this->runArchivePhpCron(); - - Option::delete(CronArchive::OPTION_ARCHIVING_FINISHED_TS); // clear so segment re-archive logic runs on this run - Option::delete(CronArchive::CRON_INVALIDATION_TIME_OPTION_NAME); - $output = $this->runArchivePhpCron(); // have to run twice since we manually invalidate above + $output = $this->runArchivePhpCron(['-vvv' => null]); $this->runApiTests('ExamplePlugin.getExampleArchivedMetric', [ 'idSite' => 'all', - 'date' => '2007-04-05', + 'date' => $dateToRequest, 'periods' => ['day', 'week'], 'testSuffix' => '_singleMetric', ]); @@ -322,6 +332,8 @@ class ArchiveCronTest extends SystemTestCase Config::getInstance()->General['archiving_range_force_on_browser_request'] = 0; Config::getInstance()->General['archiving_custom_ranges'][] = ''; + Rules::setBrowserTriggerArchiving(false); + $output = $this->runArchivePhpCron(['--force-periods' => 'range', '--force-idsites' => 1]); $expectedInvalidations = []; diff --git a/plugins/CoreConsole/tests/System/expected/test_ArchiveCronTest_singleMetric__ExamplePlugin.getExampleArchivedMetric_day.xml b/plugins/CoreConsole/tests/System/expected/test_ArchiveCronTest_singleMetric__ExamplePlugin.getExampleArchivedMetric_day.xml index 77306ca768..049680a34c 100644 --- a/plugins/CoreConsole/tests/System/expected/test_ArchiveCronTest_singleMetric__ExamplePlugin.getExampleArchivedMetric_day.xml +++ b/plugins/CoreConsole/tests/System/expected/test_ArchiveCronTest_singleMetric__ExamplePlugin.getExampleArchivedMetric_day.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8" ?> <results> <result idSite="1"> - <ExamplePlugin_example_metric>0</ExamplePlugin_example_metric> - <ExamplePlugin_example_metric2>1</ExamplePlugin_example_metric2> + <ExamplePlugin_example_metric>3383</ExamplePlugin_example_metric> + <ExamplePlugin_example_metric2>0</ExamplePlugin_example_metric2> </result> <result idSite="2" /> <result idSite="3" /> diff --git a/plugins/CoreConsole/tests/System/expected/test_ArchiveCronTest_singleMetric__ExamplePlugin.getExampleArchivedMetric_week.xml b/plugins/CoreConsole/tests/System/expected/test_ArchiveCronTest_singleMetric__ExamplePlugin.getExampleArchivedMetric_week.xml index 77306ca768..14aaf18648 100644 --- a/plugins/CoreConsole/tests/System/expected/test_ArchiveCronTest_singleMetric__ExamplePlugin.getExampleArchivedMetric_week.xml +++ b/plugins/CoreConsole/tests/System/expected/test_ArchiveCronTest_singleMetric__ExamplePlugin.getExampleArchivedMetric_week.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8" ?> <results> <result idSite="1"> - <ExamplePlugin_example_metric>0</ExamplePlugin_example_metric> - <ExamplePlugin_example_metric2>1</ExamplePlugin_example_metric2> + <ExamplePlugin_example_metric>6765</ExamplePlugin_example_metric> + <ExamplePlugin_example_metric2>0</ExamplePlugin_example_metric2> </result> <result idSite="2" /> <result idSite="3" /> diff --git a/plugins/ExamplePlugin/Archiver.php b/plugins/ExamplePlugin/Archiver.php index c206354382..b9b9bc4ab1 100644 --- a/plugins/ExamplePlugin/Archiver.php +++ b/plugins/ExamplePlugin/Archiver.php @@ -43,11 +43,6 @@ class Archiver extends \Piwik\Plugin\Archiver private $daysFrom = '2016-07-08'; - /** - * @var string - */ - private $requestedReport = null; - public function __construct(ArchiveProcessor $processor) { parent::__construct($processor); diff --git a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php index ae26a06e27..c44995e904 100644 --- a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php @@ -85,7 +85,7 @@ abstract class IntegrationTestCase extends SystemTestCase Fixture::loadAllPlugins(new TestingEnvironmentVariables(), get_class($this), self::$fixture->extraPluginsToLoad); Access::getInstance()->setSuperUserAccess(true); - + if (!empty(self::$tableData)) { self::restoreDbTables(self::$tableData); } diff --git a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php index 85a2e85326..58ed04fa35 100644 --- a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php @@ -783,7 +783,6 @@ abstract class SystemTestCase extends TestCase } - } } diff --git a/tests/PHPUnit/Integration/ArchiveProcessor/LoaderTest.php b/tests/PHPUnit/Integration/ArchiveProcessor/LoaderTest.php index bf4b1a0c72..fb0986e4d6 100644 --- a/tests/PHPUnit/Integration/ArchiveProcessor/LoaderTest.php +++ b/tests/PHPUnit/Integration/ArchiveProcessor/LoaderTest.php @@ -127,6 +127,175 @@ class LoaderTest extends IntegrationTestCase ], $existingArchives); } + public function test_pluginOnlyArchivingDoesNotRelaunchChildArchives_whenReusingAllPluginsArchives() + { + // not setting pluginOnly=1 to ensure all plugins archive is created for the day w/ visits + $_GET['trigger'] = 'archivephp'; + + $idSite = 1; + $dateTime = '2020-01-20 02:03:04'; + $anotherDayDateTime = '2020-01-22 08:00:00'; + $date = '2020-01-20'; + $period = 'week'; + $segment = ''; + $plugin = 'ExamplePlugin'; // NOTE: it's important to use ExamplePlugin here since it has an example of creating partial archives + + $t = Fixture::getTracker($idSite, $dateTime); + $t->setUrl('http://slkdfj.com'); + Fixture::checkResponse($t->doTrackPageView('alsdkjf')); + + $periodObj = Factory::build($period, $date); + foreach ($periodObj->getSubperiods() as $day) { + // archive each day before hand + $params = new Parameters(new Site($idSite), $day, new Segment($segment, [$idSite])); + $loader = new Loader($params); + $loader->prepareArchive($plugin); + } + + // add a visit to another day in the week, but no archive so it will get archived in pluginOnly request + $t = Fixture::getTracker($idSite, $anotherDayDateTime); + $t->setUrl('http://slkdfj.com'); + Fixture::checkResponse($t->doTrackPageView('alsdkjf 2')); + + $existingArchives = $this->getExistingArchives($date); + $this->assertEquals([ + [ + 'idarchive' => '1', + 'name' => 'done', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + [ + 'idarchive' => '2', + 'name' => 'done90a5a511e1974bca37613b6daec137ba.VisitsSummary', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + [ + 'idarchive' => '3', + 'name' => 'done90a5a511e1974bca37613b6daec137ba.Goals', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + [ + 'idarchive' => '4', + 'name' => 'donefea44bece172bc9696ae57c26888bf8a.VisitsSummary', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + [ + 'idarchive' => '5', + 'name' => 'donefea44bece172bc9696ae57c26888bf8a.Goals', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + ], $existingArchives); + + // archiving w/ pluginOnly=1 + $_GET['pluginOnly'] = 1; + $_GET['requestedReport'] = Archiver::EXAMPLEPLUGIN_METRIC_NAME; // so it will be set when the archiver recurses + + $params = new Parameters(new Site($idSite), $periodObj, new Segment($segment, [$idSite])); + $params->setRequestedPlugin($plugin); + $params->setArchiveOnlyReport(Archiver::EXAMPLEPLUGIN_METRIC_NAME); + + $loader = new Loader($params); + $loader->prepareArchive($plugin); + + $existingArchives = $this->getExistingArchives($date); + + // expected result means: + // - we keep and reuse already existing all plugins archive for 2020-01-20 + // - we create new single plugin (non-partial) archives for VisitsSummary + // - we create new single report (partial) archives for ExamplePlugin + $this->assertEquals([ + [ + 'idarchive' => '1', + 'name' => 'done', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + [ + 'idarchive' => '2', + 'name' => 'done90a5a511e1974bca37613b6daec137ba.VisitsSummary', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + [ + 'idarchive' => '3', + 'name' => 'done90a5a511e1974bca37613b6daec137ba.Goals', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + [ + 'idarchive' => '4', + 'name' => 'donefea44bece172bc9696ae57c26888bf8a.VisitsSummary', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + [ + 'idarchive' => '5', + 'name' => 'donefea44bece172bc9696ae57c26888bf8a.Goals', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-20', + 'period' => '1', + ], + + // start of new archives + [ + 'idarchive' => '6', + 'name' => 'done.VisitsSummary', + 'value' => '1', + 'date1' => '2020-01-20', + 'date2' => '2020-01-26', + 'period' => '2', + ], + [ + 'idarchive' => '7', + 'name' => 'done.VisitsSummary', + 'value' => '1', + 'date1' => '2020-01-22', + 'date2' => '2020-01-22', + 'period' => '1', + ], + [ + 'idarchive' => '8', + 'name' => 'done.ExamplePlugin', + 'value' => '5', + 'date1' => '2020-01-20', + 'date2' => '2020-01-26', + 'period' => '2', + ], + [ + 'idarchive' => '9', + 'name' => 'done.ExamplePlugin', + 'value' => '5', + 'date1' => '2020-01-22', + 'date2' => '2020-01-22', + 'period' => '1', + ], + ], $existingArchives); + } + private function getExistingArchives($date) { $table = ArchiveTableCreator::getNumericTable(Date::factory($date)); diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveSelectorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveSelectorTest.php index f57b1b123c..609df52f08 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveSelectorTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveSelectorTest.php @@ -87,7 +87,7 @@ class ArchiveSelectorTest extends IntegrationTestCase ], ], - // multiple partials for specific reports + normal + // multiple partials for specific reports + normal + one malformed partial [ [ ['idarchive' => 1, 'idsite' => 1, 'period' => 1, 'date1' => '2020-03-01', 'date2' => '2020-03-01', 'name' => 'done.Funnels', 'value' => 5, 'ts_archived' => '2020-03-03 01:00:00'], @@ -101,6 +101,7 @@ class ArchiveSelectorTest extends IntegrationTestCase ['idarchive' => 7, 'idsite' => 1, 'period' => 1, 'date1' => '2020-03-01', 'date2' => '2020-03-01', 'name' => 'done.Funnels', 'value' => 5, 'ts_archived' => '2020-03-04 01:07:00'], ['idarchive' => 8, 'idsite' => 1, 'period' => 1, 'date1' => '2020-03-01', 'date2' => '2020-03-01', 'name' => 'done.AnotherPlugin', 'value' => 5, 'ts_archived' => '2020-03-04 01:05:00'], ['idarchive' => 9, 'idsite' => 1, 'period' => 1, 'date1' => '2020-03-01', 'date2' => '2020-03-01', 'name' => 'done.AnotherPlugin', 'value' => 5, 'ts_archived' => '2020-03-04 01:07:00'], + ['idarchive' => 10, 'idsite' => 1, 'period' => 1, 'date1' => '2020-03-01', 'date2' => '2020-03-01', 'name' => 'done', 'value' => 5, 'ts_archived' => '2020-03-04 01:07:00'], ], [1], [ @@ -110,7 +111,7 @@ class ArchiveSelectorTest extends IntegrationTestCase ['Funnels'], [ 'done' => [ - '2020-03-01,2020-03-01' => [4], + '2020-03-01,2020-03-01' => [10,4], ], 'done.Funnels' => [ '2020-03-01,2020-03-01' => [7,6,5], diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php index d8493d14ad..1e4d77c80d 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php @@ -10,6 +10,7 @@ namespace Piwik\Tests\Integration\DataAccess; use Piwik\Access; use Piwik\ArchiveProcessor\Parameters; +use Piwik\ArchiveProcessor\Rules; use Piwik\Common; use Piwik\DataAccess\ArchiveTableCreator; use Piwik\DataAccess\ArchiveWriter; @@ -17,6 +18,7 @@ use Piwik\Date; use Piwik\Db; use Piwik\Period\Day; use Piwik\Period\Factory as PeriodFactory; +use Piwik\Plugins\SegmentEditor\API; use Piwik\Segment; use Piwik\Sequence; use Piwik\Site; @@ -226,10 +228,10 @@ class ArchiveWriterTest extends IntegrationTestCase } } - private function buildWriter($period, $date, $isPartial = false) + private function buildWriter($period, $date, $isPartial = false, $segment = '') { $oPeriod = PeriodFactory::makePeriodFromQueryParams('UTC', $period, $date); - $segment = new Segment('', []); + $segment = new Segment($segment, []); $params = new Parameters(new Site($this->idSite), $oPeriod, $segment); if ($isPartial) { $params->setRequestedPlugin('ExamplePlugin'); |