Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/14/2014 12:50:26 AM (10 years ago)
Author:
boonebgorges
Message:

In update_meta() functions, return integer value if a new metadata is created

Previously, BP update_meta() functions returned true on a successful update
*or* on the successful creation of new metadata. This is not consistent with
WP's update_metadata(), which on the creation of new metadata acts as a wrapper
for add_metadata(), which in turn returns an integer (the ID of the newly
created database row).

This changeset aligns BP's behavior with WP's.

We don't have any tests that directly address the data type returned by these
functions, but we do have a number of assertTrue assertions to verify the
setup of various tests. Where appropriate, these have been changed to the more
generous assertNotEmpty.

See #5399

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs/bp-blogs-functions.php

    r8130 r8132  
    921921 *        metadata entries with the specified value. Otherwise, update all
    922922 *        entries.
    923  * @return bool True on success, false on failure.
     923 * @return bool|int Returns false on failure. On successful update of existing
     924 *         metadata, returns true. On successful creation of new metadata,
     925 *         returns the integer ID of the new metadata row.
    924926 */
    925927function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value, $prev_value = '' ) {
     
    928930    $retval = update_metadata( 'blog', $blog_id, $meta_key, $meta_value, $prev_value );
    929931    remove_filter( 'query', 'bp_filter_metaid_column_name' );
    930 
    931     // Legacy - New items fall through to add_metadata(). Return true
    932     // instead of the ID returned from that function.
    933     if ( is_int( $retval ) ) {
    934         $retval = true;
    935     }
    936932
    937933    return $retval;
Note: See TracChangeset for help on using the changeset viewer.