[wp-trac] [WordPress Trac] #35658: Provide additional data for registered meta through register_meta()

WordPress Trac noreply at wordpress.org
Thu Jun 30 15:19:47 UTC 2016


#35658: Provide additional data for registered meta through register_meta()
-------------------------------------------------+-------------------------
 Reporter:  jeremyfelt                           |       Owner:  helen
     Type:  task (blessed)                       |      Status:  accepted
 Priority:  normal                               |   Milestone:  4.6
Component:  Options, Meta APIs                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  needs-unit-tests needs-testing has-  |     Focuses:
  patch rest-api                                 |
-------------------------------------------------+-------------------------

Comment (by Faison):

 I gave this a test and ran into a couple of bugs which are fixed in
 [https://core.trac.wordpress.org/attachment/ticket/35658/35658.20.diff
 35658.20.diff]

 * In `get_registered_metadata()`, some code was treating the variable
 `$meta_keys` as the global `$wp_meta_keys`, causing invalid index issues
 * In `get_registered_metadata()`, we were accessing the value `single` as
 though `$meta_key_data` was an object when it's an associative array
 * In `register_meta()`, added `single` as a default option. Without that,
 you can't include `single` as an option when registering meta, which
 causes the value to never be set for when it's used in
 `get_registered_metadata()`

 Besides the items in the attached patch, I noticed some things that feel a
 little inconsistent between functions that I wanted to bring up for
 discussion:

 1. When `register_meta()` fails, it returns false, but
 `unregister_meta_key()` returns a `WP_Error`. It would be pretty valuable
 to know why register_meta() fails when it does, especially if the function
 is updated in the future and new points of failure are introduced
 2. `get_registered_meta_keys()` does no specific check for `$object_type`,
 when `register_meta()` checks and calls `_doing_it_wrong()` if an invalid
 object type is provided. `get_registered_metadata()` also performs a
 check, but returns a `WP_Error`. If I was using these functions, I
 probably would enjoy getting WP_Errors over a mix of
 false/WP_error/_doing_it_wrong.

 Otherwise, the changes happening on this ticket are awesome and I look
 forward to thinking up how I can use these in the future :)

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


More information about the wp-trac mailing list