From b6dcd8bc642078f92e95c9f49cd2260d195eb9ab Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sun, 12 Oct 2014 23:18:38 +1300 Subject: [PATCH] #6085 Removed $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] and replaced it with DEBUG_FORCE_SCHEDULED_TASKS --- core/ScheduledTaskTimetable.php | 4 +--- core/TaskScheduler.php | 2 +- core/Tracker.php | 2 +- piwik.php | 1 - plugins/CoreAdminHome/Commands/RunScheduledTasks.php | 2 +- tests/LocalTracker.php | 1 - tests/PHPUnit/Integration/ReleaseCheckListTest.php | 2 +- 7 files changed, 5 insertions(+), 9 deletions(-) diff --git a/core/ScheduledTaskTimetable.php b/core/ScheduledTaskTimetable.php index 75d79e688a3..92aa1b340ec 100644 --- a/core/ScheduledTaskTimetable.php +++ b/core/ScheduledTaskTimetable.php @@ -72,9 +72,7 @@ public function getScheduledTaskTime($taskName) */ public function shouldExecuteTask($taskName) { - $forceTaskExecution = - (isset($GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) && $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) - || DEBUG_FORCE_SCHEDULED_TASKS; + $forceTaskExecution = (defined('DEBUG_FORCE_SCHEDULED_TASKS') && DEBUG_FORCE_SCHEDULED_TASKS); return $forceTaskExecution || ($this->taskHasBeenScheduledOnce($taskName) && time() >= $this->timetable[$taskName]); } diff --git a/core/TaskScheduler.php b/core/TaskScheduler.php index 6d94d591a11..8fd90693896 100644 --- a/core/TaskScheduler.php +++ b/core/TaskScheduler.php @@ -13,7 +13,7 @@ use Piwik\Plugin\Manager as PluginManager; // When set to true, all scheduled tasks will be triggered in all requests (careful!) -define('DEBUG_FORCE_SCHEDULED_TASKS', false); +//define('DEBUG_FORCE_SCHEDULED_TASKS', true); /** * Manages scheduled task execution. diff --git a/core/Tracker.php b/core/Tracker.php index f3c8fa55d76..ed911e55f68 100644 --- a/core/Tracker.php +++ b/core/Tracker.php @@ -338,7 +338,7 @@ protected static function runScheduledTasks() $nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval; - if ((isset($GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) && $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) + if ((defined('DEBUG_FORCE_SCHEDULED_TASKS') && DEBUG_FORCE_SCHEDULED_TASKS) || $cache['lastTrackerCronRun'] === false || $nextRunTime < $now ) { diff --git a/piwik.php b/piwik.php index f5278f5d47a..636d6f8b220 100644 --- a/piwik.php +++ b/piwik.php @@ -15,7 +15,6 @@ // Note: if you wish to debug the Tracking API please see this documentation: // http://developer.piwik.org/api-reference/tracking-api#debugging-the-tracker -$GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] = false; define('PIWIK_ENABLE_TRACKING', true); if (!defined('PIWIK_DOCUMENT_ROOT')) { diff --git a/plugins/CoreAdminHome/Commands/RunScheduledTasks.php b/plugins/CoreAdminHome/Commands/RunScheduledTasks.php index 1e73c1d6268..3cccb943399 100644 --- a/plugins/CoreAdminHome/Commands/RunScheduledTasks.php +++ b/plugins/CoreAdminHome/Commands/RunScheduledTasks.php @@ -51,7 +51,7 @@ private function forceRunAllTasksIfRequested(InputInterface $input) $force = $input->getOption('force'); if ($force) { - $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] = true; + define('DEBUG_FORCE_SCHEDULED_TASKS', true); } } } \ No newline at end of file diff --git a/tests/LocalTracker.php b/tests/LocalTracker.php index ecddbe5c9f9..e0867a746d1 100755 --- a/tests/LocalTracker.php +++ b/tests/LocalTracker.php @@ -5,7 +5,6 @@ use Piwik\Tracker\Cache; $GLOBALS['PIWIK_TRACKER_DEBUG'] = false; -$GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] = false; if (!defined('PIWIK_ENABLE_TRACKING')) { define('PIWIK_ENABLE_TRACKING', true); } diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php index 947b06a5374..b1a96a91cff 100644 --- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php @@ -87,7 +87,7 @@ public function testCheckThatConfigurationValuesAreProductionValues() $this->_checkEqual(array('log' => 'logger_api_call'), null); require_once PIWIK_INCLUDE_PATH . "/core/TaskScheduler.php"; - $this->assertFalse(DEBUG_FORCE_SCHEDULED_TASKS); + $this->assertFalse(defined('DEBUG_FORCE_SCHEDULED_TASKS')); // Check the index.php has "backtrace disabled" $content = file_get_contents(PIWIK_INCLUDE_PATH . "/index.php");