Bug #74563 [Com]: curl_exec() throws internal error in curl_error()
| From: | danack@php.net | Date: | Tue, 09 May 2017 15:16:08 +0000 |
| Subject: | Bug #74563 [Com]: curl_exec() throws internal error in curl_error() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209029@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74563&edit=1
ID: 74563
Comment by: danack@php.net
Reported by: jeremys at ha dot com
Summary: curl_exec() throws internal error in curl_error()
Status: Open
Type: Bug
Package: cURL related
Operating System: RHEL 7.3
PHP Version: 7.1.4
Block user comment: N
Private report: N
New Comment:
In fact - please can you just double check that you are seeing the error from the code you have
listed here.
I strongly suspect you have OPCache running and the error you are seeing is from code that has been
cached in memory, rather than running the latest version of that file.
Previous Comments:
------------------------------------------------------------------------
[2017-05-09 15:04:57] danack@php.net
Do you have Suhosin or any other security module enabled?
------------------------------------------------------------------------
[2017-05-09 13:58:27] jeremys at ha dot com
Description:
------------
Executing curl_exec() with a host/URL that refuses the connection makes curl_exec() sometimes raise
an E_WARNING because curl_exec() calls curl_error() internally. The error is as follows:
curl_error() expects parameter 1 to be resource, boolean given
As you can see in the sample script, there is no explicit call to curl_error(), yet the above error
is seen.
I've only been able to reproduce via Apache, not via cli.
Apache/2.4.6 (Red Hat Enterprise Linux)
PHP 7.1.3 (part of Zend Server 9.1) - I assume 7.1.4 as well since there are no relevant changes to
the curl interface in the PHP source code
libcurl 7.29.0
Test script:
---------------
<?php
ini_set( 'display_errors', 1 );
ini_set( 'error_reporting', E_ALL );
set_error_handler( function ( ...$error ) {
array_pop( $error );
print_r( $error );
die();
});
$resource = curl_init();
curl_setopt( $resource, CURLOPT_URL, 'http://127.0.0.1:1' );
curl_setopt( $resource, CURLOPT_RETURNTRANSFER, 1 );
curl_exec( $resource );
echo 'Script finished.';
Expected result:
----------------
Script finished.
Actual result:
--------------
Array
(
[0] => 2
[1] => curl_error() expects parameter 1 to be resource, boolean given
[2] => /usr/local/apache/htdocs2/curl-error-test.php
[3] => 16
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74563&edit=1