Reviewscouk / magento2-reviews

Reviews.co.uk Magento 2 Integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deprecated Functionality: strpos(): Passing null to parameter #1

richjones87 opened this issue · comments

reviewscouk/reviews/Block/Product/Reviewwidget.php line 112 if colour is NULL in the admin this line fails. replacing the line with sorts this.

if (strpos($colour ?? '', '#') === false) {

reviewscouk/reviews/Block/Product/Reviewwidget.php line 112 if colour is NULL in the admin this line fails. replacing the line with sorts this.

if (strpos($colour ?? '', '#') === false) {

Looks like the problem has been addressed in the latest release. However, there is another place in the same file that needs to be updated too. Here's the patch we used.

Index: vendor/reviewscouk/reviews/Block/Product/Reviewwidget.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/reviewscouk/reviews/Block/Product/Reviewwidget.php b/vendor/reviewscouk/reviews/Block/Product/Reviewwidget.php
--- a/vendor/reviewscouk/reviews/Block/Product/Reviewwidget.php
+++ b/vendor/reviewscouk/reviews/Block/Product/Reviewwidget.php
@@ -130,7 +130,7 @@ class Reviewwidget extends Framework\View\Element\Template
             $colour = '#' . $colour;
         }
         // checking to see if we hare a valid colour. If not then we change it to reviews default hex colour
-        if (!preg_match('/^#[a-f0-9]{6}$/i', $colour)) {
+        if ($colour && !preg_match('/^#[a-f0-9]{6}$/i', $colour)) {
             $colour = '#5db11f';
         }
         return $colour;