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

PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

 
Reply
   X-Cart forums > News and Announcements
 
Thread Tools
  #1  
Old 01-31-2019, 06:11 AM
 
Anastasia Zhavoronkova Anastasia Zhavoronkova is offline
 

X-Cart team
  
Join Date: Jun 2018
Posts: 20
 

Exclamation PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

Hi guys,

In December, PHP 5.6 and 7.0 have been officially discontinued. If you are still using a server that runs on either of these versions, please take a close look at the blog post.

There we're explaining how it may affect your store and offer a few solutions.

With any questions, please contact us in HelpDesk or right here.
__________________
Nastya Zhavoronkova, X-Cart
Reply With Quote
  #2  
Old 01-31-2019, 10:28 AM
 
Dougrun Dougrun is online now
 

X-Adept
  
Join Date: Apr 2012
Posts: 893
 

Default Re: PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

i'm on 7.1 on my sites. The fast lane checkout doesnt seem to be 7.2 compatible. I get a blank page if I switch to 7.2 and checkout.
__________________
4.7.x xcart store
Business 5.4xx
Reply With Quote
  #3  
Old 01-31-2019, 02:09 PM
 
iry iry is offline
 

Member
  
Join Date: Sep 2007
Location: New York
Posts: 23
 

Default Re: PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

Hello, I got the PHP 7.0 compatibility patch .
Where can I find the PHP 7.1-7.3 patch that need to be applied right after. , as per your instructions from your blog post.
Thank you
__________________
iry
xcart gold - 4.6.1)
Stylehippo.com
Big Scoots Hosting
Reply With Quote
  #4  
Old 02-27-2019, 06:21 AM
 
aim aim is offline
Advanced Staff Users
 

X-Cart team
  
Join Date: Dec 2008
Posts: 928
 

Default Re: PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

Hello,

Quote:
Originally Posted by Dougrun
i'm on 7.1 on my sites. The fast lane checkout doesnt seem to be 7.2 compatible. I get a blank page if I switch to 7.2 and checkout.

Do you have any fatal errors in var/log/x-errors_php-<date>.php files?

Quote:
Originally Posted by iry
Hello, I got the PHP 7.0 compatibility patch .
Where can I find the PHP 7.1-7.3 patch that need to be applied right after. , as per your instructions from your blog post.
Thank you

For X-Cart versions
4.7.9
4.7.8
4.7.7
4.7.6
4.7.5
4.7.4
4.7.3
4.7.2
4.7.1
4.7.0
4.6.6
4.5.5
4.4.5

you can find it in your HelpDesk account > X-Cart > X-Cart supporting files for prev versions -> {Your X-Cart branch} > {Your X-Cart version} > Updates and patches.


An adaptation may be is needed for the other versions.

Thank you.
__________________
Sincerely yours,
Ildar Amankulov
Head of Maintenance group
Reply With Quote
  #5  
Old 02-27-2019, 09:19 AM
 
Dougrun Dougrun is online now
 

X-Adept
  
Join Date: Apr 2012
Posts: 893
 

Default Re: PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

sorry, its our busy time so i cannot stop and test it.
__________________
4.7.x xcart store
Business 5.4xx
Reply With Quote
  #6  
Old 02-27-2019, 10:45 AM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,058
 

Default Re: PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

We are helping quite a few people either patch or upgrade to switch to php 7. So far it's fairly smooth but the patches are quite large. Sometimes upgrading to the latest 4.7.x is the best option.

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote

The following user thanks BCSE for this useful post:
aim (02-27-2019)
  #7  
Old 02-27-2019, 12:04 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,189
 

Default Re: PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

Keep in mind the patches are not complete and do not fully address all issues older XC versions will have with PHP 7.2+

One example is the use of each() - this has been removed in XC 4.7.9 and later but every version before that has it. And the patches do not address this.

each() has been deprecated since PHP 7.2 and most likely will be removed with 7.4 or whatever version they decide on. Cart still works but logs will be full of warnings and XC 4.7.9+ and the patches are not consistent in what they fix.

As PHP puts it: This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.

There are other warnings and notices as well that will show after the patches but not with newest XC4 version.

