Bug #60446 [Fbk->Opn]: 'http' 'ignore_errors' does not work
Edit report at https://bugs.php.net/bug.php?id=60446&edit=1
ID: 60446
User updated by: im at dinexi dot ru
Reported by: im at dinexi dot ru
Summary: 'http' 'ignore_errors' does not work
-Status: Feedback
+Status: Open
Type: Bug
Package: Streams related
Operating System: Linux
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
With 5.5.9-1ubuntu4.7 the code works absolutely as expected.
Previous Comments:
------------------------------------------------------------------------
[2015-03-27 14:33:35] tyrael@php.net
I can't reproduce the problem.
------------------------------------------------------------------------
[2013-10-25 18:22:38] david at nnucomputerwhiz dot com
I get the expected result when running this test script:
$ php stream.php
string(283) "<HTML><HEAD>\n<TITLE>Internal Server
Error</TITLE>\n</HEAD><BODY>\n<H1>Internal Server Error -
Read</H1>\nThe server encountered an internal error or misconfiguration and was unable
to\ncomplete your
request.<P>\nReference #3.5bdf02cc.1382725055.63671de\n</BODY></HTML>\n"
I'm using php 5.4 in ubuntu.
$ php -v
PHP 5.4.9-4ubuntu2.3 (cli) (built: Sep 4 2013 19:37:07)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
It's worth mentioning that I came across this because I had a different problem. I was trying
to get an https url and setting options in my stream context using 'https' as they key
which does not work. It should always be 'http' regardless if it's an https
connection.
------------------------------------------------------------------------
[2011-12-05 09:16:12] im at dinexi dot ru
Description:
------------
file_get_contents() and such raises warnings in case of errors when using http stream context.
I saw the https://bugs.php.net/bug.php?id=54898&edit=2
and yes, it works. But how I can achieve the adequate behavior when the remote works incorrectly? It
will be very sad to change the PHP error reporting level even for this single case and it's
hard to find out the problem from the script's code.
Test script:
---------------
<?php
$url = "http://rest.ebay.com/epn/v1/find/item.rss?keyword=key&programid=1&campaignid=123456789&paymentMethod=PayPal&minBids=10&maxBids=20&condition1=New&exclSellerId1=1&exclSellerId2=2&exclSellerId3=Ð";
$options = array(
'http' => array(
'ignore_errors' => true,
)
);
$context = stream_context_create($options);
$xmlString = file_get_contents($url, false, $context);
var_dump($xmlString);
Expected result:
----------------
<Error>An internal error occurred while processing your request</Error>
Actual result:
--------------
PHP Warning:
file_get_contents(http://rest.ebay.com/epn/v1/find/item.rss?keyword=key&programid=1&campaignid=123456789&paymentMethod=PayPal&minBids=10&maxBids=20&condition1=New&exclSellerId1=1&exclSellerId2=2&exclSellerId3=Ð):
failed to open stream: HTTP request failed! in /home/stanis/Work/Fiord/phptest.php on line 43
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60446&edit=1
Thread (3 messages)