improve get_children transient validation (#38666)

Co-authored-by: Ron Rennick <ronald.rennick@automattic.com>
This commit is contained in:
Ron Rennick 2023-06-12 14:05:06 -03:00 committed by GitHub
parent 2039d8915e
commit 0e95435474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
improve get_children transient validation

View File

@ -119,11 +119,11 @@ class WC_Product_Variable_Data_Store_CPT extends WC_Product_Data_Store_CPT imple
public function read_children( &$product, $force_read = false ) {
$children_transient_name = 'wc_product_children_' . $product->get_id();
$children = get_transient( $children_transient_name );
if ( false === $children ) {
if ( empty( $children ) || ! is_array( $children ) ) {
$children = array();
}
if ( empty( $children ) || ! is_array( $children ) || ! isset( $children['all'] ) || ! isset( $children['visible'] ) || $force_read ) {
if ( ! isset( $children['all'] ) || ! isset( $children['visible'] ) || $force_read ) {
$all_args = array(
'post_parent' => $product->get_id(),
'post_type' => 'product_variation',