From b6473579fd9de9d9860c62b1644b155370ca729e Mon Sep 17 00:00:00 2001 From: mattab Date: Mon, 3 Mar 2014 14:50:59 +1300 Subject: [PATCH] Refs #4357 Not fully working, so reverting --- core/ArchiveProcessor/PluginsArchiver.php | 2 +- core/EventDispatcher.php | 2 +- core/Plugin/Manager.php | 16 ++-------------- tests/LocalTracker.php | 2 +- tests/PHPUnit/Core/TaskSchedulerTest.php | 8 ++++---- tests/PHPUnit/DatabaseTestCase.php | 1 + .../Integration/Plugins/MobileMessagingTest.php | 4 ++-- .../Integration/Plugins/ScheduledReportsTest.php | 4 ++-- 8 files changed, 14 insertions(+), 25 deletions(-) diff --git a/core/ArchiveProcessor/PluginsArchiver.php b/core/ArchiveProcessor/PluginsArchiver.php index 56096079ea9..cfccad3583d 100644 --- a/core/ArchiveProcessor/PluginsArchiver.php +++ b/core/ArchiveProcessor/PluginsArchiver.php @@ -121,7 +121,7 @@ public function finalizeArchive() protected function getPluginArchivers() { if (empty(static::$archivers)) { - $pluginNames = \Piwik\Plugin\Manager::getInstance()->getActivatedAndLoadedPlugins(); + $pluginNames = \Piwik\Plugin\Manager::getInstance()->getActivatedPlugins(); $archivers = array(); foreach ($pluginNames as $pluginName) { $archivers[$pluginName] = self::getPluginArchiverClass($pluginName); diff --git a/core/EventDispatcher.php b/core/EventDispatcher.php index ba6365d9f26..b884505177b 100644 --- a/core/EventDispatcher.php +++ b/core/EventDispatcher.php @@ -64,7 +64,7 @@ public function postEvent($eventName, $params, $pending = false, $plugins = null } if (empty($plugins)) { - $plugins = \Piwik\Plugin\Manager::getInstance()->getActivatedAndLoadedPlugins(); + $plugins = \Piwik\Plugin\Manager::getInstance()->getLoadedPlugins(); } $callbacks = array(); diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index ed7a80297a4..df7b3e73479 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -637,21 +637,9 @@ public function getLoadedPlugins() * * @return string[] */ - public function getActivatedAndLoadedPlugins() + public function getActivatedPlugins() { - $activatedPlugins = $this->pluginsToLoad; - - $plugins = array(); - foreach ($activatedPlugins as $activatedPlugin) { - - if ($activatedPlugin - && $this->isPluginLoaded($activatedPlugin)) { - - $plugins[] = $activatedPlugin; - } - } - - return $plugins; + return $this->pluginsToLoad; } /** diff --git a/tests/LocalTracker.php b/tests/LocalTracker.php index 3bd3d831ad2..d8ca29ea440 100755 --- a/tests/LocalTracker.php +++ b/tests/LocalTracker.php @@ -55,7 +55,7 @@ protected function sendRequest($url, $method = 'GET', $data = null, $force = fal $pluginsTracker = Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; $oldTrackerConfig = Config::getInstance()->Tracker; - //\Piwik\Plugin\Manager::getInstance()->unloadPlugins(); + \Piwik\Plugin\Manager::getInstance()->unloadPlugins(); // modify config $GLOBALS['PIWIK_TRACKER_MODE'] = true; diff --git a/tests/PHPUnit/Core/TaskSchedulerTest.php b/tests/PHPUnit/Core/TaskSchedulerTest.php index 4a47071bafa..c6f937a6c3f 100644 --- a/tests/PHPUnit/Core/TaskSchedulerTest.php +++ b/tests/PHPUnit/Core/TaskSchedulerTest.php @@ -280,10 +280,6 @@ public function testRunTasks($expectedTimetable, $expectedExecutedTasks, $timeta $plugins = \Piwik\Plugin\Manager::getInstance()->getLoadedPlugins(); $plugins = array_map(function ($p) { return $p->getPluginName(); }, $plugins); - // stub the piwik option object to control the returned option value - self::stubPiwikOption(serialize($timetableBeforeTaskExecution)); - TaskScheduler::unsetInstance(); - \Piwik\Plugin\Manager::getInstance()->unloadPlugins(); // make sure the get tasks event returns our configured tasks @@ -291,6 +287,10 @@ public function testRunTasks($expectedTimetable, $expectedExecutedTasks, $timeta $tasks = $configuredTasks; }); + // stub the piwik option object to control the returned option value + self::stubPiwikOption(serialize($timetableBeforeTaskExecution)); + TaskScheduler::unsetInstance(); + // execute tasks $executionResults = TaskScheduler::runTasks(); diff --git a/tests/PHPUnit/DatabaseTestCase.php b/tests/PHPUnit/DatabaseTestCase.php index 333971b8e1e..1c0968539c2 100644 --- a/tests/PHPUnit/DatabaseTestCase.php +++ b/tests/PHPUnit/DatabaseTestCase.php @@ -48,6 +48,7 @@ public function setUp() Db::createDatabaseObject(); DbHelper::createTables(); +// \Piwik\Manager::getInstance()->loadPlugins(array()); IntegrationTestCase::loadAllPlugins(); } catch (Exception $e) { diff --git a/tests/PHPUnit/Integration/Plugins/MobileMessagingTest.php b/tests/PHPUnit/Integration/Plugins/MobileMessagingTest.php index e81f0790f49..4bbb959f866 100644 --- a/tests/PHPUnit/Integration/Plugins/MobileMessagingTest.php +++ b/tests/PHPUnit/Integration/Plugins/MobileMessagingTest.php @@ -34,7 +34,7 @@ public function setUp() $this->idSiteAccess = APISitesManager::getInstance()->addSite("test", "http://test"); - \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports', 'MobileMessaging', 'MultiSites', 'LanguagesManager')); + \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports', 'MobileMessaging', 'MultiSites')); \Piwik\Plugin\Manager::getInstance()->installLoadedPlugins(); } @@ -47,7 +47,7 @@ public function setUp() public function testWarnUserViaSMSMultiSitesDeactivated() { // safety net - \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports', 'MobileMessaging', 'LanguagesManager')); + \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports', 'MobileMessaging')); $this->assertFalse(\Piwik\Plugin\Manager::getInstance()->isPluginActivated('MultiSites')); $APIScheduledReports = APIScheduledReports::getInstance(); diff --git a/tests/PHPUnit/Integration/Plugins/ScheduledReportsTest.php b/tests/PHPUnit/Integration/Plugins/ScheduledReportsTest.php index 99dd590624a..44da874c375 100644 --- a/tests/PHPUnit/Integration/Plugins/ScheduledReportsTest.php +++ b/tests/PHPUnit/Integration/Plugins/ScheduledReportsTest.php @@ -34,7 +34,7 @@ public function setUp() // setup the access layer self::setSuperUser(); - \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('API', 'UserCountry', 'ScheduledReports', 'MobileMessaging', 'LanguagesManager')); + \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('API', 'UserCountry', 'ScheduledReports', 'MobileMessaging')); \Piwik\Plugin\Manager::getInstance()->installLoadedPlugins(); APISitesManager::getInstance()->addSite("Test", array("http://piwik.net")); @@ -200,7 +200,7 @@ public function testDeleteReport() public function testGetTopMenuTranslationKeyMobileMessagingInactive() { // unload MobileMessaging plugin - \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports', 'LanguagesManager')); + \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports')); $pdfReportPlugin = new ScheduledReports(); $this->assertEquals(