WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 2 years ago

#37251 new defect (bug)

Not return 404 on front-page with option page and url `/page/2`

Reported by: sheo13666q Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.5.3
Component: Query Keywords:
Focuses: Cc:
PR Number:

Description

If i setup page on front-page(Go Settings->Reading->Set show on front static page and choose own page->Save). Then go to front page on my site (example http://my-domain/) i see page, which setted before. But if i try open http://my-domain/page/2, http://my-domain/page/3 and etc, i get always front-page, except i am wait 404 error. After debug i found solution (line 1777 in query.php):

<?php
if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') && !$this->is_paged) {
            $_query = wp_parse_args($this->query);
            // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename.
            if ( isset($_query['pagename']) && '' == $_query['pagename'] )
                unset($_query['pagename']);

            unset( $_query['embed'] );

            if ( empty($_query) || !array_diff( array_keys($_query), array('preview', 'page', 'paged', 'cpage') ) ) {
                $this->is_page = true;
                $this->is_home = false;
                $qv['page_id'] = get_option('page_on_front');
                // Correct <!--nextpage--> for page_on_front
                if ( !empty($qv['paged']) ) {
                    $qv['page'] = $qv['paged'];
                    unset($qv['paged']);
                }
            }
        }

Add && !$this->is_paged check.

Attachments (1)

37251.diff (684 bytes) - added by Presskopp 3 years ago.

Download all attachments as: .zip

Change History (8)

@Presskopp
3 years ago

#1 @Presskopp
3 years ago

  • Keywords has-patch added

seems legit to me, patch made

This ticket was mentioned in Slack in #core by presskopp. View the logs.


3 years ago

#3 @Presskopp
3 years ago

  • Keywords needs-unit-tests added

This ticket was mentioned in Slack in #core by presskopp. View the logs.


2 years ago

#5 @desrosj
2 years ago

Hey @Presskopp!

So if your homepage is set to display a static page on front, what content would you expect to see on page/2, page/3, etc.? If it is a single page then there would not be any content to list past the first "page".

At first glance, it makes sense to me that those pages return 404s because there is not paginated content for that page.

#6 @d4z_c0nf
2 years ago

Have you tried the page with a paginated page? (using the <!--nextpage--> tag)
That patch, in this case, brings me to the blog page2.

#7 @Presskopp
2 years ago

  • Keywords has-patch needs-unit-tests removed

When I made the patch things seemed to be different.

Note: See TracTickets for help on using tickets.