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

props leewillis77.
fixes #24933.

Built from https://develop.svn.wordpress.org/trunk@25583


git-svn-id: http://core.svn.wordpress.org/trunk@25500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-09-23 20:31:09 +00:00
parent 74f42a9dc4
commit 4ea86c6b47
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.