Skip to content

Commit 259c415

Browse files
committed
Deprecate wp_clone(). Call clone directly. Props hakre. fixes #16813
git-svn-id: https://develop.svn.wordpress.org/trunk@17613 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 71eeebc commit 259c415

5 files changed

Lines changed: 26 additions & 23 deletions

File tree

wp-includes/cache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ function get($id, $group = 'default') {
350350
if ( isset ($this->cache[$group][$id]) ) {
351351
$this->cache_hits += 1;
352352
if ( is_object($this->cache[$group][$id]) )
353-
return wp_clone($this->cache[$group][$id]);
353+
return clone $this->cache[$group][$id];
354354
else
355355
return $this->cache[$group][$id];
356356
}
@@ -426,7 +426,7 @@ function set($id, $data, $group = 'default', $expire = '') {
426426
$data = '';
427427

428428
if ( is_object($data) )
429-
$data = wp_clone($data);
429+
$data = clone $data;
430430

431431
$this->cache[$group][$id] = $data;
432432

wp-includes/comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
13941394
return false;
13951395
}
13961396

1397-
$comment_old = wp_clone(get_comment($comment_id));
1397+
$comment_old = clone get_comment($comment_id);
13981398

13991399
if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
14001400
if ( $wp_error )

wp-includes/deprecated.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,3 +2602,20 @@ function update_category_cache() {
26022602
return true;
26032603
}
26042604

2605+
2606+
/**
2607+
* Copy an object.
2608+
*
2609+
* Returns a cloned copy of an object.
2610+
*
2611+
* @since 2.7.0
2612+
* @deprecated 3.2
2613+
*
2614+
* @param object $object The object to clone
2615+
* @return object The cloned object
2616+
*/
2617+
function wp_clone( $object ) {
2618+
_deprecated_function( __FUNCTION__, '3.2' );
2619+
2620+
return clone $object;
2621+
}

wp-includes/functions.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ function update_option( $option, $newvalue ) {
509509
wp_protect_special_option( $option );
510510

511511
if ( is_object($newvalue) )
512-
$newvalue = wp_clone($newvalue);
512+
$newvalue = clone $newvalue;
513513

514514
$newvalue = sanitize_option( $option, $newvalue );
515515
$oldvalue = get_option( $option );
@@ -590,8 +590,12 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
590590

591591
wp_protect_special_option( $option );
592592

593+
/*
594+
* FIXME the next two lines of code are not necessary and should be removed.
595+
* @see http://core.trac.wordpress.org/ticket/13480
596+
*/
593597
if ( is_object($value) )
594-
$value = wp_clone($value);
598+
$value = clone $value;
595599

596600
$value = sanitize_option( $option, $value );
597601

wp-includes/load.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -553,24 +553,6 @@ function shutdown_action_hook() {
553553
wp_cache_close();
554554
}
555555

556-
/**
557-
* Copy an object.
558-
*
559-
* Returns a cloned copy of an object.
560-
*
561-
* @since 2.7.0
562-
*
563-
* @param object $object The object to clone
564-
* @return object The cloned object
565-
*/
566-
function wp_clone( $object ) {
567-
static $can_clone;
568-
if ( !isset( $can_clone ) )
569-
$can_clone = version_compare( phpversion(), '5.0', '>=' );
570-
571-
return $can_clone ? clone( $object ) : $object;
572-
}
573-
574556
/**
575557
* Whether the current request is for a network or blog admin page
576558
*

0 commit comments

Comments
 (0)