Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

PHP 5.4 compatibility for older versions of X-Cart (4.0.19; 4.1.12)
 
Reply
   X-Cart forums > News and Announcements
 
Thread Tools
  #1  
Old 10-09-2013, 04:05 AM
  Ksenia's Avatar 
Ksenia Ksenia is offline
 

X-Cart team
  
Join Date: Apr 2013
Posts: 735
 

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

Hi folks.

More and more hosting providers tend to upgrade PHP to v 5.4. At the same time, there are some stores powered by X-Cart v.4.0.x; 4.1.x, which are not compatible with it out of the box. The maintenance team has developed the PHP 5.4 compatibility patch for them.


WHAT ABOUT OTHER VERSIONS:
4.2.0 - 4.2.2 do NOT require this patch if older '4.5.3-compatibility patch' is installed ( it makes your store PHP 5.4 compatible too).
4.2.3 or higher is PHP 5.4 compatible out of the box.

APPLY THESE FIRST:
Before you apply this patch, you should make sure that the corresponding '4.5.3-compatibility patch' is already installed:
for 4.0.19: php5.3.x-patch-2010-06-15_4.0.19.tgz
for 4.1.12: php5.3.x-patch-2010-04-12_4.1.12.tgz

AFTER THE PATCH IS APPLIED:
Make sure $debug_mode is NOT set to 3 in config.php

WHERE TO FIND THE PATCHES
Download the patch (the 'patch-name-{date}_{version}.tgz' archive file) from the 'File area' section of your Qualiteam account.

You can find the patch at
X-Cart -> X-Cart supporting files for prev versions -> {Your X-Cart branch} -> {Your X-Cart version} -> Updates and patches


IMPORTANT UPDATE based on post #11 of this thread:

Versions 4.1.9 and older require an additional patch (register_long_arrays_for_xc_lt_4.1.10.ver2.diff )

This patch is provided as is, upon request, without testing, as these X-Cart versions are out of guarantee.
__________________
X-Cart team

Last edited by Ksenia : 01-08-2014 at 03:16 AM.
Reply With Quote

The following 6 users thank Ksenia for this useful post:
aim (01-08-2014), chamberinternet (11-11-2013), gblair (10-26-2013), peakay (01-20-2014), totaltec (10-09-2013), xgarb (08-25-2014)
  #2  
Old 10-26-2013, 09:07 PM
 
gblair gblair is offline
 

Advanced Member
  
Join Date: Jul 2008
Posts: 69
 

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

Excellent. Our hosting provider has just updated to 5.4 and our store went down. They've reverted us back to 5.2 but are phasing it out by EOM (supposedly). Thank you for creating a patch!
__________________
paperwhimsy.com
Gale Blair
4.1.10
Reply With Quote
  #3  
Old 10-27-2013, 08:17 AM
 
gblair gblair is offline
 

Advanced Member
  
Join Date: Jul 2008
Posts: 69
 

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

I'm looking at applying the php 5.3 patches to our 4.1.10 x-cart.

All seems like it's going to work except:

func.compat.php not found - but I saw the work around for that in another thread.

init.php - could not patch - patch cannot be applied to this file automatically because it was significantly modified, the patch for this file should be applied manually,

I compare the script for both versions and it seems the only difference I can find is to add:

x_load('db','files', 'compat');

func_set_memory_limit("16M");

#
# Aloow displaying content in functions, registered in register_shutdown_function()
#
$zlib_oc = ini_get("zlib.output_compression");
if (!empty($zlib_oc) || func_version_compare(phpversion(), "4.0.6") <= 0)
define("NO_RSFUNCTION", true);

unset($zlib_oc);

if (func_version_compare(phpversion(), "5.3.0") >= 0) {
define('X_PHP530_COMPAT', true);
}

