From 2793f9c078272b178250ed4e0812219b9c5c1676 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 21 Nov 2014 18:07:36 +0100 Subject: [ticket/13358] Add file_downloader to version_helper PHPBB3-13358 --- phpBB/phpbb/version_helper.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/version_helper.php') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index c3c3602944..3b455ec5ba 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -50,6 +50,9 @@ class version_helper /** @var \phpbb\config\config */ protected $config; + /** @var \phpbb\file_downloader */ + protected $file_downloader; + /** @var \phpbb\user */ protected $user; @@ -58,12 +61,14 @@ class version_helper * * @param \phpbb\cache\service $cache * @param \phpbb\config\config $config + * @param \phpbb\file_downloader $file_downloader * @param \phpbb\user $user */ - public function __construct(\phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\user $user) + public function __construct(\phpbb\cache\service $cache, \phpbb\config\config $config, file_downloader $file_downloader, \phpbb\user $user) { $this->cache = $cache; $this->config = $config; + $this->file_downloader = $file_downloader; $this->user = $user; if (defined('PHPBB_QA')) @@ -250,7 +255,9 @@ class version_helper else if ($info === false || $force_update) { $errstr = $errno = ''; - $info = get_remote_file($this->host, $this->path, $this->file, $errstr, $errno); + $this->file_downloader->set_error_number($errno) + ->set_error_string($errstr); + $info = $this->file_downloader->get($this->host, $this->path, $this->file); if (!empty($errstr)) { -- cgit v1.2.1 From 352648f173e7b132544bf3eaa494184bec6d5aa2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 21 Nov 2014 21:34:02 +0100 Subject: [ticket/13358] Fix tests and use exceptions instead of user object PHPBB3-13358 --- phpBB/phpbb/version_helper.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/version_helper.php') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index 3b455ec5ba..d7f1f02678 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -257,7 +257,13 @@ class version_helper $errstr = $errno = ''; $this->file_downloader->set_error_number($errno) ->set_error_string($errstr); - $info = $this->file_downloader->get($this->host, $this->path, $this->file); + try { + $info = $this->file_downloader->get($this->host, $this->path, $this->file); + } + catch (\RuntimeException $exception) + { + throw new \RuntimeException(call_user_func_array(array($this->user, 'lang'), $exception->getMessage())); + } if (!empty($errstr)) { -- cgit v1.2.1 From 171837eefe2f8e17597629b108e2aa30c0f4055f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 21 Nov 2014 23:16:22 +0100 Subject: [ticket/13358] Do not pass variables by reference PHPBB3-13358 --- phpBB/phpbb/version_helper.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/version_helper.php') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index d7f1f02678..38050d8ad7 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -254,9 +254,6 @@ class version_helper } else if ($info === false || $force_update) { - $errstr = $errno = ''; - $this->file_downloader->set_error_number($errno) - ->set_error_string($errstr); try { $info = $this->file_downloader->get($this->host, $this->path, $this->file); } @@ -264,10 +261,11 @@ class version_helper { throw new \RuntimeException(call_user_func_array(array($this->user, 'lang'), $exception->getMessage())); } + $error_string = $this->file_downloader->get_error_string(); - if (!empty($errstr)) + if (!empty($error_string)) { - throw new \RuntimeException($errstr); + throw new \RuntimeException($error_string); } $info = json_decode($info, true); -- cgit v1.2.1