google-code-export / wordpress-custom-content-type-manager

Automatically exported from code.google.com/p/wordpress-custom-content-type-manager
2 stars 1 forks source link

SP_Post inserts multiple rows #487

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you repeatedly update a record with custom fields, new rows in wp_postmeta 
are created for each custom field.  This occurs only if the "overwrite" option 
is left as false (the default).

See http://codex.wordpress.org/Class_Reference/wpdb

Original issue reported on code.google.com by ever...@fireproofsocks.com on 7 May 2013 at 4:55

GoogleCodeExporter commented 9 years ago
Ah... if the value already exists, e.g. meta_value = 123 and you "update" it to 
"123", $wpdb->update returns 0.

Solution: line 381 of SP_Post.php must use a triple equals ===:

if ($wpdb->update( $wpdb->postmeta, array('meta_value' => $v), array('post_id' 
=> $post_id, 'meta_key' => $k)) === false ) {

Original comment by ever...@fireproofsocks.com on 7 May 2013 at 5:00

GoogleCodeExporter commented 9 years ago
Committed revision 709411.

Original comment by ever...@fireproofsocks.com on 7 May 2013 at 6:33