if (function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set'))
@date_default_timezone_set(@date_default_timezone_ get());

if (!@is_readable($xcart_dir."/config.php")) {
echo "Can't read config!";
exit;
}


Before I go ahead and screw it up, can you confirm that's all I need to do?
__________________
paperwhimsy.com
Gale Blair
4.1.10
Reply With Quote

The following user thanks gblair for this useful post:
peakay (01-20-2014)
  #4  
Old 10-27-2013, 09:14 AM
 
gblair gblair is offline
 

Advanced Member
  
Join Date: Jul 2008
Posts: 69
 

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

Nevermind, I did it anyway and it worked. Now running PHP5.3 which should keep us going for a little while longer.
__________________
paperwhimsy.com
Gale Blair
4.1.10
Reply With Quote
  #5  
Old 11-09-2013, 09:44 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 13,616
 

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

The following user thanks cflsystems for this useful post:
Ksenia (11-10-2013)
  #6  
Old 11-11-2013, 12:08 AM
  Ksenia's Avatar 
Ksenia Ksenia is offline
 

X-Cart team
  
Join Date: Apr 2013
Posts: 735
 

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

Hi Steve,

Thank you for letting us know.

We have reuploaded these patches:
php5.3.x-patch-2010-04-12_4.1.12.tgz
php5.3.x-patch-2010-04-12_4.2.0.tgz
php5.3.x-patch-2010-04-12_4.2.1.tgz
php5.3.x-patch-2010-04-12_4.2.2.tgz
php5.3.x-patch-2010-06-15_4.0.19.tgz

We have implemented the workaround, the changes are in init.php

- $x_error_reporting = $x_error_reporting & !(E_DEPRECATED |
E_USER_DEPRECATED);
+ $x_error_reporting = $x_error_reporting & ~(E_DEPRECATED |
E_USER_DEPRECATED);


After applying the patch, if $debug_mode = 2, PHP notices will be recorded into the logs, but not displayed.

To completely fix these warnings/notices, a very large patch ( 60-80 commitments) is required, so because of large scope of work the team of architects decided not to dig into it further, as the problem is not critical. We're concentrating on the current branch instead.
__________________
X-Cart team
Reply With Quote
  #7  
Old 11-11-2013, 09:14 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 13,616
 

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

Thanks Ksenia, this post was more of to bring QT's attention to the issue so you guys can fix it and have proper code in 4.6.x. The error reporting is not a fix, it just hides the problem from front end
Anyway since these are not critical but just warnings I guess this works sort of
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #8  
Old 11-13-2013, 03:43 PM
 
michaelt13 michaelt13 is offline
 

Newbie
  
Join Date: Nov 2013
Posts: 2
 

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

Quote:
Originally Posted by Ksenia
Hi folks.

More and more hosting providers tend to upgrade PHP to v 5.4. At the same time, there are some stores powered by X-Cart v.4.0.x; 4.1.x, which are not compatible with it out of the box. The maintenance team has developed the PHP 5.4 compatibility patch for them.


WHAT ABOUT OTHER VERSIONS:
4.2.0 - 4.2.2 do NOT require this patch if older '4.5.3-compatibility patch' is installed ( it makes your store PHP 5.4 compatible too).
4.2.3 or higher is PHP 5.4 compatible out of the box.

APPLY THESE FIRST:
Before you apply this patch, you should make sure that the corresponding '4.5.3-compatibility patch' is already installed:
for 4.0.19: php5.3.x-patch-2010-06-15_4.0.19.tgz
for 4.1.12: php5.3.x-patch-2010-04-12_4.1.12.tgz

AFTER THE PATCH IS APPLIED:
Make sure $debug_mode is NOT set to 3 in config.php

WHERE TO FIND THE PATCHES
Download the patch (the 'patch-name-{date}_{version}.tgz' archive file) from the 'File area' section of your Qualiteam account.

You can find the patch at
X-Cart -> X-Cart supporting files for prev versions -> {Your X-Cart branch} -> {Your X-Cart version} -> Updates and patches

Does this work for X-Cart 4.1.9? I've been trying to look for patch in folder version 4.1.9 but I do not see patch file.

Can you help with version 4.1.9?
__________________
X-Cart 4.1.9
Reply With Quote
  #9  
Old 11-13-2013, 04:06 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 13,616
 

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

The patch is under 4.1.12 directory. You will have to apply it manually to 4.1.9
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #10  
Old 11-13-2013, 04:14 PM
 
michaelt13 michaelt13 is offline
 

Newbie
  
Join Date: Nov 2013
Posts: 2
 

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

Quote:
Originally Posted by Ksenia
Hi Steve,

Thank you for letting us know.

We have reuploaded these patches:
php5.3.x-patch-2010-04-12_4.1.12.tgz
php5.3.x-patch-2010-04-12_4.2.0.tgz
php5.3.x-patch-2010-04-12_4.2.1.tgz
php5.3.x-patch-2010-04-12_4.2.2.tgz
php5.3.x-patch-2010-06-15_4.0.19.tgz

We have implemented the workaround, the changes are in init.php

- $x_error_reporting = $x_error_reporting & !(E_DEPRECATED |
E_USER_DEPRECATED);
+ $x_error_reporting = $x_error_reporting & ~(E_DEPRECATED |
E_USER_DEPRECATED);


After applying the patch, if $debug_mode = 2, PHP notices will be recorded into the logs, but not displayed.

To completely fix these warnings/notices, a very large patch ( 60-80 commitments) is required, so because of large scope of work the team of architects decided not to dig into it further, as the problem is not critical. We're concentrating on the current branch instead.

I used your trick and it solved a few problems, but I still running into these warnings:

Code:
Warning: Invalid argument supplied for foreach() in /home/rebe/public_html/shop/prepare.php on line 240 Warning: Invalid argument supplied for foreach() in /home/rebe/public_html/shop/prepare.php on line 245 Warning: Invalid argument supplied for foreach() in /home/rebe/public_html/shop/prepare.php on line 251 Warning: Invalid argument supplied for foreach() in /home/rebe/public_html/shop/prepare.php on line 254 Warning: Invalid argument supplied for foreach() in /home/rebe/public_html/shop/prepare.php on line 307 Warning: reset() expects parameter 1 to be array, string given in /home/rebeccac/public_html/shop/prepare.php on line 314 Warning: Invalid argument supplied for foreach() in /home/rebeccac/public_html/shop/prepare.php on line 307 Warning: reset() expects parameter 1 to be array, string given in /home/rebe/public_html/shop/prepare.php on line 314 Warning: Invalid argument supplied for foreach() in /home/rebe/public_html/shop/prepare.php on line 307 Warning: reset() expects parameter 1 to be array, string given in /home/rebe/public_html/shop/prepare.php on line 314 Warning: Invalid argument supplied for foreach() in /home/rebe/public_html/shop/prepare.php on line 307 Warning: reset() expects parameter 1 to be array, null given in /home/rebe/public_html/shop/prepare.php on line 314 Warning: Invalid argument supplied for foreach() in /home/rebe/public_html/shop/prepare.php on line 317
__________________
X-Cart 4.1.9
Reply With Quote
Reply
   X-Cart forums > News and Announcements


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:11 AM.

   

 
X-Cart forums © 2001-2018