[wp-trac] [WordPress Trac] #38082: Allow negative (placeholder) IDs in calls to get_metadata

WordPress Trac noreply at wordpress.org
Sat Sep 17 21:33:21 UTC 2016


#38082: Allow negative (placeholder) IDs in calls to get_metadata
--------------------------------+-----------------------------
 Reporter:  westonruter         |      Owner:
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:
 Severity:  normal              |   Keywords:
  Focuses:                      |
--------------------------------+-----------------------------
 See #38072 for full background. Nav menu items are created in the
 customizer with negative IDs to serve as placeholders. This allows such
 nav menu items to be referenced before writing to the database. This works
 for previewing `nav_menu_item` posts, but it turns out to not work for
 postmeta for such posts. The reason for this is `get_metadata` uses
 `absint` as opposed to `intval` and so the placeholder nature of the
 object ID is dropped. Along with this change the `get_metadata` function
 can short-circuit for such negative IDs after the
 `get_{$meta_type}_metadata` filters apply since no such objects would
 exist in in the database which uses `UNSIGNED INTEGER` for ID fields. As
 such, placeholder meta would only be supplied via filters.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38082>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list