Skip to content

Commit

Permalink
Deprecated functionality: strlen() in Tablerate.php
Browse files Browse the repository at this point in the history
In order to reproduce this issue use a table rate in your test environment then follow the checkout steps to the end. Starting with PHP 8.1 to 8.3 you will get this error in the OM log file.

```
Deprecated functionality: strlen(): Passing null to parameter #1 ($string) of type string is deprecated  in /var/www/html/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php on line 131
```

My approach is using strlen($variable ?? '') but it could be strlen((string) $variabile) too. I am open to opinions.
  • Loading branch information
ADDISON74 committed Jul 3, 2024
1 parent 93288c0 commit ba21954
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function getRate(Mage_Shipping_Model_Rate_Request $request)

$i = 0;
$postcode = $request->getDestPostcode();
while (strlen($postcode) > 1) {
while (strlen($postcode ?? '') > 1) {
$i++;
$postcode = substr($postcode, 0, -1);
$bind[':wildcard_postcode_' . $i] = "{$postcode}*";
Expand Down

0 comments on commit ba21954

Please sign in to comment.