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?

有帮助吗?

解决方案

There is no real impact: the wishlist_next parameter was in use until CE 1.3.3.0 and has been removed in CE 1.4.0.0.

Its use seemed to be an error handling feature whenever an exception was thrown while trying to move an item from a wishlist (the user's own wishlist or a shared wishlist) to the cart. I suspect this was made for the case when a wishlist item was not completely configured: instead of adding the item to the cart, the user is redirected to the product view page to which the query parameter wishlist_next = 1 is added; when the configuration is finished and the product is added to the cart, the wishlist_next parameter is passed to the addtocart url, where it was supposed to remove the original item from the wishlist.

Methods in which this functionality was present (with links to CE 1.3.3.0):

Note that there is a small impact when calling a product url with wishlist_next = 1: the item will be added to the cart, but instead of a success message an error message appears stating that the item could not be added to the cart.

许可以下: CC-BY-SA归因
scroll top