Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <diosmosis@users.noreply.github.com>2020-03-10 03:21:49 +0300
committerGitHub <noreply@github.com>2020-03-10 03:21:49 +0300
commit22cde646ec8247a068f75e673b69a51b97c825c2 (patch)
tree9625275ddbcc4b4252f3ab8dc42f449b3cf6bb3c /core/Archive.php
parentd6df56cb86f74b4fd3406b2802945470449b4b0a (diff)
Move Archive.php archive invalidation to Loader… (#15616)3.13.4-b1
* Move Archive.php archive invalidation to Loader so we only invalidate when about to launch archiving. * Attempt to handle more cases when invalidating before launching archiving. * fix possible sql error * fix possible error * fixing some tests * remove test code * Only invalidate specific archive being requested. * Do not invalidate on today in tracker and avoid existing valid archive check in CronArchive. * more test fixes * Attempt to fix more tests. * Fixing last tests. * another test fix * Invalidate in scheduled task if browser triggered archiving is enabled. * deal with TODO * Get ArchiveSelectorTest to pass. * applying review feedback including new tests * apply review feedback & fix tests * fix couple more tests Co-authored-by: Thomas Steur <tsteur@users.noreply.github.com>
Diffstat (limited to 'core/Archive.php')
-rw-r--r--core/Archive.php76
1 files changed, 4 insertions, 72 deletions
diff --git a/core/Archive.php b/core/Archive.php
index 1f56ef6062..141d477af4 100644
--- a/core/Archive.php
+++ b/core/Archive.php
@@ -12,7 +12,6 @@ use Piwik\Archive\ArchiveQuery;
use Piwik\Archive\ArchiveQueryFactory;
use Piwik\Archive\Parameters;
use Piwik\ArchiveProcessor\Rules;
-use Piwik\Archive\ArchiveInvalidator;
use Piwik\Container\StaticContainer;
use Piwik\DataAccess\ArchiveSelector;
@@ -168,11 +167,6 @@ class Archive implements ArchiveQuery
private static $cache;
/**
- * @var ArchiveInvalidator
- */
- private $invalidator;
-
- /**
* @param Parameters $params
* @param bool $forceIndexedBySite Whether to force index the result of a query by site ID.
* @param bool $forceIndexedByDate Whether to force index the result of a query by period.
@@ -183,8 +177,6 @@ class Archive implements ArchiveQuery
$this->params = $params;
$this->forceIndexedBySite = $forceIndexedBySite;
$this->forceIndexedByDate = $forceIndexedByDate;
-
- $this->invalidator = StaticContainer::get('Piwik\Archive\ArchiveInvalidator');
}
/**
@@ -453,67 +445,6 @@ class Archive implements ArchiveQuery
return $dataTable;
}
- private function getSiteIdsThatAreRequestedInThisArchiveButWereNotInvalidatedYet()
- {
- if (is_null(self::$cache)) {
- self::$cache = Cache::getTransientCache();
- }
-
- $id = 'Archive.SiteIdsOfRememberedReportsInvalidated';
-
- if (!self::$cache->contains($id)) {
- self::$cache->save($id, array());
- }
-
- $siteIdsAlreadyHandled = self::$cache->fetch($id);
- $siteIdsRequested = $this->params->getIdSites();
-
- foreach ($siteIdsRequested as $index => $siteIdRequested) {
- $siteIdRequested = (int) $siteIdRequested;
-
- if (in_array($siteIdRequested, $siteIdsAlreadyHandled)) {
- unset($siteIdsRequested[$index]); // was already handled previously, do not do it again
- } else {
- $siteIdsAlreadyHandled[] = $siteIdRequested; // we will handle this id this time
- }
- }
-
- self::$cache->save($id, $siteIdsAlreadyHandled);
-
- return $siteIdsRequested;
- }
-
- private function invalidatedReportsIfNeeded()
- {
- $siteIdsRequested = $this->getSiteIdsThatAreRequestedInThisArchiveButWereNotInvalidatedYet();
-
- if (empty($siteIdsRequested)) {
- return; // all requested site ids were already handled
- }
-
- $sitesPerDays = $this->invalidator->getRememberedArchivedReportsThatShouldBeInvalidated();
-
- foreach ($sitesPerDays as $date => $siteIds) {
- if (empty($siteIds)) {
- continue;
- }
-
- $siteIdsToActuallyInvalidate = array_intersect($siteIds, $siteIdsRequested);
-
- if (empty($siteIdsToActuallyInvalidate)) {
- continue; // all site ids that should be handled are already handled
- }
-
- try {
- $this->invalidator->markArchivesAsInvalidated($siteIdsToActuallyInvalidate, array(Date::factory($date)), false);
- } catch (\Exception $e) {
- Site::clearCache();
- throw $e;
- }
- }
-
- Site::clearCache();
- }
/**
* Queries archive tables for data and returns the result.
@@ -638,8 +569,6 @@ class Archive implements ArchiveQuery
*/
private function cacheArchiveIdsAfterLaunching($archiveGroups, $plugins)
{
- $this->invalidatedReportsIfNeeded();
-
$today = Date::today();
foreach ($this->params->getPeriods() as $period) {
@@ -856,8 +785,11 @@ class Archive implements ArchiveQuery
*/
private function prepareArchive(array $archiveGroups, Site $site, Period $period)
{
+ // if cron archiving is running, we will invalidate in CronArchive, not here
+ $invalidateBeforeArchiving = !SettingsServer::isArchivePhpTriggered();
+
$parameters = new ArchiveProcessor\Parameters($site, $period, $this->params->getSegment());
- $archiveLoader = new ArchiveProcessor\Loader($parameters);
+ $archiveLoader = new ArchiveProcessor\Loader($parameters, $invalidateBeforeArchiving);
$periodString = $period->getRangeString();