diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-01-16 03:26:34 +0300 |
---|---|---|
committer | Thomas Steur <tsteur@users.noreply.github.com> | 2020-01-16 03:26:34 +0300 |
commit | 7c059ecb5e433dec3538398c8413c45cd68a0c0b (patch) | |
tree | 026af3bafbd20f69b1aca757151c1d51a3bdfcd6 | |
parent | 8e2db8e1206e6778f3198558b05c25d655fc99e6 (diff) |
Removes some methods deprecated for Matomo 4 (#15386)
* Removes deprecated Plugin.getListHooksRegistered and uses Plugin.registerEvents instead
* Removes deprecated method Piwik\Piwik::doAsSuperUser
* Remove deprecated SettingsPiwik::isPiwikInstalled and use SettingsPiwik::isMatomoInstalled instead
25 files changed, 32 insertions, 64 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index cf64cd0360..3d97c635d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)* * Deprecated `piwik` font was removed. Use `matomo` font instead * The JavaScript AjaxHelper does not longer support synchronous requests. All requests will be sent async instead. +* The deprecated Platform API method `\Piwik\Plugin::getListHooksRegistered()` has been removed. Use `\Piwik\Plugin::registerEvents()` instead +* The deprecated Platform API method `\Piwik\Piwik::doAsSuperUser()` has been removed. Use `\Piwik\Access::doAsSuperUser()` instead +* The deprecated Platform API method `\Piwik\SettingsPiwik::isPiwikInstalled()` has been removed. Use `\Piwik\SettingsPiwik::isMatomoInstalled()` instead ## Matomo 3.13.1 diff --git a/config/global.php b/config/global.php index 5499b0920a..189a2cdf77 100644 --- a/config/global.php +++ b/config/global.php @@ -56,7 +56,7 @@ return array( // If Piwik is not installed yet, it's possible the tmp/ folder is not writable // we prevent failing with an unclear message eg. coming from doctrine-cache // by forcing to use a cache backend which always works ie. array - if(!\Piwik\SettingsPiwik::isPiwikInstalled()) { + if(!\Piwik\SettingsPiwik::isMatomoInstalled()) { $backend = 'array'; } else { try { diff --git a/core/Application/Kernel/EnvironmentValidator.php b/core/Application/Kernel/EnvironmentValidator.php index 3a526a8c5c..5ab514fadf 100644 --- a/core/Application/Kernel/EnvironmentValidator.php +++ b/core/Application/Kernel/EnvironmentValidator.php @@ -44,7 +44,7 @@ class EnvironmentValidator { $this->checkConfigFileExists($this->settingsProvider->getPathGlobal()); - if(SettingsPiwik::isPiwikInstalled()) { + if(SettingsPiwik::isMatomoInstalled()) { $this->checkConfigFileExists($this->settingsProvider->getPathLocal(), $startInstaller = false); return; } diff --git a/core/EventDispatcher.php b/core/EventDispatcher.php index 260942baf5..e80c9aff5d 100644 --- a/core/EventDispatcher.php +++ b/core/EventDispatcher.php @@ -107,7 +107,7 @@ class EventDispatcher if (!isset($this->pluginHooks[$pluginName])) { $plugin = $manager->getLoadedPlugin($pluginName); - $this->pluginHooks[$pluginName] = $plugin->getListHooksRegistered(); + $this->pluginHooks[$pluginName] = $plugin->registerEvents(); } $hooks = $this->pluginHooks[$pluginName]; diff --git a/core/FrontController.php b/core/FrontController.php index 9827cca5eb..8a81006e9a 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -652,7 +652,7 @@ class FrontController extends Singleton // the session must be started before using the session authenticator, // so we do it here, if this is not an API request. - if (SettingsPiwik::isPiwikInstalled() + if (SettingsPiwik::isMatomoInstalled() && ($module !== 'API' || ($action && $action !== 'index')) ) { /** diff --git a/core/Piwik.php b/core/Piwik.php index 1768b8219d..bf98a9df9b 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -819,19 +819,4 @@ class Piwik return $translator->translate($translationId, $args, $language); } - - /** - * Executes a callback with superuser privileges, making sure those privileges are rescinded - * before this method exits. Privileges will be rescinded even if an exception is thrown. - * - * @param callback $function The callback to execute. Should accept no arguments. - * @return mixed The result of `$function`. - * @throws Exception rethrows any exceptions thrown by `$function`. - * @api - * @deprecated since Matomo 3.8.0 use `Piwik\Access::doAsSuperUser` instead - */ - public static function doAsSuperUser($function) - { - return Access::doAsSuperUser($function); - } } diff --git a/core/Plugin.php b/core/Plugin.php index a3187bf70f..09a3ab98df 100644 --- a/core/Plugin.php +++ b/core/Plugin.php @@ -223,16 +223,6 @@ class Plugin } /** - * @ignore - * @deprecated since 2.15.0 use {@link registerEvents()} instead. - * @return array - */ - public function getListHooksRegistered() - { - return $this->registerEvents(); - } - - /** * This method is executed after a plugin is loaded and translations are registered. * Useful for initialization code that uses translated strings. */ diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 532aad9639..c10f5a189b 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -1389,7 +1389,7 @@ class Manager return true; } - $hooks = $plugin->getListHooksRegistered(); + $hooks = $plugin->registerEvents(); $hookNames = array_keys($hooks); foreach ($hookNames as $name) { if (strpos($name, self::TRACKER_EVENT_PREFIX) === 0) { diff --git a/core/Session.php b/core/Session.php index 683c3e0410..5a450ec6f4 100644 --- a/core/Session.php +++ b/core/Session.php @@ -91,7 +91,7 @@ class Session extends Zend_Session $currentSaveHandler = ini_get('session.save_handler'); - if (!SettingsPiwik::isPiwikInstalled()) { + if (!SettingsPiwik::isMatomoInstalled()) { // Note: this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files // for "files", use our own folder to prevent local session file hijacking @@ -143,7 +143,7 @@ class Session extends Zend_Session 'ignoreInScreenWriter' => true, ]); - if (SettingsPiwik::isPiwikInstalled()) { + if (SettingsPiwik::isMatomoInstalled()) { $pathToSessions = ''; } else { $pathToSessions = Filechecks::getErrorMessageMissingPermissions(self::getSessionsDirectory()); diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php index 9be5fdf119..9e54807e9f 100644 --- a/core/SettingsPiwik.php +++ b/core/SettingsPiwik.php @@ -216,21 +216,10 @@ class SettingsPiwik } /** - * @see SettingsPiwik::isPiwikInstalled * @return bool */ public static function isMatomoInstalled() { - return self::isPiwikInstalled(); - } - - /** - * Return true if Piwik is installed (installation is done). - * @deprecated since Matomo 3.8.0, please use {@link isMatomoInstalled()} instead. - * @return bool - */ - public static function isPiwikInstalled() - { $config = Config::getInstance()->getLocalPath(); $exists = file_exists($config); @@ -474,7 +463,7 @@ class SettingsPiwik public static function getPiwikInstanceId() { // until Piwik is installed, we use hostname as instance_id - if (!self::isPiwikInstalled() + if (!self::isMatomoInstalled() && Common::isPhpCliMode()) { // enterprise:install use case return Config::getHostname(); @@ -507,7 +496,7 @@ class SettingsPiwik */ public static function isHttpsForced() { - if (!SettingsPiwik::isPiwikInstalled()) { + if (!SettingsPiwik::isMatomoInstalled()) { // Only enable this feature after Piwik is already installed return false; } diff --git a/core/Tracker.php b/core/Tracker.php index 6c95a9ddbe..640a898346 100644 --- a/core/Tracker.php +++ b/core/Tracker.php @@ -97,7 +97,7 @@ class Tracker public function isInstalled() { if (is_null($this->isInstalled)) { - $this->isInstalled = SettingsPiwik::isPiwikInstalled(); + $this->isInstalled = SettingsPiwik::isMatomoInstalled(); } return $this->isInstalled; diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php index 4d8c4a0e16..9d5db72985 100644 --- a/plugins/CorePluginsAdmin/Controller.php +++ b/plugins/CorePluginsAdmin/Controller.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\CorePluginsAdmin; use Exception; +use Piwik\Access; use Piwik\API\Request; use Piwik\Common; use Piwik\Container\StaticContainer; @@ -483,7 +484,7 @@ class Controller extends Plugin\ControllerAdmin public function deactivate($redirectAfter = true) { if($this->isAllowedToTroubleshootAsSuperUser()) { - Piwik::doAsSuperUser(function() use ($redirectAfter) { + Access::doAsSuperUser(function() use ($redirectAfter) { $this->doDeactivatePlugin($redirectAfter); }); } else { diff --git a/plugins/CustomPiwikJs/CustomPiwikJs.php b/plugins/CustomPiwikJs/CustomPiwikJs.php index 1dcb0c4c65..1be7831212 100644 --- a/plugins/CustomPiwikJs/CustomPiwikJs.php +++ b/plugins/CustomPiwikJs/CustomPiwikJs.php @@ -14,7 +14,7 @@ use Piwik\Plugin; class CustomPiwikJs extends Plugin { - public function getListHooksRegistered() + public function registerEvents() { return array( 'CoreUpdater.update.end' => 'updateTracker', diff --git a/plugins/Diagnostics/Diagnostic/DbMaxPacket.php b/plugins/Diagnostics/Diagnostic/DbMaxPacket.php index 91745db88d..a771ba564d 100644 --- a/plugins/Diagnostics/Diagnostic/DbMaxPacket.php +++ b/plugins/Diagnostics/Diagnostic/DbMaxPacket.php @@ -27,7 +27,7 @@ class DbMaxPacket implements Diagnostic public function execute() { - if (!SettingsPiwik::isPiwikInstalled()) { + if (!SettingsPiwik::isMatomoInstalled()) { return array(); // only possible to perform check once we have DB connection } diff --git a/plugins/ExampleTheme/ExampleTheme.php b/plugins/ExampleTheme/ExampleTheme.php index a391f0daca..e39c69b955 100644 --- a/plugins/ExampleTheme/ExampleTheme.php +++ b/plugins/ExampleTheme/ExampleTheme.php @@ -13,7 +13,7 @@ use Piwik\Plugin; class ExampleTheme extends Plugin { - public function getListHooksRegistered() + public function registerEvents() { return [ 'Theme.configureThemeVariables' => 'configureThemeVariables', diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index 0392f96b5e..27ba28e91a 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -619,7 +619,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin private function checkPiwikIsNotInstalled($possibleErrorMessage = null) { - if (!SettingsPiwik::isPiwikInstalled()) { + if (!SettingsPiwik::isMatomoInstalled()) { return; } diff --git a/plugins/Installation/Installation.php b/plugins/Installation/Installation.php index 5bd24575a4..a889d81037 100644 --- a/plugins/Installation/Installation.php +++ b/plugins/Installation/Installation.php @@ -64,7 +64,7 @@ class Installation extends \Piwik\Plugin { $general = Config::getInstance()->General; - if (!SettingsPiwik::isPiwikInstalled() && !$general['enable_installer']) { + if (!SettingsPiwik::isMatomoInstalled() && !$general['enable_installer']) { throw new NotYetInstalledException('Matomo is not set up yet'); } diff --git a/plugins/Intl/Intl.php b/plugins/Intl/Intl.php index 8f44e8d06a..5d14304b5f 100644 --- a/plugins/Intl/Intl.php +++ b/plugins/Intl/Intl.php @@ -10,7 +10,7 @@ namespace Piwik\Plugins\Intl; class Intl extends \Piwik\Plugin { - public function getListHooksRegistered() + public function registerEvents() { return [ 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys', diff --git a/plugins/LanguagesManager/Menu.php b/plugins/LanguagesManager/Menu.php index a5707b0a08..f3a2e8449a 100644 --- a/plugins/LanguagesManager/Menu.php +++ b/plugins/LanguagesManager/Menu.php @@ -18,7 +18,7 @@ class Menu extends \Piwik\Plugin\Menu { public function configureTopMenu(MenuTop $menu) { - if (Piwik::isUserIsAnonymous() || !SettingsPiwik::isPiwikInstalled()) { + if (Piwik::isUserIsAnonymous() || !SettingsPiwik::isMatomoInstalled()) { $langManager = new LanguagesManager(); $menu->addHtml('LanguageSelector', $langManager->getLanguagesSelector(), true, $order = 30, false); } diff --git a/plugins/Login/config/test.php b/plugins/Login/config/test.php index cf83aaabdb..30717d24d5 100644 --- a/plugins/Login/config/test.php +++ b/plugins/Login/config/test.php @@ -6,7 +6,7 @@ return array( \Piwik\Access::doAsSuperUser(function () use ($settings, $c) { if ($c->get('test.vars.bruteForceBlockIps')) { $settings->blacklistedBruteForceIps->setValue(array('10.2.3.4')); - } elseif (\Piwik\SettingsPiwik::isPiwikInstalled()) { + } elseif (\Piwik\SettingsPiwik::isMatomoInstalled()) { $settings->blacklistedBruteForceIps->setValue(array()); } }); @@ -26,7 +26,7 @@ return array( // we block this IP $detection->addFailedAttempt(\Piwik\IP::getIpFromHeader()); } - } elseif (\Piwik\SettingsPiwik::isPiwikInstalled()) { + } elseif (\Piwik\SettingsPiwik::isMatomoInstalled()) { // prevent tests from blocking other tests $detection->deleteAll(); } diff --git a/plugins/TwoFactorAuth/TwoFactorAuth.php b/plugins/TwoFactorAuth/TwoFactorAuth.php index fe1c3f465f..9b86925b36 100644 --- a/plugins/TwoFactorAuth/TwoFactorAuth.php +++ b/plugins/TwoFactorAuth/TwoFactorAuth.php @@ -109,7 +109,7 @@ class TwoFactorAuth extends \Piwik\Plugin public function onApiGetTokenAuth($returnedValue, $params) { - if (!SettingsPiwik::isPiwikInstalled()) { + if (!SettingsPiwik::isMatomoInstalled()) { return; } diff --git a/plugins/TwoFactorAuth/Validator.php b/plugins/TwoFactorAuth/Validator.php index 77b4bb2714..382ad5f99c 100644 --- a/plugins/TwoFactorAuth/Validator.php +++ b/plugins/TwoFactorAuth/Validator.php @@ -34,7 +34,7 @@ class Validator return false; } - if (!SettingsPiwik::isPiwikInstalled()) { + if (!SettingsPiwik::isMatomoInstalled()) { return false; } @@ -45,7 +45,7 @@ class Validator { Piwik::checkUserIsNotAnonymous(); - if (!SettingsPiwik::isPiwikInstalled()) { + if (!SettingsPiwik::isMatomoInstalled()) { throw new NotYetInstalledException('Matomo is not set up yet'); } } diff --git a/plugins/TwoFactorAuth/config/test.php b/plugins/TwoFactorAuth/config/test.php index 7023790fe4..617eb132cd 100644 --- a/plugins/TwoFactorAuth/config/test.php +++ b/plugins/TwoFactorAuth/config/test.php @@ -6,7 +6,7 @@ return array( 'Piwik\Plugins\TwoFactorAuth\TwoFactorAuthentication' => DI\decorate(function ($previous) { /** @var Piwik\Plugins\TwoFactorAuth\TwoFactorAuthentication $previous */ - if (!\Piwik\SettingsPiwik::isPiwikInstalled()) { + if (!\Piwik\SettingsPiwik::isMatomoInstalled()) { return $previous; } @@ -30,7 +30,7 @@ return array( 'Piwik\Plugins\TwoFactorAuth\Dao\RecoveryCodeDao' => DI\decorate(function ($previous) { /** @var Piwik\Plugins\TwoFactorAuth\Dao\RecoveryCodeDao $previous */ - if (!\Piwik\SettingsPiwik::isPiwikInstalled()) { + if (!\Piwik\SettingsPiwik::isMatomoInstalled()) { return $previous; } @@ -47,7 +47,7 @@ return array( }), 'Piwik\Plugins\TwoFactorAuth\SystemSettings' => DI\decorate(function ($previous) { /** @var Piwik\Plugins\TwoFactorAuth\SystemSettings $previous */ - if (!\Piwik\SettingsPiwik::isPiwikInstalled()) { + if (!\Piwik\SettingsPiwik::isMatomoInstalled()) { return $previous; } diff --git a/tests/PHPUnit/Integration/Plugin/ManagerTest.php b/tests/PHPUnit/Integration/Plugin/ManagerTest.php index a8ab5c71b9..d785f0f176 100644 --- a/tests/PHPUnit/Integration/Plugin/ManagerTest.php +++ b/tests/PHPUnit/Integration/Plugin/ManagerTest.php @@ -91,7 +91,7 @@ class ManagerTest extends IntegrationTestCase public function test_ListenNotToControllerMethodEventsThatDoesNotExists() { foreach ($this->manager->getLoadedPlugins() as $plugin) { - $hooks = $plugin->getListHooksRegistered(); + $hooks = $plugin->registerEvents(); foreach ($hooks as $hook => $callback) { if (0 === strpos($hook, 'Controller.')) { list($controller, $module, $action) = explode('.', $hook); diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php index 1fae5acbf9..8aa0f0a842 100644 --- a/tests/PHPUnit/bootstrap.php +++ b/tests/PHPUnit/bootstrap.php @@ -127,7 +127,7 @@ function prepareTestDatabaseConfig(Config $config) $config->forceSave(); } -if (!SettingsPiwik::isPiwikInstalled()) { +if (!SettingsPiwik::isMatomoInstalled()) { throw new Exception('Piwik needs to be installed in order to run the tests'); } |