ID: 49066 Updated by: [email protected] Reported By: peaceable_whale at hotmail dot com -Status: Verified +Status: Bogus Bug Type: cURL related Operating System: * PHP Version: 5.*, 6SVN (2009-08-04) New Comment:
And the reason this fails is found on the manual page for curl_setopt_array(): "Returns TRUE if all options were successfully set. If an option could not be successfully set, FALSE is immediately returned, ignoring any future options in the options array." And this error is output when you don't disable errors: Warning: curl_setopt_array(): CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set.. There is no bug here. Previous Comments: ------------------------------------------------------------------------ [2009-08-03 22:55:53] [email protected] To be clear: without open_basedir it works fine. ------------------------------------------------------------------------ [2009-08-03 22:54:48] [email protected] A bit more readable script: <?php error_reporting(E_ALL^E_WARNING); $request=curl_init("http://example.com/X"); curl_setopt_array($request, array( CURL_HTTP_VERSION_1_1 => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_FAILONERROR => true, CURLOPT_RETURNTRANSFER=>true, ) ); var_dump(curl_exec($request)); ?> To reproduce: # sapi/cli/php -n -dopen_basedir=. test.php ------------------------------------------------------------------------ [2009-07-26 16:16:22] peaceable_whale at hotmail dot com The previous submitted code doesn't reflect the problem correctly... The followings are the corrected information: Description: ------------ CURLOPT_FAILONERROR does not work when CURLOPT_FOLLOWLOCATION is true and open_dir is set. PHP Version: ------------ PHP 5.3.0 NTS VC9 Reproduce code: --------------- <?php error_reporting(E_ALL^E_WARNING); header("Content-Type: text/plain; charset=UTF-8"); header("X-Content-Type-Options: nosniff"); $request=curl_init("http://example.com/X"); curl_setopt_array($request,array(CURL_HTTP_VERSION_1_1=>true,CURLOPT_USERAGENT=>"PHP/".phpversion(),CURLOPT_FOLLOWLOCATION=>true,CURLOPT_FAILONERROR=>true,CURLOPT_RETURNTRANSFER=>true)); echo (curl_exec($request)===false?"false":"true")."\r\n"; curl_close($request); ?> Expected result: ---------------- false Actual result: -------------- true) ------------------------------------------------------------------------ [2009-07-26 16:01:32] peaceable_whale at hotmail dot com Description: ------------ CURLOPT_FAILONERROR does not work when CURLOPT_URL is reset. Not false is returned even when the response code is >=400. Reproduce code: --------------- <?php header("Content-Type: text/plain; charset=UTF-8"); header("X-Content-Type-Options: nosniff"); $request=curl_init(); curl_setopt_array($request,array(CURL_HTTP_VERSION_1_1=>true,CURLOPT_USERAGENT=>"PHP/".phpversion(),CURLOPT_FAILONERROR=>false,CURLOPT_RETURNTRANSFER=>true)); for($i=0;$i<5;$i++) { curl_setopt($request,CURLOPT_URL,"http://example.com/".$i); echo "Trial ".$i.": ".(curl_exec($request)===false?"false":"true")."\r\n"; } curl_close($request); ?> Expected result: ---------------- Trial 0: false Trial 1: false Trial 2: false Trial 3: false Trial 4: false Actual result: -------------- Trial 0: true Trial 1: true Trial 2: true Trial 3: true Trial 4: true ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49066&edit=1
