[wp-trac] [WordPress Trac] #27424: Dubious code flow in add_metadata()
WordPress Trac
noreply at wordpress.org
Sat Mar 15 18:03:45 UTC 2014
#27424: Dubious code flow in add_metadata()
--------------------------------+-----------------------------
Reporter: Denis-de-Bernardy | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version: 3.8.1
Severity: normal | Keywords:
Focuses: |
--------------------------------+-----------------------------
The code goes:
{{{
$result = $wpdb->insert( $table, array(
$column => $object_id,
'meta_key' => $meta_key,
'meta_value' => $meta_value
) );
if ( ! $result )
return false;
$mid = (int) $wpdb->insert_id;
wp_cache_delete($object_id, $meta_type . '_meta');
}}}
If $result up there is false, it probably means the key exists in the
database. In other words, the cache is stale.
Should be:
{{{
$result = $wpdb->insert( $table, array(
$column => $object_id,
'meta_key' => $meta_key,
'meta_value' => $meta_value
) );
wp_cache_delete($object_id, $meta_type . '_meta');
if ( ! $result )
return false;
$mid = (int) $wpdb->insert_id;
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27424>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list