|  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
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: 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]
parse_url() does not need to emit an E_WARNING upon failure, as instead 
it returns false. Doing both basically requires people to use @.


parse-url-bitfields (last revision 2010-05-24 13:38 UTC) by
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


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-23 16:57 UTC]
Actually, it should allow for returning *why* the parsing failed as well. Assigning to myself.
 [2010-05-24 15:18 UTC]
-Package: Feature/Change Request +Package: *General Issues
 [2010-05-24 15:18 UTC]
I did a quick and dirty patch to turn the $component into a bitfield
allowing you to do:
$url = parse_url('', 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:///';
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]
-Assigned To: derick +Assigned To:
 [2010-05-24 15:36 UTC]
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]
The following patch has been added/updated:

Patch Name: parse-url-bitfields
Revision:   1274708338
 [2010-05-24 16:30 UTC]
I don't think the bit fields should be used to hide the warning.
 [2010-06-16 20:56 UTC]
Automatic comment from SVN on behalf of pajoye
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]
-Status: Open +Status: Closed -Assigned To: +Assigned To: philip
 [2011-02-08 02:25 UTC]
It does not, as of PHP 5.3.3.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sun Oct 04 12:01:29 2015 UTC