Validate $object_id in *_metadata() functions. Props scribu fixes #11841

git-svn-id: http://svn.automattic.com/wordpress/trunk@13347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-02-23 22:42:54 +00:00
parent de8b58148c
commit c68fb87dee
1 changed files with 13 additions and 1 deletions

View File

@ -32,6 +32,9 @@ function add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique =
if ( !$meta_type || !$meta_key )
return false;
if ( !$object_id = absint($object_id) )
return false;
if ( ! $table = _get_meta_table($meta_type) )
return false;
@ -85,6 +88,9 @@ function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v
if ( !$meta_type || !$meta_key )
return false;
if ( !$object_id = absint($object_id) )
return false;
if ( ! $table = _get_meta_table($meta_type) )
return false;
@ -138,7 +144,10 @@ function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v
* @return bool True on successful delete, false on failure.
*/
function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $delete_all = false) {
if ( !$meta_type || !$meta_key || (!$delete_all && ! (int)$object_id) )
if ( !$meta_type || !$meta_key )
return false;
if ( !$object_id = absint($object_id) && !$delete_all )
return false;
if ( ! $table = _get_meta_table($meta_type) )
@ -195,6 +204,9 @@ function get_metadata($meta_type, $object_id, $meta_key = '', $single = false) {
if ( !$meta_type )
return false;
if ( !$object_id = absint($object_id) )
return false;
$meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
if ( !$meta_cache ) {