View Single Post
  #5  
Old 11-09-2013, 09:44 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: PHP 5.4 compatibility for older versions of X-Cart (4.0.19; 4.1.12)

Just a heads up on the patches, cart code and php warning messages. I do not see this with 4.6.x but I see it on 4.5.x and earlier version

PHP 5.4.x will throw out a warning message on some of the XC stock code. Just an example from 4.4.x but I suspect earlier versions is even worst

Quote:
Warning: Illegal string offset 'variantid' in /var/www/xcart-devs/xcart444/include/func/func.product.php on line 794

The code there is

Code:
foreach ($cart['products'] as $cart_item) { if ( $cart_item['productid'] == $value['productid'] && $cart_item['variantid'] == $value['productid']['variantid'] ) { $in_cart += $cart_item['amount']; } }

and the warning is caused by the fact that most likely $cart_item['variantid'] has no value or its value is not numeric

From PHP docs - http://docs.php.net/manual/da/language.types.array.php
Quote:
From PHP 5.4, string offset access made consistent. As a result, some return values may be different from older version. As of PHP 5.4, string offsets should be an integer or an integer like string, otherwise the result will be a warning.

This happens on like dozen places in stock XC code from what I've seen. It won't prevent cart from working but makes the patches incomplete
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote