[wp-trac] [WordPress Trac] #16574: Lazy load ancestors

WordPress Trac wp-trac at lists.automattic.com
Wed Feb 16 15:32:49 UTC 2011


#16574: Lazy load ancestors
---------------------------------+-----------------------------
 Reporter:  nacin                |       Owner:
     Type:  enhancement          |      Status:  new
 Priority:  normal               |   Milestone:  Future Release
Component:  Performance          |     Version:
 Severity:  normal               |  Resolution:
 Keywords:  3.2-early has-patch  |
---------------------------------+-----------------------------

Comment (by filosofo):

 How about instead we deprecate the post object's `ancestors` property with
 a magic `__get` method, and then use a working `get_post_ancestors()`
 function to get the ancestors in core WP?

 That way, we maintain backwards-compatibility for those who are
 referencing the `ancestors` post property in plugins, but we are explicit
 about actually querying the post ancestors, in core (and as recommended
 practice).

 Resource-intensive queries like that should be as explicit as possible,
 for code readability and debugging purposes. Hiding the query in a magic
 `__get` method is slightly slower, and it makes it harder to identify the
 conditions in which such queries will occur.

 In other words, as a band-aid to handle deprecated properties, it's fine,
 but let's not make it standard practice, particularly for retrieving
 external resources (database records) as opposed to e.g. internal object
 properties, which I think was the intent of `__get`.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16574#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list