[contents] improve file_get_contents() reporting (#986)

Suppress any errors from file_get_contents() and include the PHP error in the feed instead.
This commit is contained in:
triatic 2019-01-06 19:30:02 +00:00 committed by LogMANOriginal
parent ef4923ae5c
commit 245af35a60

View file

@ -54,7 +54,7 @@ function getContents($url, $header = array(), $opts = array()){
// Use file_get_contents if in CLI mode with no root certificates defined // Use file_get_contents if in CLI mode with no root certificates defined
if(php_sapi_name() === 'cli' && empty(ini_get('curl.cainfo'))) { if(php_sapi_name() === 'cli' && empty(ini_get('curl.cainfo'))) {
$data = file_get_contents($url); $data = @file_get_contents($url);
if($data === false) { if($data === false) {
$errorCode = 500; $errorCode = 500;
@ -167,10 +167,14 @@ EOD
); );
} }
$lastError = error_get_last();
if($lastError !== null)
$lastError = $lastError['message'];
returnError(<<<EOD returnError(<<<EOD
The requested resource cannot be found! The requested resource cannot be found!
Please make sure your input parameters are correct! Please make sure your input parameters are correct!
cUrl error: $curlError ($curlErrno) cUrl error: $curlError ($curlErrno)
PHP error: $lastError
EOD EOD
, $errorCode); , $errorCode);
} }