Make WordPress Core

Opened 11 years ago

Last modified 7 months ago

#32295 new defect (bug)

Pagination on preview/scheduled posts

Reported by: jacklynjade's profile jacklyn.jade Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.2.2
Component: Posts, Post Types Keywords: has-patch has-test-info needs-unit-tests
Focuses: Cc:

Description

The option to add a NextPage (Pagination) is not functioning in page previews or when a post/page is scheduled to be published.

<!--nextpage-->

The expected outcome is when adding the code for nextpage, you get links to Page 1, 2, etc. and when you click those links, you are taken to more content.

However, when a page/post is not PUBLISHED but is in Preview or Scheduled, the Pagination does not function as expected. Clicking on Page 2 refreshes the page and shows the content on page 1 again.

When the page is published, everything works as expected, but for someone who is trying to preview their post before publishing, this is not helpful.

Attachments (1)

32295-pagination.patch (775 bytes) - added by kitwestneat 10 years ago.
patch to add future to statuses that don't use permalink structure

Download all attachments as: .zip

Change History (11)

#1 @SergeyBiryukov
11 years ago

  • Component changed from General to Posts, Post Types

#2 @kitwestneat
11 years ago

We are hitting this as well. The issue seems to be that when you hit "view post" on a scheduled post it uses the permalink, but if you hit preview it uses the ?p=<post_id> link, and wp_link_pages gets confused about how to correctly create the link. (It does /?p=52248/2). A potential fix is to always use ?p=<post_id>, at least for scheduled multi-page posts, and so the previous link becomes ?p=52248&page=2

Here is a simple patch that more or less does that change:

diff -r 6e6286aee493 wordpress/wp-includes/post-template.php
--- a/wordpress/wp-includes/post-template.php   Tue Jul 14 03:32:12 2015 -0400
+++ b/wordpress/wp-includes/post-template.php   Tue Jul 14 12:23:15 2015 -0400
@@ -887,7 +887,7 @@
        if ( 1 == $i ) {
                $url = get_permalink();
        } else {
-               if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
+               if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending', 'future')) )
                        $url = add_query_arg( 'page', $i, get_permalink() );
                elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
                        $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
Last edited 11 years ago by kitwestneat (previous) (diff)

@kitwestneat
10 years ago

patch to add future to statuses that don't use permalink structure

#3 @kitwestneat
10 years ago

  • Keywords has-patch added

We're still hitting this bug - what's the best way to get traction on solving it? I updated the patch against the latest release, and uploaded it. Let me know if there's anything else I can do to help move the process along.

#4 @swissspidy
2 years ago

  • Keywords needs-testing added
  • Milestone set to Future Release

#5 @swissspidy
2 years ago

#60584 was marked as a duplicate.

This ticket was mentioned in PR #8839 on WordPress/wordpress-develop by @SirLouen.


8 months ago
#6

Refreshed solution provided in 32295-pagination.patch

Trac ticket: https://core.trac.wordpress.org/ticket/32295

#7 @SirLouen
8 months ago

  • Keywords has-test-info dev-feedback added; needs-testing removed

Combined Bug Reproduction and Patch Test Report

Description

✅ This report validates that the indicated patch works as expected.

Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/8839.diff

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 137.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Sixteen 3.5
  • MU Plugins: None activated
  • Plugins:
    • Classic Editor 1.6.7
    • Test Reports 1.2.0

Reproduction Steps

  1. First you need a non-block theme to reproduce this like 2016
  2. Create a post like this:
    This is the first page
    
    <!--nextpage-->
    
    This is the second page
    
    <!--nextpage-->
    
    This is the third page
    
    <!--nextpage-->
    
    This is the fourth page
    
  3. Go to the post and check you can move through the paginated sections
  4. Schedule the post in the future
  5. Hit on preview
  6. 🐞 Check you can move through the pagination sections, it doesn't work.

Expected Results

  • Pagination works on Preview with the Scheduled post.

Actual Results

  1. ✅ Issue resolved with patch.

Additional Notes

  • @adamsilverstein this patch is ready to be shipped. Simple yet effective. Can go into 6.8.2 or 6.8.3 without troubles.

#8 follow-up: @mindctrl
8 months ago

Patch looks good. I've confirmed the before and after behavior as outlined in the testing instructions above. Do we need any automated tests for this change?

#9 in reply to: ↑ 8 @SirLouen
8 months ago

Replying to mindctrl:

Patch looks good. I've confirmed the before and after behavior as outlined in the testing instructions above. Do we need any automated tests for this change?

Always useful to have unit-tests, ngl. I only refreshed and tested.

#10 @SirLouen
7 months ago

  • Keywords needs-unit-tests added; dev-feedback removed

Considering what @mindctrl commented, maybe some unit tests could be added to this report before proceeding in tests/phpunit/tests/post/wpLinkPages.php

Note: See TracTickets for help on using tickets.