Ticket #30430: wp-deep-copy-2.diff
File wp-deep-copy-2.diff, 1004 bytes (added by , 10 years ago) |
---|
-
src/wp-includes/cache.php
244 244 } 245 245 246 246 /** 247 * Performs a deep copy of an item to ensure that arrays of objects 248 * are properly duplicated 249 * 250 * @param mixed $data The data to be duplicated 251 * @return mixed copy of the data 252 */ 253 function wp_deep_copy( $data ) { 254 if ( is_object( $data ) ) { 255 return clone $data; 256 } elseif ( is_array( $data ) ) { 257 $new = array(); 258 259 foreach ( $data as $key => $value ) { 260 $new[ $key ] = wp_deep_copy( $value ); 261 } 262 263 return $new; 264 } 265 266 return $data; 267 } 268 269 /** 247 270 * WordPress Object Cache 248 271 * 249 272 * The WordPress Object Cache is used to save on trips to the database. The … … 619 642 620 643 if ( is_object( $data ) ) 621 644 $data = clone $data; 645 elseif ( is_array( $data ) ) 646 $data = wp_deep_copy( $data ); 622 647 623 648 $this->cache[$group][$key] = $data; 624 649 return true;