aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/file_downloader.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-11-21 21:34:02 +0100
committerMarc Alexander <admin@m-a-styles.de>2014-11-21 21:37:43 +0100
commit352648f173e7b132544bf3eaa494184bec6d5aa2 (patch)
tree243a58afccaf667629201d7a909146d8fda22c36 /phpBB/phpbb/file_downloader.php
parentf6e7a94bd55c1c3b7a8aaed370a728c58ac34ea6 (diff)
downloadforums-352648f173e7b132544bf3eaa494184bec6d5aa2.tar
forums-352648f173e7b132544bf3eaa494184bec6d5aa2.tar.gz
forums-352648f173e7b132544bf3eaa494184bec6d5aa2.tar.bz2
forums-352648f173e7b132544bf3eaa494184bec6d5aa2.tar.xz
forums-352648f173e7b132544bf3eaa494184bec6d5aa2.zip
[ticket/13358] Fix tests and use exceptions instead of user object
PHPBB3-13358
Diffstat (limited to 'phpBB/phpbb/file_downloader.php')
-rw-r--r--phpBB/phpbb/file_downloader.php25
1 files changed, 6 insertions, 19 deletions
diff --git a/phpBB/phpbb/file_downloader.php b/phpBB/phpbb/file_downloader.php
index 0f33ae9941..2d5d9a7516 100644
--- a/phpBB/phpbb/file_downloader.php
+++ b/phpBB/phpbb/file_downloader.php
@@ -15,9 +15,6 @@ namespace phpbb;
class file_downloader
{
- /** @var \phpbb\user */
- protected $user;
-
/** @var string Error string */
public $error_string = '';
@@ -25,16 +22,6 @@ class file_downloader
public $error_number = 0;
/**
- * Constructor
- *
- * @param \phpbb\user $user phpBB user object
- */
- public function __construct(user $user)
- {
- $this->user = $user;
- }
-
- /**
* Retrieve contents from remotely stored file
*
* @param string $host File host
@@ -45,6 +32,9 @@ class file_downloader
*
* @return mixed File data as string if file can be read and there is no
* timeout, false if there were errors or the connection timed out
+ *
+ * @throws \RuntimeException If data can't be retrieved and no error
+ * message is returned
*/
function get($host, $directory, $filename, $port = 80, $timeout = 6)
{
@@ -75,8 +65,7 @@ class file_downloader
}
else if (stripos($line, '404 not found') !== false)
{
- $this->error_string = $this->user->lang('FILE_NOT_FOUND', $filename);
- return false;
+ throw new \RuntimeException(array('FILE_NOT_FOUND', $filename));
}
}
@@ -84,8 +73,7 @@ class file_downloader
if (!empty($stream_meta_data['timed_out']) || time() >= $timer_stop)
{
- $this->error_string = $this->user->lang['FSOCK_TIMEOUT'];
- return false;
+ throw new \RuntimeException('FSOCK_TIMEOUT');
}
}
@fclose($socket);
@@ -99,8 +87,7 @@ class file_downloader
}
else
{
- $this->error_string = $this->user->lang['FSOCK_DISABLED'];
- return false;
+ throw new \RuntimeException('FSOCK_DISABLED');
}
}