[wp-trac] [WordPress Trac] #21876: unregister_default_headers() will sometimes return null
WordPress Trac
wp-trac at lists.automattic.com
Wed Sep 12 19:23:07 UTC 2012
#21876: unregister_default_headers() will sometimes return null
-----------------------------+--------------------------
Reporter: conner_bw | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: General
Version: 3.4.2 | Severity: minor
Keywords: |
-----------------------------+--------------------------
File: wp-includes/theme.php
Function: unregister_default_headers()
Line: ~1046
Problem:
PHPDoc comment says: @return True on success, false on failure.
Expected:
true or false:
Actual:
`var_dump(unregister_default_headers(array('FAKE')));` will return NULL
Suggested fix, change:
{{{
function unregister_default_headers( $header ) {
global $_wp_default_headers;
if ( is_array( $header ) ) {
array_map( 'unregister_default_headers', $header );
} elseif ( isset( $_wp_default_headers[ $header ] ) ) {
unset( $_wp_default_headers[ $header ] );
return true;
} else {
return false;
}
}
}}}
To:
{{{
function unregister_default_headers( $header ) {
global $_wp_default_headers;
if ( is_array( $header ) ) {
$_ret = array_map( 'unregister_default_headers', $header
);
return in_array(false, $_ret, true) ? false : true;
} elseif ( isset( $_wp_default_headers[ $header ] ) ) {
unset( $_wp_default_headers[ $header ] );
return true;
} else {
return false;
}
}
}}}
Thank you for your consideration.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21876>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list