Improve pages handling
|Reported by:||hailin||Owned by:||anonymous|
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.