WordPress.org

Make WordPress Core

Opened 4 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 (5)

11694.diff (803 bytes) - added by dd32 4 years ago.
canonical-pagination.patch (1021 bytes) - added by joostdevalk 10 months ago.
Canonical - Pagination Patch
pagination-rel-canonical.patch (709 bytes) - added by joostdevalk 10 months ago.
Patch for rel=canonical on paginated posts
pagination-rel-canonical.2.patch (3.0 KB) - added by joostdevalk 10 months ago.
rel-canonical patch which adds paginated post link API call
pagination-rel-canonical.3.patch (3.0 KB) - added by joostdevalk 10 months ago.
Patch for rel=canonical on paginated posts

Download all attachments as: .zip

Change History (29)

comment:1 Denis-de-Bernardy4 years ago

  • Version set to 2.9

comment:2 Denis-de-Bernardy4 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 elky4 years ago

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

comment:4 dd324 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.

dd324 years ago

comment:5 nacin3 years ago

  • Milestone changed from Awaiting Triage to Future Release

comment:6 SergeyBiryukov20 months ago

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

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

Last edited 20 months ago by SergeyBiryukov (previous) (diff)

comment:7 sirzooro20 months ago

  • Cc sirzooro added

comment:8 mdgl19 months 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 SergeyBiryukov19 months 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 here10 months ago

See also #18660

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

1) site/post/## - where ## is non-existant - should 404 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."

Version 0, edited 10 months ago by here (next)

joostdevalk10 months ago

Canonical - Pagination Patch

comment:11 joostdevalk10 months 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.

joostdevalk10 months ago

Patch for rel=canonical on paginated posts

comment:12 joostdevalk10 months 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 joostdevalk10 months 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...

joostdevalk10 months ago

rel-canonical patch which adds paginated post link API call

comment:14 joostdevalk10 months 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 10 months ago by joostdevalk (previous) (diff)

joostdevalk10 months ago

Patch for rel=canonical on paginated posts

comment:15 joostdevalk10 months ago

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

Last edited 10 months ago by joostdevalk (previous) (diff)

comment:16 SergeyBiryukov10 months ago

  • Keywords 3.7-early added

comment:17 ocean909 months ago

  • Cc ocean90 added

comment:18 wonderboymusic9 months ago

  • Milestone changed from Future Release to 3.7

these are all marked 3.7-early

comment:19 dd328 months ago

  • Owner dd32 deleted
  • Status changed from accepted to assigned

comment:20 johnbillion6 months ago

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

comment:22 SergeyBiryukov5 months ago

#26123 was marked as a duplicate.

comment:23 nacin5 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 nacin3 months ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added
Note: See TracTickets for help on using tickets.