From f4f7b767a0ccfc0dea38f1310beafa200a983896 Mon Sep 17 00:00:00 2001 From: sgiehl <stefan@piwik.org> Date: Sun, 8 Jan 2017 12:52:20 +0100 Subject: [PATCH] renames method and updates doc --- CHANGELOG.md | 2 +- core/ArchiveProcessor/PluginsArchiver.php | 4 ++-- core/Plugin/Archiver.php | 6 ++++-- tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8446725f9c..89c4882740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,7 @@ If the tracker is not initialised correctly, the browser console will display th * The creation of settings has slightly changed to improve performance. It is now possible to create new settings via the method `$this->makeSetting()` see `Piwik\Plugins\ExampleSettingsPlugin\SystemSettings` for an example. * It is no longer possible to define an introduction text for settings. * If requesting multipe periods for one report, the keys that define the range are no longer translated. For example before 3.0 an API response may contain: `<result date="From 2010-02-01 to 2010-02-07">` which is now `<result date="2010-02-01,2010-02-07">`. -* The method `Piwik\Plugin\Archiver::shouldRunWithoutVisits()` has been added. It gives plugin archivers the possibility to decide whether to run if there weren't any visits by overwriting this method. +* The method `Piwik\Plugin\Archiver::shouldRunEvenWhenNoVisits()` has been added. By overwriting this method and returning true, a plugin archiver can force the archiving to run even when there was no visit for the website/date/period/segment combination (by default, archivers are skipped when there is no visit). * The following deprecated events have been removed as mentioned. * `Tracker.existingVisitInformation` Use [dimensions](http://developer.piwik.org/guides/dimensions) instead of using `Tracker` events. * `Tracker.newVisitorInformation` diff --git a/core/ArchiveProcessor/PluginsArchiver.php b/core/ArchiveProcessor/PluginsArchiver.php index bcfeb9cc8b..42b497c4b7 100644 --- a/core/ArchiveProcessor/PluginsArchiver.php +++ b/core/ArchiveProcessor/PluginsArchiver.php @@ -115,7 +115,7 @@ class PluginsArchiver continue; } - if (!$forceArchivingWithoutVisits && !$visits && !$archiver->shouldRunWithoutVisits()) { + if (!$forceArchivingWithoutVisits && !$visits && !$archiver->shouldRunEvenWhenNoVisits()) { Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s' (no visits).", __FUNCTION__, $pluginName); continue; } @@ -174,7 +174,7 @@ class PluginsArchiver $archivers = static::getPluginArchivers(); foreach ($archivers as $pluginName => $archiverClass) { - if ($archiverClass::shouldRunWithoutVisits()) { + if ($archiverClass::shouldRunEvenWhenNoVisits()) { return true; } } diff --git a/core/Plugin/Archiver.php b/core/Plugin/Archiver.php index 366ffbc325..fd247e0af6 100644 --- a/core/Plugin/Archiver.php +++ b/core/Plugin/Archiver.php @@ -143,11 +143,13 @@ abstract class Archiver } /** - * Whether this Archiver should run even if there aren't any visits. + * By overwriting this method and returning true, a plugin archiver can force the archiving to run even when there + * was no visit for the website/date/period/segment combination + * (by default, archivers are skipped when there is no visit). * * @return bool */ - public static function shouldRunWithoutVisits() + public static function shouldRunEvenWhenNoVisits() { return false; } diff --git a/tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php b/tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php index e0f9157de0..8f541e2d5d 100644 --- a/tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php +++ b/tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php @@ -32,7 +32,7 @@ class ArchiveWithNoVisitsTest_MockArchiver extends Archiver self::$methodsCalled[] = 'aggregateMultipleReports'; } - public static function shouldRunWithoutVisits() + public static function shouldRunEvenWhenNoVisits() { return self::$runWithoutVisits; } -- GitLab