/** * Called on Core install, update, plugin enable/disable * Will clear all cache that could be affected by the change in configuration being made */ public static function deleteAllCacheOnUpdate($pluginName = false) { AssetManager::getInstance()->removeMergedAssets($pluginName); View::clearCompiledTemplates(); Cache::deleteTrackerCache(); self::clearPhpCaches(); }
public function setUp() { parent::setUp(); Fixture::createWebsite('2014-01-01 00:00:00'); Fixture::createWebsite('2014-01-01 00:00:00'); Cache::deleteTrackerCache(); $this->request = $this->buildRequest(array('idsite' => '1')); }
public function setUp() { parent::setUp(); Fixture::createWebsite('2014-01-01 00:00:00'); Fixture::createWebsite('2014-01-01 00:00:00'); Cache::deleteTrackerCache(); $_SERVER['HTTP_USER_AGENT'] = ''; }
public function setUp() { parent::setUp(); Fixture::createWebsite('2014-01-01 00:00:00'); Tracker\Cache::deleteTrackerCache(); $this->response = new Response(); $this->handler = new Handler(); $this->handler->setResponse($this->response); $this->tracker = new Tracker(); $this->requestSet = new RequestSet(); }
public function setUp() { parent::setUp(); Fixture::createWebsite('2014-01-01 00:00:00'); Fixture::createSuperUser(); Tracker\Cache::deleteTrackerCache(); $this->backend = $this->createRedisBackend(); $this->queue = Queue\Factory::makeQueueManager($this->backend); $this->response = new Response(); $this->handler = new Handler(); $this->handler->setResponse($this->response); $this->tracker = new Tracker(); $this->requestSet = new RequestSet(); }
/** * Sets list of URL query parameters to be excluded on all websites. * Will also apply to websites created in the future. * * @param string $excludedQueryParameters Comma separated list of URL query parameters to exclude from URLs * @return bool */ public function setGlobalExcludedQueryParameters($excludedQueryParameters) { Piwik::checkUserHasSuperUserAccess(); $excludedQueryParameters = $this->checkAndReturnCommaSeparatedStringList($excludedQueryParameters); Option::set(self::OPTION_EXCLUDED_QUERY_PARAMETERS_GLOBAL, $excludedQueryParameters); Cache::deleteTrackerCache(); return true; }
public static function updateDatabase($force = false) { Cache::deleteTrackerCache(); Option::clearCache(); if ($force) { // remove version options to force update Option::deleteLike('version%'); Option::set('version_core', '0.0'); } $updater = new Updater(); $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater); if (empty($componentsWithUpdateFile)) { return false; } $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile); if (!empty($result['coreError']) || !empty($result['warnings']) || !empty($result['errors'])) { throw new \Exception("Failed to update database (errors or warnings found): " . print_r($result, true)); } return $result; }
public function tearDown() { parent::tearDown(); Manager::getInstance()->deleteAll(); Option::clearCache(); Site::clearCache(); Cache::deleteTrackerCache(); ArchiveTableCreator::clear(); $tempTableName = Common::prefixTable(LogDataPurger::TEMP_TABLE_NAME); Db::query("DROP TABLE IF EXISTS " . $tempTableName); }
public static function clearCache() { Cache::deleteTrackerCache(); self::buildCache()->flushAll(); }
/** * Set an access level to a given user for a list of websites ID. * * If access = 'noaccess' the current access (if any) will be deleted. * If access = 'view' or 'admin' the current access level is deleted and updated with the new value. * * @param string $userLogin The user login * @param string $access Access to grant. Must have one of the following value : noaccess, view, admin * @param int|array $idSites The array of idSites on which to apply the access level for the user. * If the value is "all" then we apply the access level to all the websites ID for which the current authentificated user has an 'admin' access. * * @throws Exception if the user doesn't exist * @throws Exception if the access parameter doesn't have a correct value * @throws Exception if any of the given website ID doesn't exist * * @return bool true on success */ public function setUserAccess($userLogin, $access, $idSites) { $this->checkAccessType($access); $this->checkUserExists($userLogin); $this->checkUserIsNotSuperUser($userLogin); if ($userLogin == 'anonymous' && $access == 'admin') { throw new Exception(Piwik::translate("UsersManager_ExceptionAdminAnonymous")); } // in case idSites is all we grant access to all the websites on which the current connected user has an 'admin' access if ($idSites === 'all') { $idSites = \Piwik\Plugins\SitesManager\API::getInstance()->getSitesIdWithAdminAccess(); } else { $idSites = Site::getIdSitesFromIdSitesString($idSites); } if (empty($idSites)) { throw new Exception('Specify at least one website ID in &idSites='); } // it is possible to set user access on websites only for the websites admin // basically an admin can give the view or the admin access to any user for the websites he manages Piwik::checkUserHasAdminAccess($idSites); $this->deleteUserAccess($userLogin, $idSites); // delete UserAccess $db = Db::get(); // if the access is noaccess then we don't save it as this is the default value // when no access are specified if ($access != 'noaccess') { foreach ($idSites as $idsite) { $db->insert(Common::prefixTable("access"), array("idsite" => $idsite, "login" => $userLogin, "access" => $access)); } } // we reload the access list which doesn't yet take in consideration this new user access Access::getInstance()->reloadAccess(); Cache::deleteTrackerCache(); }
public static function setTestEnvironment($args = null, $requestMethod = null) { if (is_null($args)) { $requests = new Requests(); $args = $requests->getRequestsArrayFromBulkRequest($requests->getRawBulkRequest()); $args = $_GET + $args; } if (is_null($requestMethod) && array_key_exists('REQUEST_METHOD', $_SERVER)) { $requestMethod = $_SERVER['REQUEST_METHOD']; } elseif (is_null($requestMethod)) { $requestMethod = 'GET'; } // Do not run scheduled tasks during tests if (!defined('DEBUG_FORCE_SCHEDULED_TASKS')) { TrackerConfig::setConfigValue('scheduled_tasks_min_interval', 0); } // if nothing found in _GET/_POST and we're doing a POST, assume bulk request. in which case, // we have to bypass authentication if (empty($args) && $requestMethod == 'POST') { TrackerConfig::setConfigValue('tracking_requests_require_authentication', 0); } // Tests can force the use of 3rd party cookie for ID visitor if (Common::getRequestVar('forceEnableFingerprintingAcrossWebsites', false, null, $args) == 1) { TrackerConfig::setConfigValue('enable_fingerprinting_across_websites', 1); } // Tests can force the use of 3rd party cookie for ID visitor if (Common::getRequestVar('forceUseThirdPartyCookie', false, null, $args) == 1) { TrackerConfig::setConfigValue('use_third_party_id_cookie', 1); } // Tests using window_look_back_for_visitor if (Common::getRequestVar('forceLargeWindowLookBackForVisitor', false, null, $args) == 1 || strpos(json_encode($args, true), '"forceLargeWindowLookBackForVisitor":"1"') !== false) { TrackerConfig::setConfigValue('window_look_back_for_visitor', 2678400); } // Tests can force the enabling of IP anonymization if (Common::getRequestVar('forceIpAnonymization', false, null, $args) == 1) { self::getDatabase(); // make sure db is initialized $privacyConfig = new PrivacyManagerConfig(); $privacyConfig->ipAddressMaskLength = 2; \Piwik\Plugins\PrivacyManager\IPAnonymizer::activate(); \Piwik\Tracker\Cache::deleteTrackerCache(); Filesystem::clearPhpCaches(); } $pluginsDisabled = array('Provider'); // Disable provider plugin, because it is so slow to do many reverse ip lookups PluginManager::getInstance()->setTrackerPluginsNotToLoad($pluginsDisabled); }
static function update() { Cache::deleteTrackerCache(); Filesystem::clearPhpCaches(); }
public function doUpdate(Updater $updater) { Cache::deleteTrackerCache(); Filesystem::clearPhpCaches(); }
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(); }
<?php /** * Proxy to normal piwik.php, but in testing mode * * - Use the tests database to record Tracking data * - Allows to overwrite the Visitor IP, and Server datetime * */ use Piwik\DataTable\Manager; use Piwik\Option; use Piwik\Plugins\UserCountry\LocationProvider\GeoIp; use Piwik\Site; use Piwik\Tracker\Cache; use Piwik\Tracker; require realpath(dirname(__FILE__)) . "/includes.php"; // Wrapping the request inside ob_start() calls to ensure that the Test // calling us waits for the full request to process before unblocking ob_start(); Piwik_TestingEnvironment::addHooks(); GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; Tracker::setTestEnvironment(); Manager::getInstance()->deleteAll(); Option::clearCache(); Site::clearCache(); Cache::deleteTrackerCache(); include PIWIK_INCLUDE_PATH . '/piwik.php'; ob_end_flush();