Fix slashing in Custom fields values. Allow for the meta_key to be updated without changing meta_value. Use wpdb::insert in add_meta(). Fixes #12418

git-svn-id: https://develop.svn.wordpress.org/trunk@13489 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse
2010-02-28 07:12:05 +00:00
parent 1a258ebff7
commit df84c657f9
3 changed files with 10 additions and 10 deletions
+2 -2
View File
@@ -854,7 +854,7 @@ case 'add-meta' :
'position' => 1,
'supplemental' => array('postid' => $pid)
) );
} else {
} else { // Update?
$mid = (int) array_pop(array_keys($_POST['meta']));
$key = $_POST['meta'][$mid]['key'];
$value = $_POST['meta'][$mid]['value'];
@@ -862,7 +862,7 @@ case 'add-meta' :
die('0'); // if meta doesn't exist
if ( !current_user_can( 'edit_post', $meta->post_id ) )
die('-1');
if ( $meta->meta_value != stripslashes($value) ) {
if ( $meta->meta_value != stripslashes($value) || $meta->meta_key != stripslashes($key) ) {
if ( !$u = update_meta( $mid, $key, $value ) )
die('0'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
}