WordPress.org

Make WordPress Core

Changeset 48502


Ignore:
Timestamp:
07/17/2020 02:57:04 AM (2 months ago)
Author:
TimothyBlynJacobs
Message:

Meta: Reorder the get_metadata_default() signature to match get_metadata().

The order of parameters in get_metadata_default() did not match the signature of get_metadata(). This could be confusing for developers who are familiar with the existing metadata API.

Fixes #43941.
Props SergeyBiryukov, spacedmonkey, johnjamesjacoby.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/meta.php

    r48473 r48502  
    509509    }
    510510
    511     return get_metadata_default( $meta_type, $meta_key, $single, $object_id );
     511    return get_metadata_default( $meta_type, $object_id, $meta_key, $single );
    512512}
    513513
     
    596596 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
    597597 *                          or any other object type with an associated meta table.
    598  * @param string $meta_key  Metadata key.
     598 * @param int    $object_id ID of the object metadata is for.
     599 * @param string $meta_key  Metadata key. If not specified, retrieve all metadata for
     600 *                          the specified object. Default empty.
    599601 * @param bool   $single    Optional. If true, return only the first value of the specified meta_key.
    600602 *                          This parameter has no effect if meta_key is not specified. Default false.
    601  * @param int    $object_id Optional. ID of the object metadata is for. Default 0.
    602603 * @return mixed Single metadata value, or array of values.
    603604 */
    604 function get_metadata_default( $meta_type, $meta_key, $single = false, $object_id = 0 ) {
     605function get_metadata_default( $meta_type, $object_id, $meta_key, $single = false ) {
    605606    if ( $single ) {
    606607        $value = '';
  • trunk/tests/phpunit/tests/meta/registerMeta.php

    r48411 r48502  
    521521        $object_property_name = $object_type . '_id';
    522522        $object_id            = self::$$object_property_name;
    523         $default_value        = get_metadata_default( $object_type, $meta_key, $single, $object_id );
     523        $default_value        = get_metadata_default( $object_type, $object_id, $meta_key, $single );
    524524        $this->assertSame( $default_value, $expected );
    525525
     
    568568        $object_property_name = $object_type . '_id';
    569569        $object_id            = self::$$object_property_name;
    570         $default_value        = get_metadata_default( $object_type, $meta_key, $single, $object_id );
     570        $default_value        = get_metadata_default( $object_type, $object_id, $meta_key, $single );
    571571        $this->assertSame( $default_value, $expected );
    572572    }
Note: See TracChangeset for help on using the changeset viewer.