[wp-trac] [WordPress Trac] #14477: get_pages with child_of only works with uninterrupted hierarchies

WordPress Trac noreply at wordpress.org
Sun Mar 1 10:35:11 UTC 2026


#14477: get_pages with child_of only works with uninterrupted hierarchies
--------------------------+-----------------------------
 Reporter:  vividvisions  |       Owner:  wonderboymusic
     Type:  enhancement   |      Status:  reopened
 Priority:  high          |   Milestone:  Future Release
Component:  Query         |     Version:  3.0
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+-----------------------------

Comment (by rahultank):

 Testing notes for ticket #14477 — patch 14477.7.diff

 **Environment tested:**
 - WordPress version: trunk (latest develop branch)
 - PHP version: 8.3.30

 **Findings:**

 The patch (14477.7.diff) does not apply cleanly to the current trunk. The
 context lines no longer match — get_page_children() has moved from line
 ~4457 to line 6280 in the current post.php, and the function itself has
 been significantly refactored since this patch was written (it now uses a
 hash-based O(N) algorithm).

 **Code review notes on the patch:**
 1. Typo in docblock: "heirarchy" should be "hierarchy"
 2. @since 4.9 is outdated — needs updating to current version
 3. The comment "Needs a better name." should be removed before merge
 4. wp_list_pluck( $descendants, 'ID' ) is called inside a foreach loop —
 O(N^2), should be extracted before the loop
 5. The unit test at the bottom is commented out — it should be uncommented
 and verified

 **Bug status:**
 The underlying bug likely still exists in current trunk. get_pages() at
 line 6590 still calls get_page_children( $child_of, $pages ) passing only
 the already-filtered WP_Query result set. If intermediate parent pages are
 excluded by meta_key/meta_value filters, their descendants will not be
 found.

 **Recommendation:**
 This patch needs to be rebased against current trunk, the unit test needs
 to be uncommented and passing, and the code issues above should be
 addressed before it is ready for commit.

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


More information about the wp-trac mailing list