diff --git a/core/Archive.php b/core/Archive.php index 5178718e732ed1c3d75000b554a2afb8a7ad79bb..161afb33ba1fe978aced644dc6e0dc587348779e 100644 --- a/core/Archive.php +++ b/core/Archive.php @@ -933,4 +933,12 @@ class Archive return $idArchivesByMonth; } + + /** + * @internal + */ + public static function clearStaticCache() + { + self::$cache = null; + } } diff --git a/misc/cron/archive.php b/misc/cron/archive.php index 2f0d97a523ffdd297a1167c823ca428dc5d794aa..a1923e01e489b890ec2368b4aebada0ecfd35bbc 100644 --- a/misc/cron/archive.php +++ b/misc/cron/archive.php @@ -64,14 +64,17 @@ if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) { if (Piwik\Common::isPhpCliMode()) { // We can run the archive in CLI with `php-cgi` so we have to configure the container/logger // just like for CLI - $container = new \Piwik\Application\Environment('cli'); - $container->init(); + $environment = new \Piwik\Application\Environment('cli'); + $environment->init(); /** @var ConsoleHandler $consoleLogHandler */ $consoleLogHandler = StaticContainer::get('Symfony\Bridge\Monolog\Handler\ConsoleHandler'); $consoleLogHandler->setOutput(new ConsoleOutput(OutputInterface::VERBOSITY_VERBOSE)); } else { // HTTP request: logs needs to be dumped in the HTTP response (on top of existing log destinations) + $environment = new \Piwik\Application\Environment(null); + $environment->init(); + /** @var \Monolog\Logger $logger */ $logger = StaticContainer::get('Psr\Log\LoggerInterface'); $handler = new StreamHandler('php://output', Logger::INFO); diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index c9f6ba2f9d9343f86b9d8169b8c80980eb64d773..04d63cdce9b9a009d5b174487a405c7305f9a924 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -10,6 +10,7 @@ namespace Piwik\Tests\Framework; use Piwik\Access; use Piwik\Application\Environment; use Piwik\Application\Kernel\GlobalSettingsProvider\IniSettingsProvider; +use Piwik\Archive; use Piwik\Cache\Backend\File; use Piwik\Cache as PiwikCache; use Piwik\Common; @@ -311,6 +312,7 @@ class Fixture extends \PHPUnit_Framework_Assert public function clearInMemoryCaches() { + Archive::clearStaticCache(); DataTableManager::getInstance()->deleteAll(); Option::clearCache(); Site::clearCache(); diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php index 9cbc606a1f8e8bce1125ec80b54929b25aae1a16..4ab45a24fc2478caac73de468af8a0846c78c9aa 100755 --- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php +++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php @@ -26,22 +26,23 @@ class TwoVisitsWithCustomVariablesSegmentMatchNONETest extends SystemTestCase */ public function testApi($api, $params) { + if (!array_key_exists('segment', $params)) { + $params['segment'] = $this->getSegmentToTest(); // this method can access the DB, so we get it here instead of the data provider + } + $this->runApiTests($api, $params); } public function getApiForTesting() { // we will test all segments from all plugins - Fixture::loadAllPlugins(); - $apiToCall = array('VisitsSummary.get', 'CustomVariables.getCustomVariables'); return array( array($apiToCall, array('idSite' => 'all', 'date' => self::$fixture->dateTime, 'periods' => array('day', 'week'), - 'setDateLastN' => true, - 'segment' => $this->getSegmentToTest())) + 'setDateLastN' => true)) ); }