Make WordPress Core

Ticket #7537: 7537.diff

File 7537.diff, 1.3 KB (added by DD32, 16 years ago)
  • wp-includes/canonical.php

     
    157157        $redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
    158158
    159159        // Remove trailing slashes from certain terminating query string args
    160         $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
     160        $redirect['query'] = isset($redirect['query']) ? preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] ) : '';
    161161
    162162        // Clean up empty query strings
    163163        $redirect['query'] = preg_replace( '#&?(p|page_id|cat|tag)=?$#', '', $redirect['query'] );
     
    206206        if ( isset( $redirect['port'] ) )
    207207                $compare_redirect[] = $redirect['port'];
    208208
    209         if ( isset( $redirect['query'] ) )
     209        if ( ! empty( $redirect['query'] ) )
    210210                $compare_redirect[] = $redirect['query'];
    211211
    212212        if ( $compare_original !== $compare_redirect ) {
     
    214214                if ( isset($redirect['port']) )
    215215                        $redirect_url .= ':' . $redirect['port'];
    216216                $redirect_url .= $redirect['path'];
    217                 if ( $redirect['query'] )
     217                if ( ! empty($redirect['query']) )
    218218                        $redirect_url .= '?' . $redirect['query'];
    219219        }
    220220