MDL-73520 general: replace deprecated php_errormsg with error_get_last()
For a better PHP8 compatibility this commit replaces the deprecated $php_errormsg with error_get_last(). The PHP 8.0 migration guide (https://www.php.net/manual/de/migration80.incompatible.php) says: The track_errors ini directive has been removed. This means that php_errormsg is no longer available. The error_get_last() function may be used instead. Also the documentation on $php_errormsg (https://www.php.net/manual/en/reserved.variables.phperrormsg.php) says: This feature has been DEPRECATED as of PHP 7.2.0. Relying on this feature is highly discouraged. Use error_get_last() instead. Signed-off-by: Daniel Ziegenberg <[email protected]>
This commit is contained in:
@@ -134,11 +134,19 @@ function sendOAuthParamsPOST($method, $endpoint, $oauth_consumer_key, $oauth_con
|
||||
$ctx = stream_context_create($params);
|
||||
$fp = @fopen($endpoint, 'rb', false, $ctx);
|
||||
if (!$fp) {
|
||||
throw new \Exception("Problem with $endpoint, $php_errormsg");
|
||||
$message = "(No error message provided.)";
|
||||
if ($error = error_get_last()) {
|
||||
$message = $error["message"];
|
||||
}
|
||||
throw new \Exception("Problem with $endpoint, $message");
|
||||
}
|
||||
$response = @stream_get_contents($fp);
|
||||
if ($response === false) {
|
||||
throw new \Exception("Problem reading data from $endpoint, $php_errormsg");
|
||||
$message = "(No error message provided.)";
|
||||
if ($error = error_get_last()) {
|
||||
$message = $error["message"];
|
||||
}
|
||||
throw new \Exception("Problem reading data from $endpoint, $message");
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -208,11 +208,19 @@ function do_post_request($url, $data, $optional_headers = null)
|
||||
$fp = @fopen($url, 'rb', false, $ctx);
|
||||
if (!$fp) {
|
||||
echo @stream_get_contents($fp);
|
||||
throw new Exception("Problem with $url, $php_errormsg");
|
||||
$message = "(No error message provided.)";
|
||||
if ($error = error_get_last()) {
|
||||
$message = $error["message"];
|
||||
}
|
||||
throw new Exception("Problem with $url, $message");
|
||||
}
|
||||
$response = @stream_get_contents($fp);
|
||||
if ($response === false) {
|
||||
throw new Exception("Problem reading data from $url, $php_errormsg");
|
||||
$message = "(No error message provided.)";
|
||||
if ($error = error_get_last()) {
|
||||
$message = $error["message"];
|
||||
}
|
||||
throw new Exception("Problem reading data from $url, $message");
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -5,3 +5,4 @@ In future releases we should look into using a supported library.
|
||||
|
||||
2022-01-05 - MDL-73502 - Removed get_magic_quotes_gpc() use, was returning false since ages ago.
|
||||
2022-01-20 - MDL-73523 - Conditional openssl_free_key() use, deprecated by PHP 8.0
|
||||
2022-03-05 - MDL-73520 - replace deprecated php_errormsg with error_get_last(), deprecated by PHP 8.0
|
||||
|
||||
Reference in New Issue
Block a user