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: [email protected] Assigned: philip (profile)
Status: Closed Package: *General Issues
PHP Version: 5.3.2RC1 OS: N/A
Private report: No CVE-ID: None
 [2009-12-23 16:52 UTC] [email protected]
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 [email protected])
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)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-23 16:57 UTC] [email protected]
Actually, it should allow for returning *why* the parsing failed as well. Assigning to myself.
 [2010-05-24 15:18 UTC] [email protected]
-Package: Feature/Change Request +Package: *General Issues
 [2010-05-24 15:18 UTC] [email protected]
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] [email protected]
-Assigned To: derick +Assigned To:
 [2010-05-24 15:36 UTC] [email protected]
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] [email protected]
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] [email protected]
I don't think the bit fields should be used to hide the warning.
 [2010-06-16 20:56 UTC] [email protected]
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] [email protected]
-Status: Open +Status: Closed -Assigned To: +Assigned To: philip
 [2011-02-08 02:25 UTC] [email protected]
It does not, as of PHP 5.3.3.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 31 03:00:01 2025 UTC