Merge pull request #14206 from woocommerce/fix/14118

__clone meta correctly on object clone
This commit is contained in:
Claudio Sanches 2017-04-10 18:49:49 -03:00 committed by GitHub
commit 2acc956254
1 changed files with 16 additions and 0 deletions

View File

@ -131,6 +131,22 @@ abstract class WC_Data {
}
}
/**
* When the object is cloned, make sure meta is duplicated correctly.
*
* @since 3.0.2
*/
public function __clone() {
$this->maybe_read_meta_data();
if ( ! empty( $this->meta_data ) ) {
foreach ( $this->meta_data as $array_key => $meta ) {
if ( ! empty( $meta->id ) ) {
unset( $this->meta_data[ $array_key ]->id );
}
}
}
}
/**
* Get the data store.
*