php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60446 'http' 'ignore_errors' does not work
Submitted: 2011-12-05 09:16 UTC Modified: 2016-06-07 17:03 UTC
Votes:3
Avg. Score:3.0 ± 1.6
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: im at dinexi dot ru Assigned: cmb (profile)
Status: Closed Package: Streams related
PHP Version: 5.3.8 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: im at dinexi dot ru
New email:
PHP Version: OS:

 

 [2011-12-05 09:16 UTC] 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)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-25 18:22 UTC] 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&#32;&#35;3&#46;5bdf02cc&#46;1382725055&#46;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.
 [2015-03-27 14:33 UTC] tyrael@php.net
-Status: Open +Status: Feedback
 [2015-03-27 14:33 UTC] tyrael@php.net
I can't reproduce the problem.
 [2015-03-27 15:34 UTC] im at dinexi dot ru
-Status: Feedback +Status: Open
 [2015-03-27 15:34 UTC] im at dinexi dot ru
With 5.5.9-1ubuntu4.7 the code works absolutely as expected.
 [2016-06-07 17:03 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-06-07 17:03 UTC] cmb@php.net
> With 5.5.9-1ubuntu4.7 the code works absolutely as expected.

So I guess we can close this ticket.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 15:01:29 2024 UTC