Product Gallery: add defensive check (#50495)

* Product Gallery: add defensive check

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Luigi Teschio 2024-08-09 17:52:32 +02:00 committed by GitHub
parent 1fbfa83fb4
commit 3425a2c017
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Comment: Product Gallery: add defensive check to avoid fatal errors.

View File

@ -74,6 +74,10 @@ class ProductGalleryLargeImageNextPrevious extends AbstractBlock {
$product = wc_get_product( $post_id );
if ( ! $product instanceof \WC_Product ) {
return '';
}
$product_gallery = $product->get_gallery_image_ids();
if ( empty( $product_gallery ) ) {