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.6 and 7.0 Discontinued: How It Affects Your X-Cart 4 Store (https://forum.x-cart.com/showthread.php?t=76802)

Anastasia Zhavoronkova 01-31-2019 06:11 AM

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.

Dougrun 01-31-2019 10:28 AM

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.

iry 01-31-2019 02:09 PM

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

aim 02-27-2019 06:21 AM

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.

Dougrun 02-27-2019 09:19 AM

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.

BCSE 02-27-2019 10:45 AM

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

cflsystems 02-27-2019 12:04 PM

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.

aim 02-28-2019 12:19 AM

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.

cflsystems 02-28-2019 06:22 AM

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.

aim 03-01-2019 03:41 AM

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.


All times are GMT -8. The time now is 01:54 PM.

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