X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   News and Announcements (https://forum.x-cart.com/forumdisplay.php?f=28)
-   -   PHP 5.4 compatibility for older versions of X-Cart (4.0.19; 4.1.12) (https://forum.x-cart.com/showthread.php?t=67915)

Ksenia 10-09-2013 04:05 AM

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.

gblair 10-26-2013 09:07 PM

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!

gblair 10-27-2013 08:17 AM

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?

gblair 10-27-2013 09:14 AM

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.

cflsystems 11-09-2013 09:44 AM

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

Ksenia 11-11-2013 12:08 AM

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.

cflsystems 11-11-2013 09:14 AM

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

michaelt13 11-13-2013 03:43 PM

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?

cflsystems 11-13-2013 04:06 PM

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

michaelt13 11-13-2013 04:14 PM

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



All times are GMT -8. The time now is 11:15 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.