[wp-trac] [WordPress Trac] #59705: get_metadata_raw() will return false when unserialize() fails

WordPress Trac noreply at wordpress.org
Mon Oct 23 11:16:16 UTC 2023


#59705: get_metadata_raw() will return false when unserialize() fails
--------------------------------+-----------------------------
 Reporter:  igorsch             |      Owner:  (none)
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:  5.8
 Severity:  normal              |   Keywords:
  Focuses:                      |
--------------------------------+-----------------------------
 The return value of get_metadata_raw() is documented as follows:
 > *               False for an invalid `$object_id` (non-numeric, zero, or
 negative value),
 > *               or if `$meta_type` is not specified.
 Source: https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-
 includes/meta.php#L596:L597

 However, if your metadata contains serialized data that is incorrect for
 some reason, maybe_unserialize() will (also) return `false`.
 Source: https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-
 includes/meta.php#L661

 E.g. `a:2:{s:3:"foo";b:1;}` is invalid due to it expecting 2 entries, but
 only 1 is present.

 History check; It seems to have been made a lot more precise (but missing
 this minor case):
 * https://core.trac.wordpress.org/ticket/51797
 * https://github.com/WordPress/wordpress-
 develop/commit/3bb06ce10b8ddac22091803b2e85832ed3ca3b1b

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


More information about the wp-trac mailing list