Opened 4 years ago
Closed 3 years ago
#11047 closed defect (bug) (fixed)
admin edit pages could loop
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1 |
| Component: | General | Version: | 2.7 |
| Severity: | normal | Keywords: | needs-refresh 2nd-opinion |
| Cc: |
Description
This is to continue #11018.
Display_page_row() in wp-admin/includes/template.php could loop forever, causing wp-admin/edit-pages.php not able to load at all.
We should break the loop and fix the pages dynamically when this happens.
Attachments (1)
Change History (9)
_get_post_ancestors as we have the same bug there and then we can call that and use count() to get the depth we are at.
When there is a loop, we probably can not use count since it will return infinity.
We need to break out somehow, and return a dummy value such as 9999. Not sure it's going to be pretty.
Attached the right patch.
_get_post_ancestors has the following comment:
The post parent will be an ancestor and the parent of the post
- parent will be an ancestor. There will only be two ancestors at the most.
Based on the above comment, _get_post_ancestors doesn't have loop issue, and it appears that it was designed to have only two ancestors.
Therefore, the correct way to break pages loop is in display_page_row.

westi suggested breaking the loop in _get_post_ancestors.
This patch breaks the loop right in display_page_row, and we've been running this patch on a live site for a week now and verified that it's working correctly.