In canonical.php:

* Clarify some docs
* `redirect_canonical()` inconsistently returns `null` or `false` when bailing - can simply return.

See #32444.

Built from https://develop.svn.wordpress.org/trunk@32529


git-svn-id: http://core.svn.wordpress.org/trunk@32499 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-05-21 20:30:25 +00:00
parent 9b3271f635
commit 3f32bf7bc0
2 changed files with 11 additions and 9 deletions

View File

@ -33,8 +33,7 @@
* @param string $requested_url Optional. The URL that was requested, used to
* figure if redirect is needed.
* @param bool $do_redirect Optional. Redirect to the new URL.
* @return null|false|string Null, if redirect not needed. False, if redirect
* not needed or the string of the URL
* @return null|string Null, if redirect not needed, or the string of the URL
*/
function redirect_canonical( $requested_url = null, $do_redirect = true ) {
global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
@ -447,8 +446,9 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
$redirect_url .= '?' . $redirect['query'];
}
if ( !$redirect_url || $redirect_url == $requested_url )
return false;
if ( ! $redirect_url || $redirect_url == $requested_url ) {
return;
}
// Hex encoded octets are case-insensitive.
if ( false !== strpos($requested_url, '%') ) {
@ -472,8 +472,10 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
*/
$redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url );
if ( !$redirect_url || $redirect_url == $requested_url ) // yes, again -- in case the filter aborted the request
return false;
// yes, again -- in case the filter aborted the request
if ( ! $redirect_url || $redirect_url == $requested_url ) {
return;
}
if ( $do_redirect ) {
// protect against chained redirects
@ -483,7 +485,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
} else {
// Debug
// die("1: $redirect_url<br />2: " . redirect_canonical( $redirect_url, false ) );
return false;
return;
}
} else {
return $redirect_url;
@ -523,7 +525,7 @@ function _remove_qs_args_if_not_in_url( $query_string, Array $args_to_check, $ur
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @return bool|string The correct URL if one is found. False on failure.
* @return false|string The correct URL if one is found. False on failure.
*/
function redirect_guess_404_permalink() {
global $wpdb, $wp_rewrite;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32528';
$wp_version = '4.3-alpha-32529';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.