public function configureReportingMenu(MenuReporting $menu) { $idSite = Common::getRequestVar('idSite', null, 'int'); $goals = API::getInstance()->getGoals($idSite); $mainGoalMenu = $this->getGoalCategoryName($idSite); $site = new Site($idSite); if (count($goals) == 0) { $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25); if ($site->isEcommerceEnabled()) { $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } $menu->add($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal')); } else { $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'index', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25); if ($site->isEcommerceEnabled()) { $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } $menu->add($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2); $group = new Group(); foreach ($goals as $goal) { $subMenuName = str_replace('%', '%%', Translate::clean($goal['name'])); $params = array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal']); $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']); if (count($goals) <= 3) { $menu->add($mainGoalMenu, $subMenuName, $params, true, 50, $tooltip); } else { $group->add($subMenuName, $params, $tooltip); } } if (count($goals) > 3) { $menu->addGroup($mainGoalMenu, 'Goals_ChooseGoal', $group, $orderId = 50, $tooltip = false); } } }
protected function execute(InputInterface $input, OutputInterface $output) { $dialog = $this->getHelperSet()->get('dialog'); $command = $this->getApplication()->find('translations:fetch'); $arguments = array('command' => 'translations:fetch', '--username' => $input->getOption('username'), '--password' => $input->getOption('password'), '--keep-english' => true); $inputObject = new ArrayInput($arguments); $inputObject->setInteractive($input->isInteractive()); $command->run($inputObject, $output); $englishFromOTrance = FetchFromOTrance::getDownloadPath() . DIRECTORY_SEPARATOR . 'en.json'; if (!file_exists($englishFromOTrance)) { $output->writeln("English file from oTrance missing. Aborting"); return; } $englishFromOTrance = json_decode(file_get_contents($englishFromOTrance), true); Translate::reloadLanguage('en'); $availableTranslations = $GLOBALS['Piwik_translations']; $categories = array_unique(array_merge(array_keys($englishFromOTrance), array_keys($availableTranslations))); sort($categories); $unnecessary = $outdated = $missing = array(); foreach ($categories as $category) { if (!empty($englishFromOTrance[$category])) { foreach ($englishFromOTrance[$category] as $key => $value) { if (!array_key_exists($category, $availableTranslations) || !array_key_exists($key, $availableTranslations[$category])) { $unnecessary[] = sprintf('%s_%s', $category, $key); continue; } else { if (html_entity_decode($availableTranslations[$category][$key]) != html_entity_decode($englishFromOTrance[$category][$key])) { $outdated[] = sprintf('%s_%s', $category, $key); continue; } } } } if (!empty($availableTranslations[$category])) { foreach ($availableTranslations[$category] as $key => $value) { if (!array_key_exists($category, $englishFromOTrance) || !array_key_exists($key, $englishFromOTrance[$category])) { $missing[] = sprintf('%s_%s', $category, $key); continue; } } } } $output->writeln(""); if (!empty($missing)) { $output->writeln("<bg=yellow;options=bold>-- Following keys are missing on oTrance --</bg=yellow;options=bold>"); $output->writeln(implode("\n", $missing)); $output->writeln(""); } if (!empty($unnecessary)) { $output->writeln("<bg=yellow;options=bold>-- Following keys might be unnecessary on oTrance --</bg=yellow;options=bold>"); $output->writeln(implode("\n", $unnecessary)); $output->writeln(""); } if (!empty($outdated)) { $output->writeln("<bg=yellow;options=bold>-- Following keys are outdated on oTrance --</bg=yellow;options=bold>"); $output->writeln(implode("\n", $outdated)); $output->writeln(""); } $output->writeln("Finished."); }
protected function completeKey($cacheKey) { $pluginManager = PluginManager::getInstance(); $pluginNames = $pluginManager->getLoadedPluginsName(); $cacheKey = $cacheKey . md5(implode('', $pluginNames)) . Translate::getLanguageLoaded(); return $cacheKey; }
/** * @group Core */ public function testGetPrettyString() { Translate::loadEnglishTranslation(); $year = new Year(Date::factory('2024-10-09')); $shouldBe = '2024'; $this->assertEquals($shouldBe, $year->getPrettyString()); }
public function init() { $__languages = array('bg', 'cz', 'de', 'en', 'es', 'fr', 'hu', 'id', 'it', 'ja', 'nl', 'pl', 'pt', 'ro', 'ru', 'sr', 'tr', 'uk', 'zh'); if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] !== '') { $realPath =& $_SERVER['REQUEST_URI']; } elseif (isset($_SERVER['SCRIPT_NAME']) && $_SERVER['SCRIPT_NAME'] !== '') { $realPath =& $_SERVER['SCRIPT_NAME']; } else { exit(LANG_UNKNOWN_DIR); } /** First of all, check if we are inside Piwik */ $dirName = dirname($realPath); if ($dirName === '/') { $dirName = ''; } define('CLICKHEAT_PATH', $dirName . '/plugins/ClickHeat/libs/'); define('CLICKHEAT_INDEX_PATH', 'index.php?module=ClickHeat&'); define('CLICKHEAT_ROOT', PIWIK_INCLUDE_PATH . '/plugins/ClickHeat/libs/'); define('CLICKHEAT_CONFIG', PIWIK_INCLUDE_PATH . '/plugins/ClickHeat/clickheat.php'); define('IS_PIWIK_MODULE', true); if (Piwik::hasUserSuperUserAccess()) { define('CLICKHEAT_ADMIN', true); } else { define('CLICKHEAT_ADMIN', false); } define('CLICKHEAT_LANGUAGE', Translate::getLanguageToLoad()); require_once CLICKHEAT_CONFIG; /** Specific definitions */ $clickheatConf['__screenSizes'] = array(0, 640, 800, 1024, 1280, 1440, 1600, 1800); $clickheatConf['__browsersList'] = array('all' => '', 'firefox' => 'Firefox', 'chrome' => 'Google Chrome', 'msie' => 'Internet Explorer', 'safari' => 'Safari', 'opera' => 'Opera', 'kmeleon' => 'K-meleon', 'unknown' => ''); self::conf($clickheatConf); }
/** * @param InputInterface $input * @param OutputInterface $output * @return array * @throws \RuntimeException */ protected function getCategory(InputInterface $input, OutputInterface $output) { $validate = function ($category) { if (empty($category)) { throw new \InvalidArgumentException('Please enter the name of the category your widget should belong to'); } return $category; }; $category = $input->getOption('category'); $categories = array(); foreach (Widgets::getAllWidgets() as $widget) { if ($widget->getCategory()) { $categories[] = Piwik::translate($widget->getCategory()); } } $categories = array_values(array_unique($categories)); if (empty($category)) { $dialog = $this->getHelperSet()->get('dialog'); $category = $dialog->askAndValidate($output, 'Enter the widget category, for instance "Visitor" (you can reuse any existing category or define a new one): ', $validate, false, null, $categories); } else { $validate($category); } $translationKey = Translate::findTranslationKeyForTranslation($category); if (!empty($translationKey)) { return $translationKey; } $category = ucfirst($category); return $category; }
public function configureReportingMenu(MenuReporting $menu) { $idSite = $this->getIdSite(); $goals = API::getInstance()->getGoals($idSite); $mainGoalMenu = 'Goals_Goals'; if (count($goals) == 0) { $linkToAddNewGoal = $this->urlForAction('addNewGoal', array('idGoal' => null)); $menu->addItem($mainGoalMenu, '', $linkToAddNewGoal, 25); $menu->addItem($mainGoalMenu, 'Goals_AddNewGoal', $linkToAddNewGoal, 1); return; } $order = 1; $url = $this->urlForAction('index', array('idGoal' => null)); $menu->addItem($mainGoalMenu, '', $url, 25); $menu->addItem($mainGoalMenu, 'General_Overview', $url, ++$order); $group = new Group(); foreach ($goals as $goal) { $subMenuName = str_replace('%', '%%', Translate::clean($goal['name'])); $params = $this->urlForAction('goalReport', array('idGoal' => $goal['idgoal'])); $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']); if (count($goals) > 3) { $group->add($subMenuName, $params, $tooltip); } else { $menu->addItem($mainGoalMenu, $subMenuName, $params, ++$order, $tooltip); } } if (count($goals) > 3) { $menu->addGroup($mainGoalMenu, 'Goals_ChooseGoal', $group, ++$order, $tooltip = false); } $menu->addItem($mainGoalMenu, 'Goals_ManageGoals', $this->urlForAction('editGoals'), ++$order); }
private function getEnglishTranslationForFeatureName($featureName) { if (Translate::getLanguageLoaded() == 'en') { return $featureName; } $translationKeyForFeature = Translate::findTranslationKeyForTranslation($featureName); return Piwik::translate($translationKeyForFeature, array(), 'en'); }
public function setUp() { parent::setUp(); StaticCache::clearAll(); PluginAwareStaticCache::clearAll(); Translate::reloadLanguage('en'); $this->api = API::getInstance(); }
public function setUp() { parent::setUp(); for ($i = 1; $i <= $this->numSitesToCreate; $i++) { Fixture::createWebsite('2012-12-12 00:00:00', $ecommerce = 0, 'Site ' . $i); } Translate::loadAllTranslations(); $this->dashboard = $this->getMockBuilder('Piwik\\Plugins\\MultiSites\\Dashboard')->setMethods(null)->disableOriginalConstructor()->getMock(); }
public function setUp() { parent::setUp(); $this->addNonLdapUsers(); $this->addPreexistingLdapUser(); $plugins = Config::getInstance()->Plugins; $plugins['Plugins'][] = 'LoginLdap'; Config::getInstance()->Plugins = $plugins; $application = new Console(self::$fixture->piwikEnvironment); $application->setAutoExit(false); $this->applicationTester = new ApplicationTester($application); Translate::loadEnglishTranslation(); // needed due to travis build that tests against minimum required piwik }
public function setUp() { parent::setUp(); $config = Config::getInstance(); $config->clear(); $config->setTestEnvironment(); $section = Config::getInstance()->Tracker; $section['default_action_url'] = '/'; $section['campaign_var_name'] = 'campaign_param_name,piwik_campaign,utm_campaign,test_campaign_name'; $section['action_url_category_delimiter'] = '/'; $section['campaign_keyword_var_name'] = 'piwik_kwd,utm_term,test_piwik_kwd'; Config::getInstance()->Tracker = $section; PluginManager::getInstance()->loadPlugins(array('SitesManager')); Translate::loadEnglishTranslation(); }
/** * Decodes all encoded entities in the given translations * * @param array $translations * * @return array filtered translations */ public function filter($translations) { foreach ($translations as $pluginName => $pluginTranslations) { foreach ($pluginTranslations as $key => $translation) { // remove encoded entities $decoded = Translate::clean($translation); if ($translation != $decoded) { $this->filteredData[$pluginName][$key] = $translation; $translations[$pluginName][$key] = $decoded; continue; } } } return $translations; }
private function getEnglishTranslationForFeatureName($featureName) { $loadedLanguage = Translate::getLanguageLoaded(); if ($loadedLanguage == 'en') { return $featureName; } $translationKeyForFeature = Translate::findTranslationKeyForTranslation($featureName); if (!empty($translationKeyForFeature)) { Translate::reloadLanguage('en'); $featureName = Piwik::translate($translationKeyForFeature); Translate::reloadLanguage($loadedLanguage); return $featureName; } return $featureName; }
/** * @param \Exception|null $exception */ public function dispatch($exception = null) { if ($exception) { $message = $exception->getMessage(); } else { $message = ''; } Translate::loadCoreTranslation(); $action = Common::getRequestVar('action', 'welcome', 'string'); if ($this->isAllowedAction($action)) { echo FrontController::getInstance()->dispatch('Installation', $action, array($message)); } else { Piwik::exitWithErrorMessage(Piwik::translate('Installation_NoConfigFound')); } exit; }
public function testExecute_ShouldReturnLogAfterWorkingWithSomeData() { $result = $this->executeCommand('2010-01-03,2010-06-03'); $this->assertContains('Re-attribution for date range: 2010-01-03 to 2010-06-03. 35 visits to process with provider "geoip_php".', $result); $this->assertRegExp('/100% processed. Time elapsed: [0-9.]+s/', $result); $queryParams = array('idSite' => self::$fixture->idSite, 'date' => self::$fixture->dateTime, 'period' => 'month'); // we need to manually reload the translations since they get reset for some reason in IntegrationTestCase::tearDown(); // if we do not load translations, a DataTable\Map containing multiple periods will contain only one DataTable having // the label `General_DateRangeFromTo` instead of many like `From 2010-01-04 to 2010-01-11`, ' `From 2010-01-11 to 2010-01-18` // As those data tables would all have the same prettyfied period label they would overwrite each other. Translate::loadAllTranslations(); $this->assertApiResponseEqualsExpected("UserCountry.getCountry", $queryParams); $this->assertApiResponseEqualsExpected("UserCountry.getContinent", $queryParams); $this->assertApiResponseEqualsExpected("UserCountry.getRegion", $queryParams); $this->assertApiResponseEqualsExpected("UserCountry.getCity", $queryParams); }
/** * @param \Exception|null $exception */ public function dispatch($exception = null) { if ($exception) { $message = $exception->getMessage(); } else { $message = ''; } Translate::loadCoreTranslation(); $step = Common::getRequestVar('action', 'welcome', 'string'); $controller = $this->getInstallationController(); $isActionWhiteListed = in_array($step, array('saveLanguage', 'getBaseCss')); if (in_array($step, array_keys($controller->getInstallationSteps())) || $isActionWhiteListed) { echo FrontController::getInstance()->dispatch('Installation', $step, array($message)); } else { Piwik::exitWithErrorMessage(Piwik::translate('Installation_NoConfigFound')); } exit; }
public function doRun(InputInterface $input, OutputInterface $output) { $this->initPiwikHost($input); $this->initConfig($output); try { self::initPlugins(); } catch (\Exception $e) { // Piwik not installed yet, no config file? } Translate::reloadLanguage('en'); $commands = $this->getAvailableCommands(); foreach ($commands as $command) { $this->addCommandIfExists($command); } $self = $this; return Access::doAsSuperUser(function () use($input, $output, $self) { return call_user_func(array($self, 'Symfony\\Component\\Console\\Application::doRun'), $input, $output); }); }
public function doRun(InputInterface $input, OutputInterface $output) { $this->initPiwikHost($input); $this->initConfig($output); try { self::initPlugins(); } catch (\Exception $e) { // Piwik not installed yet, no config file? } Translate::reloadLanguage('en'); $commands = $this->getAvailableCommands(); foreach ($commands as $command) { if (!class_exists($command)) { Log::warning(sprintf('Cannot add command %s, class does not exist', $command)); } elseif (!is_subclass_of($command, 'Piwik\\Plugin\\ConsoleCommand')) { Log::warning(sprintf('Cannot add command %s, class does not extend Piwik\\Plugin\\ConsoleCommand', $command)); } else { $this->add(new $command()); } } return parent::doRun($input, $output); }
public function configureReportingMenu(MenuReporting $menu) { $idSite = Common::getRequestVar('idSite', null, 'int'); $goals = API::getInstance()->getGoals($idSite); $mainGoalMenu = $this->getGoalCategoryName($idSite); $site = new Site($idSite); if (count($goals) == 0) { $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25); if ($site->isEcommerceEnabled()) { $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } $menu->add($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal')); } else { $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'index', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25); if ($site->isEcommerceEnabled()) { $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } $menu->add($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2); foreach ($goals as $goal) { $menu->add($mainGoalMenu, str_replace('%', '%%', Translate::clean($goal['name'])), array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal'])); } } }
/** * Return JS file inclusion directive(s) using the markup <script> * * @return string */ public function getJsInclusionDirective() { $result = "<script type=\"text/javascript\">\n" . Translate::getJavascriptTranslations() . "\n</script>"; if ($this->isMergedAssetsDisabled()) { $this->getMergedCoreJSAsset()->delete(); $this->getMergedNonCoreJSAsset()->delete(); $result .= $this->getIndividualCoreAndNonCoreJsIncludes(); } else { $result .= sprintf(self::JS_IMPORT_DIRECTIVE, self::GET_CORE_JS_MODULE_ACTION); $result .= sprintf(self::JS_IMPORT_DIRECTIVE, self::GET_NON_CORE_JS_MODULE_ACTION); } return $result; }
/** * Tracker requests will automatically trigger the Scheduled tasks. * This is useful for users who don't setup the cron, * but still want daily/weekly/monthly PDF reports emailed automatically. * * This is similar to calling the API CoreAdminHome.runScheduledTasks */ protected static function runScheduledTasks() { $now = time(); // Currently, there are no hourly tasks. When there are some, // this could be too aggressive minimum interval (some hours would be skipped in case of low traffic) $minimumInterval = Config::getInstance()->Tracker['scheduled_tasks_min_interval']; // If the user disabled browser archiving, he has already setup a cron // To avoid parallel requests triggering the Scheduled Tasks, // Get last time tasks started executing $cache = Cache::getCacheGeneral(); if ($minimumInterval <= 0 || empty($cache['isBrowserTriggerEnabled'])) { Common::printDebug("-> Scheduled tasks not running in Tracker: Browser archiving is disabled."); return; } $nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval; if (isset($GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) && $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] || $cache['lastTrackerCronRun'] === false || $nextRunTime < $now) { $cache['lastTrackerCronRun'] = $now; Cache::setCacheGeneral($cache); self::initCorePiwikInTrackerMode(); Option::set('lastTrackerCronRun', $cache['lastTrackerCronRun']); Common::printDebug('-> Scheduled Tasks: Starting...'); // save current user privilege and temporarily assume Super User privilege $isSuperUser = Piwik::hasUserSuperUserAccess(); // Scheduled tasks assume Super User is running Piwik::setUserHasSuperUserAccess(); // While each plugins should ensure that necessary languages are loaded, // we ensure English translations at least are loaded Translate::loadEnglishTranslation(); ob_start(); CronArchive::$url = SettingsPiwik::getPiwikUrl(); $cronArchive = new CronArchive(); $cronArchive->runScheduledTasksInTrackerMode(); $resultTasks = ob_get_contents(); ob_clean(); // restore original user privilege Piwik::setUserHasSuperUserAccess($isSuperUser); foreach (explode('</pre>', $resultTasks) as $resultTask) { Common::printDebug(str_replace('<pre>', '', $resultTask)); } Common::printDebug('Finished Scheduled Tasks.'); } else { Common::printDebug("-> Scheduled tasks not triggered."); } Common::printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC'); }
/** * changing the language within one request is a bit fancy * in order to keep the core clean, we need a little hack here * * @param string $langId */ protected function changeLanguage($langId) { if ($this->lastLanguage != $langId) { $_GET['language'] = $langId; Translate::reset(); Translate::reloadLanguage($langId); } $this->lastLanguage = $langId; }
private function loadEnglishTranslation() { Translate::reloadLanguage('en'); }
/** * @return string Two letters language code, eg. "fr" */ public static function getLanguageCodeForCurrentUser() { $languageCode = self::getLanguageFromPreferences(); if (!API::getInstance()->isLanguageAvailable($languageCode)) { $languageCode = Common::extractLanguageCodeFromBrowserLanguage(Common::getBrowserLanguage(), API::getInstance()->getAvailableLanguages()); } if (!API::getInstance()->isLanguageAvailable($languageCode)) { $languageCode = Translate::getLanguageDefault(); } return $languageCode; }
/** * @group Core */ public function testIsDefined() { // setup the access layer $pseudoMockAccess = new FakeAccess(); FakeAccess::$superUser = true; Access::setSingletonInstance($pseudoMockAccess); \Piwik\Translate::loadEnglishTranslation(); Fixture::createWebsite('2009-01-04 00:11:42', true); $_GET['idSite'] = 1; WidgetsList::_reset(); WidgetsList::add('Actions', 'Pages', 'Actions', 'getPageUrls'); $this->assertTrue(WidgetsList::isDefined('Actions', 'getPageUrls')); $this->assertFalse(WidgetsList::isDefined('Actions', 'inValiD')); }
protected function setup() { parent::setup(); Translate::reloadLanguage('en'); }
/** * Load translation * * @param Plugin $plugin * @param string $langCode * @throws \Exception * @return bool whether the translation was found and loaded */ private function loadTranslation($plugin, $langCode) { // we are in Tracker mode if Loader is not (yet) loaded if (SettingsServer::isTrackerApiRequest()) { return false; } if (is_string($plugin)) { $pluginName = $plugin; } else { $pluginName = $plugin->getPluginName(); } $path = self::getPluginsDirectory() . $pluginName . '/lang/%s.json'; $defaultLangPath = sprintf($path, $langCode); $defaultEnglishLangPath = sprintf($path, 'en'); $translationsLoaded = false; // merge in english translations as default first if (file_exists($defaultEnglishLangPath)) { $translations = $this->getTranslationsFromFile($defaultEnglishLangPath); $translationsLoaded = true; if (isset($translations[$pluginName])) { // only merge translations of plugin - prevents overwritten strings Translate::mergeTranslationArray(array($pluginName => $translations[$pluginName])); } } // merge in specific language translations (to overwrite english defaults) if (!empty($langCode) && $defaultEnglishLangPath != $defaultLangPath && file_exists($defaultLangPath)) { $translations = $this->getTranslationsFromFile($defaultLangPath); $translationsLoaded = true; if (isset($translations[$pluginName])) { // only merge translations of plugin - prevents overwritten strings Translate::mergeTranslationArray(array($pluginName => $translations[$pluginName])); } } return $translationsLoaded; }
public function performTearDown() { // Note: avoid run SQL in the *tearDown() metohds because it randomly fails on Travis CI // with error Error while sending QUERY packet. PID=XX $this->tearDown(); self::unloadAllPlugins(); if ($this->dropDatabaseInTearDown) { $this->dropDatabase(); } DataTableManager::getInstance()->deleteAll(); Option::clearCache(); Site::clearCache(); Cache::deleteTrackerCache(); Config::getInstance()->clear(); ArchiveTableCreator::clear(); \Piwik\Plugins\ScheduledReports\API::$cache = array(); \Piwik\Registry::unsetInstance(); \Piwik\EventDispatcher::getInstance()->clearAllObservers(); $_GET = $_REQUEST = array(); Translate::unloadEnglishTranslation(); Config::unsetInstance(); \Piwik\Config::getInstance()->Plugins; // make sure Plugins exists in a config object for next tests that use Plugin\Manager // since Plugin\Manager uses getFromGlobalConfig which doesn't init the config object }
public function clearInMemoryCaches() { Archive::clearStaticCache(); DataTableManager::getInstance()->deleteAll(); Option::clearCache(); Site::clearCache(); Cache::deleteTrackerCache(); PiwikCache::getTransientCache()->flushAll(); PiwikCache::getEagerCache()->flushAll(); PiwikCache::getLazyCache()->flushAll(); ArchiveTableCreator::clear(); \Piwik\Plugins\ScheduledReports\API::$cache = array(); Singleton::clearAll(); PluginsArchiver::$archivers = array(); $_GET = $_REQUEST = array(); Translate::reset(); self::getConfig()->Plugins; // make sure Plugins exists in a config object for next tests that use Plugin\Manager // since Plugin\Manager uses getFromGlobalConfig which doesn't init the config object }