[wp-trac] [WordPress Trac] #38323: Reconsider $object_subtype handling in `register_meta()`

WordPress Trac noreply at wordpress.org
Sat Jun 9 14:44:42 UTC 2018


#38323: Reconsider $object_subtype handling in `register_meta()`
-------------------------------------------------+-------------------------
 Reporter:  flixos90                             |       Owner:  flixos90
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.0
Component:  Options, Meta APIs                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-unit-tests needs-    |     Focuses:  rest-api
  dev-note                                       |
-------------------------------------------------+-------------------------

Comment (by spacedmonkey):

 So I have been looking at the patch and I have some issues with
 `get_object_subtype` function as it stands.

 I think we should return the comment_types back in as sub type. This is
 how the code currently works in capabilities.php and see is no good reason
 to change it and break any existing filters. There is a big difference
 between a comment, pingback and trackback. That is  value is having that
 as a sub type.

 The new filter `$object_subtype = apply_filters(
 "get_object_subtype_{$object_type}", $object_subtype, $object_id );`
 should be moved to the return value and not just be there for the default.
 All subtypes should be filterable. Also, should sites (blogs) meta be in
 this switch statement?

 I also have some worries about performance, as every time subtype is
 loaded, it now loads the parent object is it related. If post meta for
 example was loaded, outside of a WP_Query, it would do a single query (if
 the user is not using object caching) to post object for every different
 id. I have just loaded post meta outside of WP_Query, becuase I didnt want
 to overhead of getting the whole object. But now it is loading the whole
 object. I would like to see some profiling data before merge.

 There are also contexts where the object id is not easily to hand and so
 loading the main object is impossible. Take `is_protected_meta`, where the
 type isnt always passed, as it isn't always known.  This ticket effects
 #44238 which adds protected to the register meta and makes that patch much
 harder. It also effects #43941 of adding a meta default value. We should
 talk about these tickets here and create a roadmap for where we see
 register_meta going in the future.

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


More information about the wp-trac mailing list