Return false in update_metadata() and update_metadata_by_mid() when the DB query fails.

props leewillis77.
fixes #24933.


git-svn-id: https://develop.svn.wordpress.org/trunk@25583 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-09-23 20:31:01 +00:00
parent 164d6cf220
commit 169ac00ea5
1 changed files with 7 additions and 3 deletions

View File

@ -151,7 +151,9 @@ function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v
if ( 'post' == $meta_type )
do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
$wpdb->update( $table, $data, $where );
$result = $wpdb->update( $table, $data, $where );
if ( ! $result )
return false;
wp_cache_delete($object_id, $meta_type . '_meta');
@ -435,7 +437,9 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key =
do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
// Run the update query, all fields in $data are %s, $where is a %d.
$result = (bool) $wpdb->update( $table, $data, $where, '%s', '%d' );
$result = $wpdb->update( $table, $data, $where, '%s', '%d' );
if ( ! $result )
return false;
// Clear the caches.
wp_cache_delete($object_id, $meta_type . '_meta');
@ -445,7 +449,7 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key =
if ( 'post' == $meta_type )
do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
return $result;
return true;
}
// And if the meta was not found.