[wp-trac] [WordPress Trac] #36356: Function signature of wp_parse_url() does not match parse_url()
WordPress Trac
noreply at wordpress.org
Tue Oct 4 22:23:52 UTC 2016
#36356: Function signature of wp_parse_url() does not match parse_url()
--------------------------------------+----------------------------
Reporter: johnbillion | Owner: peterwilsoncc
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 4.7
Component: HTTP API | Version: 4.4
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+----------------------------
Comment (by jrf):
@peterwilsoncc
> The doco is ambiguous in the circumstance, normally I'd clarify but
wanted to get the build passing
Very true. I've just run some tests and to my surprise on malformed urls +
a component parameter `parse_url()` returns `false`, so the current
behaviour of `wp_parse_url()` is in line with that.
All the same, it makes for unnecessarily extra complicated variable
checking of the return value of `wp_parse_url()` in the case of a
`$component` parameter being passed.
{{{
// Current check would have to be:
$component = wp_parse_url( $url, $component_constant );
if ( isset($component) && false !== $component ) {
// continue processing
}
// What I suggested would simplify this to:
$component = wp_parse_url( $url, $component_constant );
if ( isset($component) ) {
// continue processing
}
}}}
So to clarify - this was what I suggested:
* with component: component if exists
* with component: null on parse error ''and if the component does not
exist''
* no component: false on parse error
* no component: array of set values
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36356#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list