Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

strpos(): Passing null to parameter #1 [duplicate]

Tags:

php

magento2

I'm having a problem with a Magento Extension.

Error: Deprecated Functionality: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Setup/ChangeMethodsFormat.php on line 40

Line 40 is: if (strpos($oldMethods, "\n") === false) {

function is:

     $oldMethods = $rule->getMethods();
        if (strpos($oldMethods, "\n") === false) {
            continue;
        }

can somebody help me?

PHP Version: 8.1.7

like image 365
Oscar Avatar asked Nov 28 '25 09:11

Oscar


1 Answers

The error says that $oldMethods is null. So you could check for that:

if ($oldMethods !== null || strpos($oldMethods, "\n") === false){
continue;
}

I assume that or is the correct operator.

like image 78
schmauch Avatar answered Nov 30 '25 21:11

schmauch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!