From df5366a5ca0dd9ee93cbf21a61a78ffcbe66dc82 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 27 Oct 2014 15:42:26 -0700 Subject: [PATCH 1/5] [ticket/13232] Use a cache var with _ to force TTL and shuffle cron tasks PHPBB3-13232 --- phpBB/includes/functions.php | 4 ++-- phpBB/phpbb/cron/manager.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7700dcfd27..1a3560dbb1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5254,7 +5254,7 @@ function page_footer($run_cron = true, $display_template = true, $exit_handler = // Call cron-type script $call_cron = false; - if (!defined('IN_CRON') && !$config['use_system_cron'] && $run_cron && !$config['board_disable'] && !$user->data['is_bot'] && !$cache->get('cron.lock_check')) + if (!defined('IN_CRON') && !$config['use_system_cron'] && $run_cron && !$config['board_disable'] && !$user->data['is_bot'] && !$cache->get('_cron.lock_check')) { $call_cron = true; $time_now = (!empty($user->time_now) && is_int($user->time_now)) ? $user->time_now : time(); @@ -5286,7 +5286,7 @@ function page_footer($run_cron = true, $display_template = true, $exit_handler = } else { - $cache->put('cron.lock_check', true, 300); + $cache->put('_cron.lock_check', true, 60); } } diff --git a/phpBB/phpbb/cron/manager.php b/phpBB/phpbb/cron/manager.php index 5c8ac04b77..df9bed4bd7 100644 --- a/phpBB/phpbb/cron/manager.php +++ b/phpBB/phpbb/cron/manager.php @@ -72,7 +72,8 @@ class manager * @return \phpbb\cron\task\wrapper|null */ public function find_one_ready_task() - { + { + shuffle($this->tasks); foreach ($this->tasks as $task) { if ($task->is_ready()) From 0cdd071230120b8d502e6869c17f5b748d9182a0 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 27 Oct 2014 15:45:24 -0700 Subject: [PATCH 2/5] [ticket/13232] Fix indentation PHPBB3-13232 --- phpBB/phpbb/cron/manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/cron/manager.php b/phpBB/phpbb/cron/manager.php index df9bed4bd7..079ce8107e 100644 --- a/phpBB/phpbb/cron/manager.php +++ b/phpBB/phpbb/cron/manager.php @@ -72,8 +72,8 @@ class manager * @return \phpbb\cron\task\wrapper|null */ public function find_one_ready_task() - { - shuffle($this->tasks); + { + shuffle($this->tasks); foreach ($this->tasks as $task) { if ($task->is_ready()) From 6380aea647c2d611a4c3aaf5d0fe4046782340dd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 28 Oct 2014 00:34:51 +0100 Subject: [PATCH 3/5] [ticket/13232] Fix more issues with TTL and global cache file PHPBB3-13232 --- phpBB/phpbb/avatar/driver/local.php | 4 ++-- phpBB/phpbb/version_helper.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php index 07b3ed59de..8888686b2d 100644 --- a/phpBB/phpbb/avatar/driver/local.php +++ b/phpBB/phpbb/avatar/driver/local.php @@ -154,7 +154,7 @@ class local extends \phpbb\avatar\driver\driver */ protected function get_avatar_list($user) { - $avatar_list = ($this->cache == null) ? false : $this->cache->get('avatar_local_list'); + $avatar_list = ($this->cache == null) ? false : $this->cache->get('_avatar_local_list'); if ($avatar_list === false) { @@ -192,7 +192,7 @@ class local extends \phpbb\avatar\driver\driver if ($this->cache != null) { - $this->cache->put('avatar_local_list', $avatar_list, 86400); + $this->cache->put('_avatar_local_list', $avatar_list, 86400); } } diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index 968a57428f..96386f6d04 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -239,7 +239,7 @@ class version_helper */ public function get_versions($force_update = false, $force_cache = false) { - $cache_file = 'versioncheck_' . $this->host . $this->path . $this->file; + $cache_file = '_versioncheck_' . $this->host . $this->path . $this->file; $info = $this->cache->get($cache_file); From dccbd573e8010a30f0876c03f0e7150e2a377938 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 27 Oct 2014 18:55:37 -0700 Subject: [PATCH 4/5] [ticket/13232] Ensure prune cron job always gets run in prune test The cron scheduler might pick a different task but we don't want to go through them all to find the one we need. So we just make sure cron is run at all and then manually run the one we want. PHPBB3-13232 --- tests/functional/prune_shadow_topic_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php index 84f07e9802..fc5aab54a4 100644 --- a/tests/functional/prune_shadow_topic_test.php +++ b/tests/functional/prune_shadow_topic_test.php @@ -129,8 +129,8 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas $result = $this->db->sql_query($sql); $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}"); - $cron_link = $crawler->filter('img')->last()->attr('src'); - $crawler = self::request('GET', $cron_link . "&sid={$this->sid}", array(), false); + $this->assertNotEmpty($crawler->filter('img')->last()->attr('src')); + self::request('GET', "cron.php?cron_type=cron.task.core.prune_shadow_topics&f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}", array(), false); $this->assert_forum_details($this->data['forums']['Prune Shadow'], array( 'forum_posts_approved' => 0, From 2e814cc43fe8194e496c743f576b55feadbc3812 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 28 Oct 2014 10:01:28 +0100 Subject: [PATCH 5/5] [ticket/13232] Fix spaces vs tabs PHPBB3-13232 --- tests/functional/prune_shadow_topic_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php index fc5aab54a4..f00303060d 100644 --- a/tests/functional/prune_shadow_topic_test.php +++ b/tests/functional/prune_shadow_topic_test.php @@ -129,8 +129,8 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas $result = $this->db->sql_query($sql); $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}"); - $this->assertNotEmpty($crawler->filter('img')->last()->attr('src')); - self::request('GET', "cron.php?cron_type=cron.task.core.prune_shadow_topics&f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}", array(), false); + $this->assertNotEmpty($crawler->filter('img')->last()->attr('src')); + self::request('GET', "cron.php?cron_type=cron.task.core.prune_shadow_topics&f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}", array(), false); $this->assert_forum_details($this->data['forums']['Prune Shadow'], array( 'forum_posts_approved' => 0,