The release of 1.9.4.0 introduces two programming errors in the wishlist observer: in order to make the method Mage_Wishlist_Model_Observer::processAddToCart
compatible with PHP 7.2, the two usages of count
on a possible NULL
value are replaced by empty
while it should have been !empty
.
This is the diff between 1.9.3.10 and 1.9.4.0 of the file app/code/core/Mage/Wishlist/Model/Observer.php
:
--- a/app/code/core/Mage/Wishlist/Model/Observer.php
+++ b/app/code/core/Mage/Wishlist/Model/Observer.php
@@ -102,7 +102,7 @@ class Mage_Wishlist_Model_Observer extends Mage_Core_Model_Abstract
$wishlistIds = array($singleWishlistId);
}
- if (count($wishlistIds) && $request->getParam('wishlist_next')){
+ if (empty($wishlistIds) && $request->getParam('wishlist_next')){
$wishlistId = array_shift($wishlistIds);
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
@@ -125,7 +125,7 @@ class Mage_Wishlist_Model_Observer extends Mage_Core_Model_Abstract
Mage::getSingleton('checkout/session')->setSingleWishlistId(null);
}
- if ($request->getParam('wishlist_next') && count($urls)) {
+ if ($request->getParam('wishlist_next') && empty($urls)) {
$url = array_shift($urls);
$message = array_shift($messages);
the impact of this error is not clear to me: on the one hand the bodies of the if
statements are executed exactly in wrong circumstances resulting in wishlist items not being deleted, incorrect/missing error messages in the session and redirects to NULL
. But on the other hand, this logic is only triggered when the wishlist_next
query parameter has a truthy value. However, I cannot find any place where wishlist_next
query parameter is set.
So my question is: what is the real impact of these programming errors?
empty()
vscount()
usage, and I too cannot find anywhere in the code wherewishlist_next
is set orsetWishlistNext()
is called.wishlist_next
was in use until CE 1.3.3.0, and has been removed in CE 1.4.0.0.