Make WordPress Core

Ticket #39827: 39827.diff

File 39827.diff, 1.0 KB (added by jipmoors, 7 years ago)

Avoid notice on non-existing key.

  • src/wp-includes/canonical.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    388388        else
    389389                unset($redirect['port']);
    390390
    391         // trailing /index.php
    392         $redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']);
     391        // Redirect can be missing path key caused by failed (and suppressed) parse_url calls.
     392        if ( empty( $redirect['path'] ) ) {
     393                $redirect['path'] = '';
     394        }
     395
     396        // We don't need to initiate a regular expression call if the path is empty.
     397        if ( ! empty( $redirect['path'] ) ) {
     398                // trailing /index.php
     399                $redirect['path'] = preg_replace( '|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path'] );
     400        }
    393401
    394402        $punctuation_pattern = implode( '|', array_map( 'preg_quote', array(
    395403                ' ', '%20',       // space