From c5e92d47e8ee237806fc72dc4e2bdbf7b1de5ea3 Mon Sep 17 00:00:00 2001 From: ADDISON <8360474+ADDISON74@users.noreply.github.com> Date: Thu, 4 Jul 2024 22:43:20 +0300 Subject: [PATCH 1/3] Deprecated functionality: strlen(): Passing null to parameter #1 I am getting this error with PHP 8.3 in the system.log file: ```Deprecated functionality: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/app/code/core/Mage/Wishlist/Controller/Abstract.php on line 88``` **/app/code/core/Mage/Wishlist/Controller/Abstract.php on line 88** In order to reproduce this issue log into a customer account in the Frontend then add any product to the Wishlist. You will be redirected to the customer account. A part of the URL is **wishlist/index/index/wishlist_id/[PRODUCT_ID]/**. Press the [Add All to the Cart] button. In my case I am getting an error message because the product has custom options and I have to choose them. If you take a look into the /var/log directory you will see a nice system.log file, having 374 kB as size and inside the same line 1745 times. IMPORTANT NOTE: This PR has 3 implementations inside (3 lines, 2 commented), there may be others. Please share your opinions, at the end there will be only one line left. --- app/code/core/Mage/Wishlist/Controller/Abstract.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Wishlist/Controller/Abstract.php b/app/code/core/Mage/Wishlist/Controller/Abstract.php index dda3faab225..1a2cc56d187 100644 --- a/app/code/core/Mage/Wishlist/Controller/Abstract.php +++ b/app/code/core/Mage/Wishlist/Controller/Abstract.php @@ -85,7 +85,9 @@ public function allcartAction() $qtysString = $this->getRequest()->getParam('qty'); if (isset($qtysString)) { - $qtys = array_filter(json_decode($qtysString), '\strlen'); + $qtys = array_filter(json_decode($qtysString), fn($qtysString) => strlen($qtysString ?? '')); + // $qtys = array_filter(json_decode($qtysString), function ($qtysString) { return strlen($qtysString ?? ''); }); + // $qtys = @array_filter(json_decode($qtysString), '\strlen'); } /** @var Mage_Wishlist_Model_Item $item */ From 2d5d0475bf86bbef408600c7ca7bd2f24847c914 Mon Sep 17 00:00:00 2001 From: ADDISON <8360474+ADDISON74@users.noreply.github.com> Date: Fri, 5 Jul 2024 00:52:58 +0300 Subject: [PATCH 2/3] Update Abstract.php --- app/code/core/Mage/Wishlist/Controller/Abstract.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Wishlist/Controller/Abstract.php b/app/code/core/Mage/Wishlist/Controller/Abstract.php index 1a2cc56d187..e436c03e09e 100644 --- a/app/code/core/Mage/Wishlist/Controller/Abstract.php +++ b/app/code/core/Mage/Wishlist/Controller/Abstract.php @@ -85,8 +85,9 @@ public function allcartAction() $qtysString = $this->getRequest()->getParam('qty'); if (isset($qtysString)) { - $qtys = array_filter(json_decode($qtysString), fn($qtysString) => strlen($qtysString ?? '')); - // $qtys = array_filter(json_decode($qtysString), function ($qtysString) { return strlen($qtysString ?? ''); }); + $qtys = array_filter(json_decode($qtysString), fn($tmpString) => strlen($tmpString ?? '')); + // $qtys = array_filter(json_decode($qtysString), function ($tmpString) { return strlen($tmpString ?? ''); }); + // $qtys = array_filter(json_decode($qtysString), function ($tmpString) { return $tmpString !== NULL && strlen($tmpString); }); => From Drupal Community // $qtys = @array_filter(json_decode($qtysString), '\strlen'); } From 14b3fca599affd6d4e1fb555bf802e18bea71230 Mon Sep 17 00:00:00 2001 From: ADDISON <8360474+ADDISON74@users.noreply.github.com> Date: Sat, 6 Jul 2024 13:25:18 +0300 Subject: [PATCH 3/3] final-version --- app/code/core/Mage/Wishlist/Controller/Abstract.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/code/core/Mage/Wishlist/Controller/Abstract.php b/app/code/core/Mage/Wishlist/Controller/Abstract.php index e436c03e09e..b82a55c5637 100644 --- a/app/code/core/Mage/Wishlist/Controller/Abstract.php +++ b/app/code/core/Mage/Wishlist/Controller/Abstract.php @@ -85,10 +85,7 @@ public function allcartAction() $qtysString = $this->getRequest()->getParam('qty'); if (isset($qtysString)) { - $qtys = array_filter(json_decode($qtysString), fn($tmpString) => strlen($tmpString ?? '')); - // $qtys = array_filter(json_decode($qtysString), function ($tmpString) { return strlen($tmpString ?? ''); }); - // $qtys = array_filter(json_decode($qtysString), function ($tmpString) { return $tmpString !== NULL && strlen($tmpString); }); => From Drupal Community - // $qtys = @array_filter(json_decode($qtysString), '\strlen'); + $qtys = array_filter(json_decode($qtysString), fn ($tmpString) => strlen($tmpString ?? '')); } /** @var Mage_Wishlist_Model_Item $item */