From e58d26f377a71a4fb880da587fd6a071d834ca43 Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Thu, 29 Apr 2021 16:46:41 +0200 Subject: [PATCH] Fix: using "current" on a possibly "false" value. --- src/Internal/ProductAttributesLookup/DataRegenerator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Internal/ProductAttributesLookup/DataRegenerator.php b/src/Internal/ProductAttributesLookup/DataRegenerator.php index 8b175dad8d4..1e45d553c84 100644 --- a/src/Internal/ProductAttributesLookup/DataRegenerator.php +++ b/src/Internal/ProductAttributesLookup/DataRegenerator.php @@ -155,7 +155,7 @@ CREATE TABLE ' . $this->lookup_table_name . '( ); // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared - $last_existing_product_id = current( + $last_existing_product_id = wc_get_products( array( 'return' => 'ids', @@ -163,14 +163,14 @@ CREATE TABLE ' . $this->lookup_table_name . '( 'orderby' => 'id', 'order' => 'DESC', ) - ) - ); + ); + if ( false === $last_existing_product_id ) { // No products exist, nothing to (re)generate. return false; } - update_option( 'woocommerce_attribute_lookup__last_product_id_to_process', $last_existing_product_id ); + update_option( 'woocommerce_attribute_lookup__last_product_id_to_process', current( $last_existing_product_id ) ); update_option( 'woocommerce_attribute_lookup__last_products_page_processed', 0 ); return true;