[wp-trac] [WordPress Trac] #10905: Do not allow duplicate (post_id, meta_key, meta_value) rows in meta tables

WordPress Trac wp-trac at lists.automattic.com
Sun Jan 3 00:33:33 UTC 2010


#10905: Do not allow duplicate (post_id, meta_key, meta_value) rows in meta tables
--------------------------+-------------------------------------------------
 Reporter:  scribu        |       Owner:  ryan     
     Type:  defect (bug)  |      Status:  new      
 Priority:  normal        |   Milestone:  3.0      
Component:  Database      |     Version:  2.9      
 Severity:  normal        |    Keywords:  has-patch
--------------------------+-------------------------------------------------

Comment(by arena):

 Not sure the duplicates (meta_key, meta_value) should not be allowed as it
 is supported today !

 '''A.''' To complete the api, following functions should be added

 ''1.'' update_metadata_by_id($meta_type, $meta_id, $meta_value, $meta_key
 = false)

 ''2.'' delete_metadata_by_id($meta_type, $meta_id) ( see function
 delete_meta() )

 ''3.'' get_metadata_by_id($meta_type, $meta_id)

 '''B.''' For code consistency, make a definitive choice between
 '''$type_column''' or '''$column'''

 '''C.''' add_metadata should return inserted id :
 {{{
         $result = $wpdb->insert( $table, array(
                 $type_column => $object_id,
                 'meta_key' => $meta_key,
                 'meta_value' => $meta_value
         ) );

         if ($result) {
                 $result = $wpdb->insert_id;
                 wp_cache_delete($object_id, $meta_type . '_meta');
                 do_action( "added_{$meta_type}_meta", $wpdb->insert_id,
 $object_id, $meta_key, $meta_value );
         }

         return $result;
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10905#comment:17>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list