Addressed PR review comments #27734

This commit is contained in:
vedanshujain 2020-10-21 14:53:28 +05:30
parent 3dd80d6d65
commit 6ed8ffe850
2 changed files with 4 additions and 7 deletions

View File

@ -594,11 +594,8 @@ abstract class WC_Data {
}
}
$raw_meta_data = $cache_loaded ? $cached_meta : $this->data_store->read_meta( $this );
if ( $cache_loaded ) {
// Filter the raw meta data again, in case we cached in an earlier version where filter conditions were different.
$raw_meta_data = $this->data_store->filter_raw_data( $this, $raw_meta_data );
}
// We filter the raw meta data again when loading from cache, in case we cached in an earlier version where filter conditions were different.
$raw_meta_data = $cache_loaded ? $this->data_store->filter_raw_meta_data( $this, $cached_meta ) : $this->data_store->read_meta( $this );
if ( $raw_meta_data ) {
foreach ( $raw_meta_data as $meta ) {

View File

@ -94,7 +94,7 @@ class WC_Data_Store_WP {
$object->get_id()
)
);
return $this->filter_raw_data( $object, $raw_meta_data );
return $this->filter_raw_meta_data( $object, $raw_meta_data );
}
/**
@ -107,7 +107,7 @@ class WC_Data_Store_WP {
*
* @return mixed|void
*/
public function filter_raw_data( &$object, $raw_meta_data ) {
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 );
$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 );