Hacking core eCommerce for php7 and c5.6.4

Permalink
I have been working my way through core eCommerce to get it running as smoothly as possible under php7 and the prospective c5.6.4 on github.

For anyone else doing similar, here is a summary of the code changes I have so far found necessary. Line numbers may not be precise because the cumulative effect of changes can shift them down a bit.
core_commerce/libraries/discount/controller.php
[controller.php at line 34, column 50]      
public function setupAndRun($method=null) // php7, make optional
core_commerce/libraries/payment/controller.php
[controller.php at line 19, column 50]     
public function setupAndRun($method=null) // php7, make optional
core_commerce/libraries/shipping/controller.php
[controller.php at line 25, column 50]      
public function setupAndRun($method=null) // php7, make optional
core_commerce/models/attribute/categories/core_commerce_order.php
[core_commerce_order.php at line 15, column 54]      
public function load($akID, $loadBy = 'akID') // php7, match parameters
core_commerce/models/attribute/categories/core_commerce_product.php
[core_commerce_product.php at line 55, column 54]      
public function load($akID, $loadBy = 'akID') // php7, match parameters


So far, that has cured everything in a benign way, except for one really bad parameter mismatch in
core_commerce/models/attribute/types/product_price_adjustment_select/controller.php, CoreCommerceProductAdjustmentSelectAttributeTypeOption::add

The solution to that is a bit more hacky, to suppress the warning. I found and adapted a trick on stack overflow at https://stackoverflow.com/questions/36079651/silence-declaration-sho... . Rather than suppress all warnings, or all declaration warnings, I adapted to catch the specific warning.
if (PHP_MAJOR_VERSION >= 7) {
    set_error_handler(function ($errno, $errstr) {
        if(strpos($errstr, 'Declaration of CoreCommerceProductAdjustmentSelectAttributeTypeOption::add') === 0){
            return true;
        }
    }, E_WARNING);
}


For convenience I currently have this code at the bottom of /config/site.php.

The snippet could be adapted to target other specific warnings, though it is always better to resolve the source of the problem.

Anyway, with this in place I now have a dev clone of an eCommerce site running under php7. My own Zone Based Shipping addon, also used on the site, runs happily with php7.

If I find any more changes needed to make eCommerce behave under php7, I will post to this thread.

JohntheFish
 
JohntheFish replied on at Permalink Reply
JohntheFish
A couple of days on and I have found no further php7 compatibility issues. For anyone doing similar, you can regard the above list as pretty much complete.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
This could be a very useful addition for 5.6.4 running on PHP 7.x
I am a little confused with the term 'core' as I thought eCommerce was a paid 5.6 addon.
Is there a plan to incorporate eCommerce into the 5.6.4 core?
JohntheFish replied on at Permalink Reply
JohntheFish
My apologies for any confusion.

The package handle is core_commerce, even though its name is eCommerce. It was developed by the 'core team' at Prortland Labs.

AFAIK, there are no moves for integration with the 5.6.4 core.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Ah yes I see,
Thank You
JohntheFish replied on at Permalink Reply
JohntheFish
A few more changes are needed to move from php7/7.1 to php7.2. Any use of the class Object needs to be replaced with the class ConcreteObject.

Details are listed at https://www.c5magic.co.uk/add-ons/zone-based-shipping/php7/...