Eliminate duplicate HPOS internal meta keys (#36611)

This commit is contained in:
Vedanshu Jain 2023-01-27 15:12:29 +05:30 committed by GitHub
commit dead6d7060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Eliminate data store internal meta keys duplicates

View File

@ -108,7 +108,15 @@ class WC_Data_Store_WP {
* @return mixed|void
*/
public function filter_raw_meta_data( &$object, $raw_meta_data ) {
$this->internal_meta_keys = array_merge( array_map( array( $this, 'prefix_key' ), $object->get_data_keys() ), $this->internal_meta_keys );
$this->internal_meta_keys = array_unique(
array_merge(
array_map(
array( $this, 'prefix_key' ),
$object->get_data_keys()
),
$this->internal_meta_keys
)
);
$meta_data = array_filter( $raw_meta_data, array( $this, 'exclude_internal_meta_keys' ) );
return apply_filters( "woocommerce_data_store_wp_{$this->meta_type}_read_meta", $meta_data, $object, $this );
}