imagekit-developer / imagekit-magento

Magento 2 ImageKit Integration
MIT License
1 stars 2 forks source link

Depreciated Functionality: strpos(): Passing null to parameter #1 ($haystack) of type string is depreciated #9

Closed ecrocombe closed 1 year ago

ecrocombe commented 1 year ago

Preconditions and environment: Magento 2.4.5-p1 PHP 8.1.2-1ubuntu2.9 imagekit/imagekit 1.2.2 imagekit/imagekit-magento 1.0.4

Steps to reproduce:

  1. Login to admin panel
  2. Click Catalog >> Products

Expected result Display a table of products.

Actual result Error message displayed instead of table.

Untitled

Additional information Issue appears to originate from the imagekit/imagekit v1.2.2 (SDK) and not the Magento Module (imagekit/imagekit-magento). It looks like this is fixed in more recent versions of imagekit/imagekit (v3), however imagekit/imagekit-magento's composer requires 1.2.2 of imagekit/imagekit.

For those finding this via search, I was able to temp fix this by modifying line 197 of /vendor/imagekit/imagekit/src/ImageKit/Url/Url.php FROM

if (strpos($value, '/') !== false) {
    $finalres .= str_replace('/', '@@', $value);
} else {
    $finalres .= $value;
}

TO

if (is_string($value) && strlen($value) > 0 && strpos($value, '/') !== false) {
    $finalres .= str_replace('/', '@@', $value);
} else {
    $finalres .= $value;
}

WARNING: The above temporary solution is thoroughly untested, use at your own risk.

hans2103 commented 1 year ago

I can reproduce the issue. Using the provided code I was able to fix it on one of my shops. @imagekitio can you update your Magento plugin?