php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50563 removing E_WARNING from parse_url()
Submitted: 2009-12-23 16:52 UTC Modified: 2011-02-08 02:25 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: philip@php.net Assigned: philip
Status: Closed Package: *General Issues
PHP Version: 5.3.2RC1 OS: N/A
Private report: No CVE-ID:
 [2009-12-23 16:52 UTC] philip@php.net
Description:
------------
parse_url() does not need to emit an E_WARNING upon failure, as instead 
it returns false. Doing both basically requires people to use @.


Patches

parse-url-bitfields (last revision 2010-05-24 13:38 UTC) by kalle@php.net)
fix-parse_url-warning-against-5_3 (last revision 2010-05-21 16:10 UTC) by ralph at smashlabs dot com)
fix-parse_url-warning-against-trunk (last revision 2010-05-21 16:10 UTC) by ralph at smashlabs dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-23 16:57 UTC] derick@php.net
Actually, it should allow for returning *why* the parsing failed as well. Assigning to myself.
 [2010-05-24 15:18 UTC] kalle@php.net
-Package: Feature/Change Request +Package: *General Issues
 [2010-05-24 15:18 UTC] kalle@php.net
I did a quick and dirty patch to turn the $component into a bitfield
allowing you to do:
$url = parse_url('http://www.php.net/manual/', PHP_URL_HOST | PHP_URL_PATH);
printf('%s%s', $url['host'], $url['path']);

At the same point I figured we could disable the warning and therefore
I added a new constant named PHP_URL_SILENT:
$broken_url = 'http:///www.php.net/';
var_dump(parse_url($broken_url), parse_url($broken_url, PHP_URL_SILENT));

It doesn't alter the actual URL parser code to tell why the parsing
failed, but it kills two flies in one hit. Ofcourse the silent option
can be skipped, but while atleast updating parse_url().

The patch uploaded here does not currently fix any broken tests.

Theres a minor BC break, since it changes the values of the constants,
but it can be fixed by changing the checking code, or the dirty way to
increase the values so they don't conflict with the old ones.
 [2010-05-24 15:36 UTC] pajoye@php.net
-Assigned To: derick +Assigned To:
 [2010-05-24 15:36 UTC] pajoye@php.net
Derick, I don't see why you would change the return value here. Please explain your reasoning.

However the patch to remove the warning can be applied already, as I explained on internals.
 [2010-05-24 15:38 UTC] kalle@php.net
The following patch has been added/updated:

Patch Name: parse-url-bitfields
Revision:   1274708338
URL:        http://bugs.php.net/patch-display.php?bug=50563&patch=parse-url-bitfields&revision=1274708338
 [2010-05-24 16:30 UTC] philip@php.net
I don't think the bit fields should be used to hide the warning.
 [2010-06-16 20:56 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=300501
Log: - #50563, removing E_WARNING from parse_url()
 [2011-02-07 22:00 UTC] dan at teton dot com
This is STILL throwing E_WARNING.  Not good.
 [2011-02-08 02:25 UTC] philip@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: philip
 [2011-02-08 02:25 UTC] philip@php.net
It does not, as of PHP 5.3.3.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 01:01:56 2014 UTC