Make WordPress Core


Ignore:
Timestamp:
09/24/2015 02:03:05 PM (9 years ago)
Author:
wonderboymusic
Message:

Canonical/Rewrite: sanity check posts that are paged with <!--nextpage-->. Page numbers past the max number of pages are returning the last page of content and causing infinite duplicate content.

Awesome rewrite bug: the page query var was being set to '/4' in $wp. When cast to int, it returns 0 (Bless you, PHP). WP_Query calls trim( $page, '/' ) when setting its own query var. The few places that were checking page before posts were queried now have sanity checks, so that these changes work without flushing rewrites.

Adds/updates unit tests.

Props wonderboymusic, dd32.
See #11694.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rewrite-functions.php

    r33751 r34492  
    257257        $maybe_page = $query_vars['day'];
    258258    }
     259    // Bug found in #11694 - 'page' was returning '/4'
     260    $maybe_page = (int) trim( $maybe_page, '/' );
    259261
    260262    $post_page_count = substr_count( $post->post_content, '<!--nextpage-->' ) + 1;
Note: See TracChangeset for help on using the changeset viewer.