Make WordPress Core


Ignore:
Timestamp:
08/08/2016 06:48:53 PM (8 years ago)
Author:
boonebgorges
Message:

Improve category check in redirect_canonical() when permastruct contains category slug.

[37262] changed a check in redirect_canonical() so that it checked
categories in the object cache rather than querying the database. However,
the check was based on the identity of WP_Term objects, which in
certain cases can be augmented by the main WP query routine, causing
failures of the in_array() check. This caused unnecessary redirects
for URLs where is_single() is true, but the URL is different from the
post permalink, such as the embed endpoint.

has_term() also checks the cache, but does not sufer from this bug.

Props cmillerdev.
Fixes #36602.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/canonical/category.php

    r37261 r38216  
    6363            // Nonexistent category will redirect to correct one.
    6464            array( '/foo/post0/', array( 'url' => '/cat0/post0/', 'qv' => array( 'category_name' => 'cat0', 'name' => 'post0', 'page' => '' ) ) ),
     65
     66            // Embed URLs should not redirect to post permalinks.
     67            array( '/cat0/post0/embed/', array( 'url' => '/cat0/post0/embed/', 'qv' => array( 'category_name' => 'cat0', 'name' => 'post0', 'embed' => 'true' ) ) ),
    6568        );
    6669    }
Note: See TracChangeset for help on using the changeset viewer.