WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#7286 closed defect (bug) (fixed)

Improve pages handling

Reported by: hailin Owned by:
Milestone: 2.6 Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

page_rows() and _page_rows() in wp-admin/includes/template.php
don't perform well in the worst case, where there are a lot of children pages.

He problem is that in _page_rows(), we had to traverse through the whole array in
order to find out a sub-page whose parent is the given one. In the worse case, the performance can degrade to O( number of children pages * number of top level pages).

Besides, given current logic, it's very hard to handle orphaned pages, which should be displayed at the last pagenum. Displaying orphaned pages makes the function more robust. Ex: we've seen a bug (#7272) causing some orphaned pages, and because this function doesn't display them, we don't know what happened, and it's very costly to figure out what went wrong.

The proposed fix has O(N) complexity in the worst, best, and average case.
It also displays orphaned pages nicely.

Attachments (1)

7286_pages.diff (3.6 KB) - added by hailin 6 years ago.
revised patch

Download all attachments as: .zip

Change History (5)

comment:1 hailin6 years ago

On a second thought, we need to applying paging to the orphaned pages too.
New patch coming soon...

hailin6 years ago

revised patch

comment:2 hailin6 years ago

modified a little logic to apply paging to orphaned pages as well.
thoroughly tested.

comment:3 ryan6 years ago

  • Milestone changed from 2.7 to 2.6

comment:4 ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [8319]) Performance improvements for page_rows(). Props hailin. fixes #7286

Note: See TracTickets for help on using tickets.