Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
richjones87 opened this issue Mar 17, 2023 · 1 comment
Open

Comments

@richjones87
Copy link

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) {

@avstaylime
Copy link

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants