WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 3 months ago

#11694 assigned defect (bug)

WP should do sanity checks for paginated posts, pages and comments

Reported by: Denis-de-Bernardy Owned by:
Milestone: Future Release Priority: normal
Severity: major Version: 2.9
Component: Posts, Post Types Keywords: has-patch 3.9-early
Focuses: template Cc:

Description

Create a post with two pages using the <!--nextpage--> tag. Publish, and browse the post's *third* page.

WP should return a 404 here, rather than the last page of the post.

Along the same lines, it should return the correct canonical urls for paginated posts. Currently, rel=canonical will only ever return the post's first page.

Attachments (6)

11694.diff (803 bytes) - added by dd32 5 years ago.
canonical-pagination.patch (1021 bytes) - added by joostdevalk 2 years ago.
Canonical - Pagination Patch
pagination-rel-canonical.patch (709 bytes) - added by joostdevalk 2 years ago.
Patch for rel=canonical on paginated posts
pagination-rel-canonical.2.patch (3.0 KB) - added by joostdevalk 2 years ago.
rel-canonical patch which adds paginated post link API call
pagination-rel-canonical.3.patch (3.0 KB) - added by joostdevalk 2 years ago.
Patch for rel=canonical on paginated posts
11694-tests.patch (813 bytes) - added by boonebgorges 10 months ago.
Removing from trunk as per #30284

Download all attachments as: .zip

Change History (35)

comment:1 @Denis-de-Bernardy6 years ago

  • Version set to 2.9

comment:2 @Denis-de-Bernardy6 years ago

  • Summary changed from WP should do sanity check for paginated posts and pages to WP should do sanity checks for paginated posts and pages

comment:3 @elky5 years ago

The rel=canonical issue really ought to be split out in to a separate bug, imho.

comment:4 @dd325 years ago

  • Keywords has-patch added
  • Milestone changed from 3.0 to 3.1
  • Owner set to dd32
  • Status changed from new to accepted

I'm attaching a patch I've got locally for this.

This will need a more thought out patch however.

@dd325 years ago

comment:5 @nacin5 years ago

  • Milestone changed from Awaiting Triage to Future Release

comment:6 @SergeyBiryukov3 years ago

Closed #21278 as a duplicate. Related: #11857 (for archive pages).

As noted in ticket:21278:9, paginated comments are affected too.

Last edited 3 years ago by SergeyBiryukov (previous) (diff)

comment:7 @sirzooro3 years ago

  • Cc sirzooro added

comment:8 @mdgl3 years ago

See also #21579 where a similar issue occurs with paged comments. Invalid comment pages, for example http://example.com/content/comment-page-999/ do not return a 404 but equally do not find any comments! Is a new ticket needed or can we use this one to fix the 404 issue in both cases and #21579 to generate the proper rel="canonical" in both cases?

comment:9 @SergeyBiryukov3 years ago

  • Summary changed from WP should do sanity checks for paginated posts and pages to WP should do sanity checks for paginated posts, pages and comments

Replying to mdgl:

Is a new ticket needed or can we use this one to fix the 404 issue in both cases

No need for a new ticket. Updated the summary.

comment:10 @here2 years ago

See also #18660

@elky was correct 3 years ago, this is two issues.

1) site/post/## - where ## is non-existant - should 404 or 301 not 200 duplicate content
2) site/post/## - where ## > 1 - rel=canonical should be site/post/## not duplicate first page site/post based on :

http://support.google.com/webmasters/bin/answer.py?hl=en&answer=1663744

"rel="next" and rel="prev" are orthogonal concepts to rel="canonical". You can include both declarations."

Last edited 2 years ago by here (previous) (diff)

@joostdevalk2 years ago

Canonical - Pagination Patch

comment:11 @joostdevalk2 years ago

The patch I just added fixes point 1 in @here's comment above: ie. the fact that WP serves a 200 for a page that doesn't exist by, if the post is paginated, checking how much pages are in the post and acting accordingly, by either redirecting to the first page of the post or by providing a proper URL.

@joostdevalk2 years ago

Patch for rel=canonical on paginated posts

comment:12 @joostdevalk2 years ago

This second patch adds the page query variable to the canonical. If it's not used in conjunction with the other patch, this should check whether this page can actually exist.

comment:13 @joostdevalk2 years ago

Looking at how it's dealt with in post-template.php a bit more, this probably should actually be done a bit different. I think _wp_link_page should be split up and part of that should be in link-template.php, which should then be used by _wp_link_page and the functions above...

@joostdevalk2 years ago

rel-canonical patch which adds paginated post link API call

comment:14 @joostdevalk2 years ago

The last ticket introduces get_paginated_post_url, for which the functionality is removed from _wp_link_page and now used in both _wp_link_page in post-template.php and rel_canonical in link-template.php. This looks a lot cleaner to me than what we had so far and also allows for future use of get_paginated_post_url within a patch for #18660.

Last edited 2 years ago by joostdevalk (previous) (diff)

@joostdevalk2 years ago

Patch for rel=canonical on paginated posts

comment:15 @joostdevalk2 years ago

v3 of the patch changes get_paginated_post_link into the semantically correct name get_paginated_post_url.

Last edited 2 years ago by joostdevalk (previous) (diff)

comment:16 @SergeyBiryukov2 years ago

  • Keywords 3.7-early added

comment:17 @ocean902 years ago

  • Cc ocean90 added

comment:18 @wonderboymusic2 years ago

  • Milestone changed from Future Release to 3.7

these are all marked 3.7-early

comment:19 @dd322 years ago

  • Owner dd32 deleted
  • Status changed from accepted to assigned

comment:20 @johnbillion23 months ago

  • Keywords 3.7-early removed
  • Milestone changed from 3.7 to 3.8

comment:22 @SergeyBiryukov22 months ago

#26123 was marked as a duplicate.

comment:23 @nacin21 months ago

  • Keywords 3.9-early added
  • Milestone changed from 3.8 to Future Release

There is some cool work from joostdevalk here, but it's too late for 3.8. Maybe we can tackle the messiness of pagination in 3.9.

comment:24 @nacin19 months ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added

comment:25 @ircbot16 months ago

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.

comment:27 @ircbot14 months ago

This ticket was mentioned in IRC in #wordpress-dev by SergeyBiryukov. View the logs.

@boonebgorges10 months ago

Removing from trunk as per #30284

comment:29 @ocean903 months ago

#32505 was marked as a duplicate.

Note: See TracTickets for help on using tickets.