This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

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 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

core_commerce/models/attribute/categories/core_commerce_product_option.php [core_commerce_product_option.php at line 95, column 62]

public static function sortListByDisplayOrder($a, $b) // php7

[core_commerce_product_option.php at line 156, column 54]

public function load($akID, $loadBy = 'akID') // php7, match parameters

[core_commerce_product_option.php at line 166, column 55]

public function duplicate($product = array())  // php7 =array(). This is actually be a product object, the array() is misdirection to be compatible with the parent class.

core_commerce/models/attribute/types/product_price_adjustment_select/controller.php [controller.php at line 432, column 51]

public function validateKey($args = false) // php7, match parameters

[controller.php at line 523, column 79]

public function getSelectAttributeOptionDisplayValue($format = 'html') // php7, match parameters

[controller.php at line 584, column 63]

public static function getByValue($value, $ak = false) // php7, match parameters

 
 
This resolves 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. Rather than suppress all warnings, or all declaration warnings, I adapted this 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.

I now have eCommerce running under php7. My own Zone Based Shipping addonalready runs happily with php7.

Loading Conversation