mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 03:54:10 +01:00
[ticket/13358] Do not pass variables by reference
PHPBB3-13358
This commit is contained in:
parent
352648f173
commit
171837eefe
@ -2990,11 +2990,13 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
|
|||||||
global $phpbb_container;
|
global $phpbb_container;
|
||||||
|
|
||||||
// Get file downloader and assign $errstr and $errno
|
// Get file downloader and assign $errstr and $errno
|
||||||
$file_downloader = $phpbb_container->get('file_downloader')
|
$file_downloader = $phpbb_container->get('file_downloader');
|
||||||
->set_error_string($errstr)
|
|
||||||
->set_error_number($errno);
|
|
||||||
|
|
||||||
return $file_downloader->get($host, $directory, $filename, $port, $timeout);
|
$file_data = $file_downloader->get($host, $directory, $filename, $port, $timeout);
|
||||||
|
$errstr = $file_downloader->get_error_string();
|
||||||
|
$errno = $file_downloader->get_error_number();
|
||||||
|
|
||||||
|
return $file_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -38,6 +38,10 @@ class file_downloader
|
|||||||
*/
|
*/
|
||||||
function get($host, $directory, $filename, $port = 80, $timeout = 6)
|
function get($host, $directory, $filename, $port = 80, $timeout = 6)
|
||||||
{
|
{
|
||||||
|
// Set default values for error variables
|
||||||
|
$this->error_number = 0;
|
||||||
|
$this->error_string = '';
|
||||||
|
|
||||||
if ($socket = @fsockopen($host, $port, $this->error_number, $this->error_string, $timeout))
|
if ($socket = @fsockopen($host, $port, $this->error_number, $this->error_string, $timeout))
|
||||||
{
|
{
|
||||||
@fputs($socket, "GET $directory/$filename HTTP/1.0\r\n");
|
@fputs($socket, "GET $directory/$filename HTTP/1.0\r\n");
|
||||||
@ -95,30 +99,22 @@ class file_downloader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set error string
|
* Get error string
|
||||||
*
|
*
|
||||||
* @param string $error_string Error string
|
* @return string Error string
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function set_error_string(&$error_string)
|
public function get_error_string()
|
||||||
{
|
{
|
||||||
$this->error_string = &$error_string;
|
return $this->error_string;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set error number
|
* Get error number
|
||||||
*
|
*
|
||||||
* @param int $error_number Error number
|
* @return int Error number
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function set_error_number(&$error_number)
|
public function get_error_number()
|
||||||
{
|
{
|
||||||
$this->error_number = &$error_number;
|
return $this->error_number;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,9 +254,6 @@ class version_helper
|
|||||||
}
|
}
|
||||||
else if ($info === false || $force_update)
|
else if ($info === false || $force_update)
|
||||||
{
|
{
|
||||||
$errstr = $errno = '';
|
|
||||||
$this->file_downloader->set_error_number($errno)
|
|
||||||
->set_error_string($errstr);
|
|
||||||
try {
|
try {
|
||||||
$info = $this->file_downloader->get($this->host, $this->path, $this->file);
|
$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()));
|
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);
|
$info = json_decode($info, true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user