[wp-trac] [WordPress Trac] #52626: Block editor doesn't paginate parent page results

WordPress Trac noreply at wordpress.org
Sun Apr 24 18:51:43 UTC 2022


#52626: Block editor doesn't paginate parent page results
--------------------------+------------------------------
 Reporter:  hobzhobz      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Editor        |     Version:  5.6.2
 Severity:  major         |  Resolution:
 Keywords:                |     Focuses:  rest-api
--------------------------+------------------------------

Comment (by hobzhobz):

 Replying to [comment:9 axdr]:
 > Replying to [comment:8 hobzhobz]:
 > > Replying to [comment:6 axdr]:
 > > > Too many records in the drop-down list will make it impossible to
 use it.
 > > >
 > > > No need to solve this problem by outputing the headings of all
 pages.
 > > > Perhaps someone can solve it using the menu-order field.
 > >
 > > Warning: might sound condescending. But i'm trying to be extra clear
 here because this seems so hard for people to understand...
 > >
 > > It's already sorted by menu_order.
 > > You know what happens if menu_order is 0 on all pages? Undefined
 behavior. You know what that means? It means that they come in seemingly
 random order. Do you know what that means when doing pagination? It means
 that page 1 has 100 random pages. Page 2 has 100 random pages. Did you
 know that this means that the same page can come on page 1 and page 2? Yes
 it can.
 > > You need to sort on menu_order AND a secondary parameter. Something
 like ID perhaps.
 > >
 > > BAD: order by menu_order limit 0,100
 > > GOOD: order by menu_order, ID limit 0,100
 > >
 > >
 > >
 >
 > BAD: ORDER BY menu_order LIMIT 0,100
 > GOOD: WHERE menu_order<>0 ORDER BY menu_order, post_title
 >
 > The problem is that it is GOOD only when the number of pages is more
 than critical

 You can't add a where statement to exclude all pages that has menu_order
 0. They need to be included.

 post_title is not safe also. Two pages can have the same title. they will
 be sorted in undefined behavior/random. If they happen to be just around
 the cut-off it's gonna be problem. You need to always have a unique field
 in the sorting when doing pagination with SQL database.

 BAD: ORDER BY menu_order, page_title
 GOOD: ORDER BY menu_order, page_title, ID

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52626#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list