WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 4 months ago

#52626 new defect (bug)

Block editor doesn't paginate parent page results

Reported by: hobzhobz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 5.6.2
Component: Editor Keywords:
Focuses: rest-api Cc:

Description

Conditions:

More than 100 pages.
Use gutenberg editor.
Edit a page.

Result:

Parent page dropdown is broken / does not contain all pages.

Expected result:

Should be able to see all the 100+ pages in the parent page dropdown.

Reason:

rest api ajax request only fetches the first 100 pages. The response headers does contain the corrent headers:
X-WP-Total: 1040 (i have 1040 pages)
X-WP-TotalPages: 11 (yes it's 11 x 100 pages)

I see only one ajax request for the first 100 pages.
After that i would see 10 more requests in older versions of wordpress.
Now it's only one.
I have tried reading the javascript but it's not easy to read.

This breaks my companies internal website. Would be nice to have a fix. We can't switch away from gutenberg.

This is also related to an older unfixed bug: https://core.trac.wordpress.org/ticket/46294

Attachments (2)

Screenshot from 2021-02-24 00-10-04.png (18.1 KB) - added by hobzhobz 5 months ago.
Screenshot showing that the headers for the first ajax request is correct and that there's no more requests after that.
Screenshot from 2021-02-24 00-11-14.png (7.3 KB) - added by hobzhobz 5 months ago.
Screenshot showing parent page dropdown with only 3 pages (should contain 1040 pages) (sorry, swedish)

Download all attachments as: .zip

Change History (6)

@hobzhobz
5 months ago

Screenshot showing that the headers for the first ajax request is correct and that there's no more requests after that.

@hobzhobz
5 months ago

Screenshot showing parent page dropdown with only 3 pages (should contain 1040 pages) (sorry, swedish)

#1 @TimothyBlynJacobs
5 months ago

  • Component changed from REST API to Editor
  • Focuses rest-api added

#2 @TimothyBlynJacobs
5 months ago

  • Summary changed from wp rest api fails to paginate page requests correctly for parent page dropdown on edit post page when using gutenberg to Block editor doesn't paginate parent page results

#3 @hobzhobz
5 months ago

I want to add a detail to anyone trying to reproduce this bug.

Your pages needs to be in a somewhat complex tree.

If your pages are perfectly flat, then the dropdown will at least show the first 100 pages. But if they are in a tree, the javascript (i assume) will not be able to build the page tree correctly with only a fraction of the pages, so it will produce seemingly random results.

#4 @hobzhobz
5 months ago

WORKAROUND (VERY UGLY/HACKY)

WARNING: You need to do this after every time you upgrade wordpress.

  1. Copy the contents of wp-includes/js/dist/editor.js to wp-includes/js/dist/editor.min.js (because the minified version is annoying to edit)
  1. Edit wp-includes/js/dist/editor.min.js line 7272 Change per_page: 100 to per_page: 10000 (or whatever you need for your site)
  1. Edit wp-includes/rest-api/endpoints/class-wp-rest-controller.php line 356, change 'maximum' => 100 to 'maximum' => 10000 (or whatever you set in step 2)

With this hack you no longer need the menu_order fix, because now they all come in the same response without pagination so the ordering doesnt matter.

Last edited 4 months ago by hobzhobz (previous) (diff)
Note: See TracTickets for help on using tickets.