From 6834a29edc79cc448b9fba0665bb419e41b58eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannu=20Po=CC=88lo=CC=88nen?= Date: Wed, 27 May 2020 14:13:41 +0300 Subject: [PATCH] Add null guard after product cache rebuild --- CHANGELOG.md | 3 +++ Model/Service/Product/CachingProductService.php | 10 ++++++++++ composer.json | 2 +- etc/module.xml | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c87408ee..54b1192b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning. +# 4.0.8 +* Add null guard for caching product service in case the product data building fails for dirty product + # 4.0.7 * Handle empty / invalid product cache entries and possible failures in product data building gracefully diff --git a/Model/Service/Product/CachingProductService.php b/Model/Service/Product/CachingProductService.php index 6e53db9f4..2a300f3cd 100644 --- a/Model/Service/Product/CachingProductService.php +++ b/Model/Service/Product/CachingProductService.php @@ -110,6 +110,16 @@ public function getProduct(ProductInterface $product, StoreInterface $store) //If it is dirty rebuild the product data if ($cachedProduct->getIsDirty()) { $cachedProduct = $this->nostoCacheService->rebuildDirtyProduct($cachedProduct); + if ($cachedProduct == null) { + $this->nostoLogger->debug( + sprintf( + 'Unable to rebuild dirty cache entry for product #%s for store %s', + $product->getId(), + $store->getCode() + ) + ); + return null; + } } //Check that we actually got serializable data $productData = $cachedProduct->getProductData(); diff --git a/composer.json b/composer.json index 653c2717f..431ecc680 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "nosto/module-nostotagging", "description": "Increase your conversion rate and average order value by delivering your customers personalized product recommendations throughout their shopping journey.", "type": "magento2-module", - "version": "4.0.7", + "version": "4.0.8", "require-dev": { "php": ">=7.1.0", "phan/phan": "0.8.8", diff --git a/etc/module.xml b/etc/module.xml index 794ef6374..509d78cc5 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -37,5 +37,5 @@ - +