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

WordPress Trac noreply at wordpress.org
Thu Jun 30 17:39:29 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 sc0ttkclark):

 Replying to [comment:79 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]

 This patch fix looks good to me.

 > 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

 You know, we never returned before, I'd love to use WP_Error more often
 for new failed return values, this sounds like a good spot we could do
 that.

 > 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.

 Our $object_type limitation is one I'm not entirely behind, but yeah the
 difference here seems odd, we should probably return and WP_Error instead
 of running just _doing_it_wrong() here, for consistency.

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


More information about the wp-trac mailing list