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:
Diffstat (limited to 'core/CronArchive.php')
-rw-r--r--core/CronArchive.php24
1 files changed, 19 insertions, 5 deletions
diff --git a/core/CronArchive.php b/core/CronArchive.php
index 9d8801fcbd..bb1337dbb0 100644
--- a/core/CronArchive.php
+++ b/core/CronArchive.php
@@ -9,7 +9,6 @@
namespace Piwik;
use Exception;
-use Piwik\ArchiveProcessor\Parameters;
use Piwik\ArchiveProcessor\PluginsArchiver;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Archiver\Request;
@@ -274,6 +273,8 @@ class CronArchive
*/
private $isArchiveProfilingEnabled = false;
+ private $lastDbReset = false;
+
/**
* Returns the option name of the option that stores the time core:archive was last executed.
*
@@ -305,6 +306,7 @@ class CronArchive
$this->invalidator = StaticContainer::get('Piwik\Archive\ArchiveInvalidator');
$this->isArchiveProfilingEnabled = Config::getInstance()->Debug['archiving_profile'] == 1;
+ $this->lastDbReset = time();
}
private function isMaintenanceModeEnabled()
@@ -411,10 +413,7 @@ class CronArchive
(!$instanceId
|| strpos($process, '--matomo-domain=' . $instanceId) !== false
|| strpos($process, '--matomo-domain="' . $instanceId . '"') !== false
- || strpos($process, '--matomo-domain=\'' . $instanceId . "'") !== false
- || strpos($process, '--piwik-domain=' . $instanceId) !== false
- || strpos($process, '--piwik-domain="' . $instanceId . '"') !== false
- || strpos($process, '--piwik-domain=\'' . $instanceId . "'") !== false)) {
+ || strpos($process, '--matomo-domain=\'' . $instanceId . "'") !== false)) {
$numRunning++;
}
}
@@ -977,6 +976,8 @@ class CronArchive
// public for tests
public function isThereAValidArchiveForPeriod($idSite, $period, $date, $segment = '')
{
+ $this->disconnectDb();
+
if (Range::isMultiplePeriod($date, $period)) {
$rangePeriod = Factory::build($period, $date, Site::getTimezoneFor($idSite));
$periodsToCheck = $rangePeriod->getSubperiods();
@@ -1274,12 +1275,25 @@ class CronArchive
} catch (Exception $e) {
return $this->logNetworkError($url, $e->getMessage());
}
+ $this->disconnectDb();
if ($this->checkResponse($response, $url)) {
return $response;
}
return false;
}
+ private function disconnectDb()
+ {
+ $twoHoursInSeconds = 60 * 60 * 2;
+
+ if (time() > ($this->lastDbReset + $twoHoursInSeconds)) {
+ // we aim to through DB connections away only after 2 hours
+ $this->lastDbReset = time();
+ Db::destroyDatabaseObject();
+ Tracker::disconnectCachedDbConnection();
+ }
+ }
+
private function checkResponse($response, $url)
{
if (empty($response)