Deprecate wp_clone(). Call clone directly. Props hakre. fixes #16813

git-svn-id: http://svn.automattic.com/wordpress/trunk@17613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-04-06 17:44:29 +00:00
parent c5b47b029c
commit e3895262ef
5 changed files with 26 additions and 23 deletions

View File

@ -350,7 +350,7 @@ class WP_Object_Cache {
if ( isset ($this->cache[$group][$id]) ) {
$this->cache_hits += 1;
if ( is_object($this->cache[$group][$id]) )
return wp_clone($this->cache[$group][$id]);
return clone $this->cache[$group][$id];
else
return $this->cache[$group][$id];
}
@ -426,7 +426,7 @@ class WP_Object_Cache {
$data = '';
if ( is_object($data) )
$data = wp_clone($data);
$data = clone $data;
$this->cache[$group][$id] = $data;

View File

@ -1394,7 +1394,7 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
return false;
}
$comment_old = wp_clone(get_comment($comment_id));
$comment_old = clone get_comment($comment_id);
if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
if ( $wp_error )

View File

@ -2602,3 +2602,20 @@ function update_category_cache() {
return true;
}
/**
* Copy an object.
*
* Returns a cloned copy of an object.
*
* @since 2.7.0
* @deprecated 3.2
*
* @param object $object The object to clone
* @return object The cloned object
*/
function wp_clone( $object ) {
_deprecated_function( __FUNCTION__, '3.2' );
return clone $object;
}

View File

@ -509,7 +509,7 @@ function update_option( $option, $newvalue ) {
wp_protect_special_option( $option );
if ( is_object($newvalue) )
$newvalue = wp_clone($newvalue);
$newvalue = clone $newvalue;
$newvalue = sanitize_option( $option, $newvalue );
$oldvalue = get_option( $option );
@ -590,8 +590,12 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
wp_protect_special_option( $option );
/*
* FIXME the next two lines of code are not necessary and should be removed.
* @see http://core.trac.wordpress.org/ticket/13480
*/
if ( is_object($value) )
$value = wp_clone($value);
$value = clone $value;
$value = sanitize_option( $option, $value );

View File

@ -553,24 +553,6 @@ function shutdown_action_hook() {
wp_cache_close();
}
/**
* Copy an object.
*
* Returns a cloned copy of an object.
*
* @since 2.7.0
*
* @param object $object The object to clone
* @return object The cloned object
*/
function wp_clone( $object ) {
static $can_clone;
if ( !isset( $can_clone ) )
$can_clone = version_compare( phpversion(), '5.0', '>=' );
return $can_clone ? clone( $object ) : $object;
}
/**
* Whether the current request is for a network or blog admin page
*