From 36d5fff1c6cbacbda4b4c623d8b9d909f214167a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 12 May 2014 23:47:05 +0200 Subject: [ticket/12536] Get Versions Should Not Require Both Stable and Unstable https://tracker.phpbb.com/browse/PHPBB3-12536 PHPBB3-12536 --- phpBB/phpbb/version_helper.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index e2fdf6ce63..7d59b5cd3a 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -216,10 +216,19 @@ class version_helper if ($this->force_stability !== null) { - return ($this->force_stability === 'unstable') ? $info['unstable'] : $info['stable']; + $stability = ($this->force_stability === 'unstable') ? 'unstable' : 'stable'; + } + else + { + $stability = $this->is_stable($this->current_version) ? 'stable' : 'unstable'; + } + + if (!isset($info[$stability])) + { + throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL')); } - return ($this->is_stable($this->current_version)) ? $info['stable'] : $info['unstable']; + return $info[$stability]; } /** @@ -247,7 +256,7 @@ class version_helper $info = json_decode($info, true); - if (empty($info['stable']) || empty($info['unstable'])) + if (empty($info['stable']) && empty($info['unstable'])) { $this->user->add_lang('acp/common'); -- cgit v1.2.1 From 3dddf1f4bf84d7a97ee47623a868483079ed643e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 13 May 2014 12:48:08 +0200 Subject: [ticket/12536] Return empty array if stability unavailable PHPBB3-12536 --- phpBB/phpbb/version_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index 7d59b5cd3a..4c779c1a5a 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -225,7 +225,7 @@ class version_helper if (!isset($info[$stability])) { - throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL')); + return array(); } return $info[$stability]; -- cgit v1.2.1 From 8b6df0e2f8a0601b43a1c1186f09bf058dadb47b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 13 May 2014 12:59:10 +0200 Subject: [ticket/12536] Update doc block PHPBB3-12536 --- phpBB/phpbb/version_helper.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index 4c779c1a5a..8e1c593094 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -208,7 +208,6 @@ class version_helper * * @param bool $force_update Ignores cached data. Defaults to false. * @return string Version info - * @throws \RuntimeException */ public function get_versions_matching_stability($force_update = false) { -- cgit v1.2.1 From e1d9f1c67c9be90ac2f7f6a86ed02f0c22622afa Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 15 May 2014 01:14:44 +0200 Subject: [ticket/12536] Use stable values when unstable are unavailable PHPBB3-12536 --- phpBB/phpbb/version_helper.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index 8e1c593094..4718088ab6 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -215,19 +215,10 @@ class version_helper if ($this->force_stability !== null) { - $stability = ($this->force_stability === 'unstable') ? 'unstable' : 'stable'; - } - else - { - $stability = $this->is_stable($this->current_version) ? 'stable' : 'unstable'; - } - - if (!isset($info[$stability])) - { - return array(); + return ($this->force_stability === 'unstable') ? $info['unstable'] : $info['stable']; } - return $info[$stability]; + return ($this->is_stable($this->current_version)) ? $info['stable'] : $info['unstable']; } /** @@ -271,6 +262,9 @@ class version_helper } } + $info['stable'] = (empty($info['stable'])) ? array() : $info['stable']; + $info['unstable'] = (empty($info['unstable'])) ? $info['stable'] : $info['unstable']; + $this->cache->put($cache_file, $info, 86400); // 24 hours } -- cgit v1.2.1 From 8a227b981adae1ec49ad0996f32fe3e5fff33e8a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 26 May 2014 23:46:59 +0200 Subject: [ticket/12536] Restore missing @throws PHPBB3-12536 --- phpBB/phpbb/version_helper.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index 4718088ab6..76bd477e18 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -208,6 +208,7 @@ class version_helper * * @param bool $force_update Ignores cached data. Defaults to false. * @return string Version info + * @throws \RuntimeException */ public function get_versions_matching_stability($force_update = false) { -- cgit v1.2.1