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

WordPress Trac noreply at wordpress.org
Mon May 14 13:56:09 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 flixos90):

 Replying to [comment:49 johnjamesjacoby]:
 > It is not a good idea to reuse terms. Types and subtypes are being
 specced out as names for things that have nothing to do with actual types
 or subtypes, which have been part of all programming languages for longer
 than we’ve been alive to use them.

 The full terms are "object types" and "object subtypes", and at least the
 first are not a new concept in core. The latter are also found in one
 location in core. But if it's these names feel off to you, we can think
 about alternatives. Content types and content subtypes? Meta types (this
 is the current name in the metadata functions) and meta subtypes?

 > Code in WordPress shouldn’t be confusing on purpose because it’s easy,
 and it definitely shouldn’t get more confusing because it’s already kinda
 confusing.

 Definitely. Which of the ideas do you find confusing?

 > The only way to fully move forward with the types and subtypes literally
 being talked about here is to invent a base `WP_Type` and `WP_Sub_Type`
 class that define what registered types and subtypes are, so taxonomies
 and post types and such can be connected to them.

 I personally like this idea and it was discussed before (see
 https://core.trac.wordpress.org/ticket/38323#comment:22), but later not
 pursued. On the other hand, such classes might clarify the concepts, but
 they aren't a necessity for the first iteration if we have a clear
 definition for these concepts anyway and document it.

 > Guessing at what core object types are, and not letting plugins declare
 their own object types and subtypes, leaves this fragile and unfinished.
 Just squatting a slug and hoping nothing collides was necessary ten years
 ago, and everyone has worked hard to code away from that idea.

 Plugins can add their own object types, for example by introducing their
 own database table. When they connect a custom metadata table to it, the
 metadata functions need to be called with the respective object type that
 identifies the table name, but also affects the hooks fired. For that very
 purpose, there is a filter in `get_object_subtype()` so that such a custom
 object type can also take care of defining how a subtype for it is
 detected on an entity.

 > Not to mention that these aren’t taxonomy subtypes, these are term
 subtypes. Terms are already a subtype of their taxonomy.

 In my understanding, terms are entities of the object type "term", and
 their behavior is further specified by the object subtype "taxonomy".

 > Types and subtypes are not good names for what’s being recommended here,
 unless we fill in all of the other gaps I mentioned above.

 As I mentioned in the beginning of this comment, please suggest
 alternative naming ideas from "object type" and "object subtype". I
 personally don't see the "type" and "subtype" parts of the name
 problematic. Maybe we should rather focus on the "object" part of the
 name. In the current meanings, the core object types are 'post', 'term',
 'comment' and 'user', each of which is defined by the fact that its
 entities are identified by a unique ID and they support meta. In
 multisite, 'blog' and 'site' (old naming conventions here because tied to
 DB) are also object types, for the same reason. Since this is all
 connected to metadata, maybe the names should be "meta type" and "meta
 subtype". Just thinking out loud here.

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


More information about the wp-trac mailing list