EmicoEcommerce / Magento2Tweakwise-archived

Magento 2 module for Tweakwise integration
Other
9 stars 25 forks source link

PathSlugStrategy::skip will throw an error when $requestPath is shorter then $fileExtention #130

Closed jasperzeinstra closed 3 years ago

jasperzeinstra commented 3 years ago

Issue Brief

We receive a warning on 404 pages when the request path is only 3 characters long, like 'https://www.webshop.nl/asd'

Environment

Steps to reproduce

  1. Go to 404 page with url "asd"

Actual result

1.A warning is thrown: Warning: strpos(): Offset not contained in string

Expected result

The regular 404 page is shown.

Tech hint -- See comment in: https://github.com/EmicoEcommerce/Magento2Tweakwise/commit/fb28e32ef60b2965e2017ebc0a4ee27e83b68ba2

you're working with a negative offset for Strpos, but you're not checking if the string is as long or longer then the provided negative offset. This will throw an error on 404 url's with only 3 charachters.

\Emico\Tweakwise\Model\Catalog\Layer\Url\Strategy\PathSlugStrategy::skip

$requestPath = 'asd';
$fileExtention = '.jpg';

echo strpos($requestPath, $fileExtention, -\strlen($fileExtention));

Will throw the error: Warning: strpos(): Offset not contained in string

edwinljacobs commented 3 years ago

Thanks, issue is clear

edwinljacobs commented 3 years ago

https://github.com/EmicoEcommerce/Magento2Tweakwise/releases/tag/v3.0.3 should fix this issue. We did not take that into account :( Thanks for pointing that out