Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

TotalsCalculation

Ivan Čurdinjaković edited this page Feb 17, 2017 · 4 revisions

Update: we implemented Topological sort for proper ordering when doing totals calculation, so, with new versions of this extension, totals calculation should just work, even with 3rd party extensions.

Everything below is just of historical significance now :-)


Daniel Sloof, the original author of XML fix for totals calculation in this extension, put it succintly:

...it's the fact that PHP (as a language, not the respective implementations) don't impose strict sorting orders.

See for example uasort:

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

Both PHP7 and HHVM will handle sorting differently, due to implementing faster sorting algo's. The module above only fixes the order on clean Magento installations; any 3rd party extension that adds a total collector may (or may not) screw up the ordering again.

In HHVM you can use EnableZendSorting to fall back to PHP5 style sort ordering (for the undefined behavior). I don't think there's such a thing in PHP7 though. This isn't a bad thing, because you shouldn't rely on undefined behavior anyway.

It would require a fix in Magento core to solve this problem for good.


So, I'll just sum it up: XML fix implemented in Inchoo_PHP7 is good for PHP 7 and Magento Core, but, if there are 3rd party extensions adding stuff to calculation, test extensively - it may still work all right, or it may not.

Clone this wiki locally