So to me the patches are incomplete.

And while looking at this (the below code is from 4.7.10) it just doesn't make sense

PHP Code:
if (
        empty(
$product['meta_description'])
        || empty(
$product['meta_keywords'])
    ) {

        
$ids array_reverse(func_get_category_path($product['categoryid']));

        
$parents func_query_hash("SELECT categoryid, meta_description, meta_keywords FROM $sql_tbl[categories] WHERE categoryid IN ('".implode("', '"$ids)."') AND override_child_meta = 'Y'""categoryid"false);

        foreach (
$ids as $cid) {
            if (
                !empty(
$product['meta_description'])
                && !empty(
$product['meta_keywords'])
            ) {
                break;
            }
. . . . . . . . . . . 
   }


The "if" will run if meta_description OR keta_meywords are empty but then the following "foreach" breaks only if meta_description AND meta_keywords are not empty?!
The code will never get to the "foreach" if both are not empty in the first place....
The second "if" is absolutely unnecessary.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
elmirage001 (02-27-2019)
  #8  
Old 02-28-2019, 12:19 AM
 
aim aim is offline
Advanced Staff Users
 

X-Cart team
  
Join Date: Dec 2008
Posts: 928
 

Default Re: PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

Quote:
Originally Posted by cflsystems
Keep in mind the patches are not complete and do not fully address all issues older XC versions will have with PHP 7.2+

One example is the use of each() - this has been removed in XC 4.7.9 and later but every version before that has it. And the patches do not address this.

each() has been deprecated since PHP 7.2 and most likely will be removed with 7.4 or whatever version they decide on. Cart still works but logs will be full of warnings and XC 4.7.9+ and the patches are not consistent in what they fix.

As PHP puts it: This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.

There are other warnings and notices as well that will show after the patches but not with newest XC4 version.

So to me the patches are incomplete.

And while looking at this (the below code is from 4.7.10) it just doesn't make sense

PHP Code:
if (
        empty(
$product['meta_description'])
        || empty(
$product['meta_keywords'])
    ) {

        
$ids array_reverse(func_get_category_path($product['categoryid']));

        
$parents func_query_hash("SELECT categoryid, meta_description, meta_keywords FROM $sql_tbl[categories] WHERE categoryid IN ('".implode("', '"$ids)."') AND override_child_meta = 'Y'""categoryid"false);

        foreach (
$ids as $cid) {
            if (
                !empty(
$product['meta_description'])
                && !empty(
$product['meta_keywords'])
            ) {
                break;
            }
. . . . . . . . . . . 
   }


The "if" will run if meta_description OR keta_meywords are empty but then the following "foreach" breaks only if meta_description AND meta_keywords are not empty?!
The code will never get to the "foreach" if both are not empty in the first place....
The second "if" is absolutely unnecessary.

Hello,

Thank you for the notes.

The code above works as the http://php.net/manual/en/control-structures.do.while.php construction
i.e. the first iteration runs anyway. It is a replacement for the deprecated PHP each call

Code:
@@ -565,7 +569,14 @@ function func_get_category_meta($categoryid, $category = null) array_shift($ids); $parents = func_query_hash("SELECT categoryid, meta_description, meta_keywords FROM $sql_tbl[categories] WHERE categoryid IN ('".implode("', '", $ids)."') AND override_child_meta = 'Y'", "categoryid", false); - while ((list(,$cid) = each($ids)) && (empty($category['meta_description']) || empty($category['meta_keywords']))) { + foreach ($ids as $cid) { + if ( + !empty($category['meta_description']) + && !empty($category['meta_keywords']) + ) { + break; + } + $parents[$cid]['meta_description'] = trim($parents[$cid]['meta_description']); $parents[$cid]['meta_keywords'] = trim($parents[$cid]['meta_keywords']);


The whole code looks like

PHP Code:
if (empty($category['meta_description']) || empty($category['meta_keywords'])) {

        
$ids array_reverse(func_get_category_path($categoryid));

        
array_shift($ids);
        
$parents func_query_hash("SELECT categoryid, meta_description, meta_keywords FROM $sql_tbl[categories] WHERE categoryid IN ('".implode("', '"$ids)."') AND override_child_meta = 'Y'""categoryid"false);

        foreach (
$ids as $cid) {
            if (
                !empty(
$category['meta_description'])
                && !empty(
$category['meta_keywords'])
            ) {
                break;
            }

            
$parents[$cid]['meta_description'] = trim($parents[$cid]['meta_description']);
            
$parents[$cid]['meta_keywords'] = trim($parents[$cid]['meta_keywords']);

            if (empty(
$category['meta_description']) && !empty($parents[$cid]['meta_description']))
                
$category['meta_description'] = $parents[$cid]['meta_description'];

            if (empty(
$category['meta_keywords']) && !empty($parents[$cid]['meta_keywords']))
                
$category['meta_keywords'] = $parents[$cid]['meta_keywords'];
        }
    } 

The foreach tries to go through the $ids array in order to fill the empty meta_description/meta_keywords of the category from the filled fields of its parents.

As for the deprecated warnings, I tried to make minimal patches so as to achieve the maximal compatibility with the client's code.

Thank you.
__________________
Sincerely yours,
Ildar Amankulov
Head of Maintenance group
Reply With Quote
  #9  
Old 02-28-2019, 06:22 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,189
 

Default Re: PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

No. Look carefully the code I posted. It is not that is wrong - it is simply unneeded and will never run the way it is coded. After the

PHP Code:
foreach ($ids as $cid) { 

the code checks if descr AND keywords are NOT empty but this "foreach" will never be reached if both are not empty in the first place. The "foreach" is included in an "if" statement which checks descr OR keywords being EMPTY.

If one of them is empty then the "foreach" will run but in this case the following "if" will not run - one of them is empty...

You replaced the "each" function and added

PHP Code:
if ( 
                !empty(
$product['meta_description']) 
                && !empty(
$product['meta_keywords']) 
            ) { 
                break; 
            } 

without taking into account the parent "if" block. This second "if" will never run and it shouldn't be there.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #10  
Old 03-01-2019, 03:41 AM
 
aim aim is offline
Advanced Staff Users
 

X-Cart team
  
Join Date: Dec 2008
Posts: 928
 

Default Re: PHP 5.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store

Hello Steve,

You are right, it is safe to remove the block

PHP Code:
if (
                !empty(
$category['meta_description'])
                && !empty(
$category['meta_keywords'])
            ) {
                break;
            } 

Although I would like to keep the block for the perfomance purpose.

By the way,

I have posted a small PHP test for the function
http://codepad.org/ZVvrVbHa


PHP Code:
$category = array (
  
'meta_description' => '',
  
'meta_keywords' => 'Cube Goodies keywords',
);

if (empty(
$category['meta_description']) || empty($category['meta_keywords'])) {

        
$ids = array(5);

        
$parents =
            array (
              
=>
              array (
                
'meta_description' => 'Toys description',
                
'meta_keywords' => 'Toys keywords',
              ),
            );


        foreach (
$ids as $cid) {
            if (
                !empty(
$category['meta_description'])
                && !empty(
$category['meta_keywords'])
            ) {
                break;
            }

            
$parents[$cid]['meta_description'] = trim($parents[$cid]['meta_description']);
            
$parents[$cid]['meta_keywords'] = trim($parents[$cid]['meta_keywords']);

            if (empty(
$category['meta_description']) && !empty($parents[$cid]['meta_description']))
                
$category['meta_description'] = $parents[$cid]['meta_description'];

            if (empty(
$category['meta_keywords']) && !empty($parents[$cid]['meta_keywords']))
                
$category['meta_keywords'] = $parents[$cid]['meta_keywords'];
        }
    }

    if (
        
$category['meta_keywords'] !== 'Cube Goodies keywords'
        
|| $category['meta_description'] !== 'Toys description'
    
) {
        echo 
'TEST FAILED';
    } else {
        echo 
'TEST PASSED';
    }

    
print_r($category);die; 

Thank you.
__________________
Sincerely yours,
Ildar Amankulov
Head of Maintenance group
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 11:26 PM.

   

 
X-Cart forums © 2001-2020