The different behavior of the function uasort in PHP 5.5 and PHP 7.0

时光总嘲笑我的痴心妄想 提交于 2019-12-01 15:24:09

From the usort() documentation:

Note: If two members compare as equal, their relative order in the sorted array is undefined.

This is what you're seeing here. PHP 7 uses a different, partially stable sorting algorithm, so elements that compare equal according to your sorting function may now have a different order.

If you care about the sorting order of equal elements (and this is not just a testing issue), you should make it explicit in your comparison function.

Hartmut

Possible Solution

I've created a magento module to solve magento issues with totals calculation for php7. The issues I've experienced in particular were that taxes have been added twice to the grand total for pay with amazon module on the amazonpayments checkout page.

Credits

The solution was provided by archigrafix on https://magento.stackexchange.com/a/97107/35665 solved my issues - so this is simply the fix packed into a module.

Module:

https://github.com/hartmut-ltd/magento-php7-totals-fix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!