[wp-trac] [WordPress Trac] #32453: add_meta_box callback receives Post Object with ID a String instead of an Integer

WordPress Trac noreply at wordpress.org
Thu May 21 02:08:58 UTC 2015


#32453: add_meta_box callback receives Post Object with ID a String instead of an
Integer
--------------------------------+------------------------------
 Reporter:  adiant              |       Owner:
     Type:  defect (bug)        |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Options, Meta APIs  |     Version:  4.2.2
 Severity:  minor               |  Resolution:
 Keywords:                      |     Focuses:
--------------------------------+------------------------------

Comment (by dd32):

 Unfortunately this is a compatibility thing - All integers from the
 database are delivered to WordPress as numeric strings, not ints.

 Changing the fields to be ints can unfortunately introduce compatibility
 issues, see #22324 and #22324 for some details on that.

 Worth noting here, that you should always expect a numeric string OR
 integer for post ID's for maximum compatibility.

 For example, with the provided code, on a new-page view you'll see it as
 an int, but on an edit you'll see it as a numeric string.

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


More information about the wp-trac mailing list