Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStoreMeta::is_valid_cached_meta
Determine whether a cached meta entry is a well-formed array of meta rows.
An empty array is valid: it represents an order with no meta. Each non-empty element must be an object carrying the meta_id, meta_key and meta_value properties that database-backed rows always have (see CustomMetaDataStore::get_meta_data_for_object_ids()) and that downstream consumers read.
Method of the class: OrdersTableDataStoreMeta{}
No Hooks.
Returns
true|false. True when the value is a usable array of meta rows.
Usage
// private - for code of main (parent) class only $result = $this->is_valid_cached_meta( $object_meta ): bool;
- $object_meta(mixed) (required)
- The cached value to validate.
OrdersTableDataStoreMeta::is_valid_cached_meta() OrdersTableDataStoreMeta::is valid cached meta code WC 11.0.1
private function is_valid_cached_meta( $object_meta ): bool {
if ( ! is_array( $object_meta ) ) {
return false;
}
foreach ( $object_meta as $meta_row ) {
if ( ! is_object( $meta_row )
|| ! property_exists( $meta_row, 'meta_id' )
|| ! property_exists( $meta_row, 'meta_key' )
|| ! property_exists( $meta_row, 'meta_value' ) ) {
return false;
}
}
return true;
}