I’m using siteground as a host. When I try to update to php 7 it does not allow me to and I get the following errors.
Suggestions?
I’m using siteground as a host. When I try to update to php 7 it does not allow me to and I get the following errors.
Suggestions?
Hi @johnbogs ,
Thanks for writing in.
Are these actual PHP error or just error generated by their tools? What’s your current version? You can stay with 5.6 version, other hosts use version 7 but there are no reports about this error, just SiteGround.
Those affected templates are derived from Woocommerce, and I see the similar issue and it also displays errors for Woocommerce core files, and yes, the same host.
If you’re currently on 5.6 then it should trigger the same error too since the error said since 5.3 and 5.4
.
Thanks!
Hi Rad - so does that mean I should not pay attention to the errors? Because it wont allow me to upgrade to V7 until the errors are corrected.
Can you help or should i contact woocommerce?
ty
Hello There,
It’s good to hear from you again.
Please make sure that X, Cornerstone plugin, WooCommerce and all of your plugins is update to date. After that, you can initiate the PHP 7 update. You won’t be able to update to PHP 7 if one of your plugins or the out dated theme is causing the issue.
To better assist you with this issue, could you at least provide the URL of your site so that we can check it?
Thanks.
Hi - I checked the themes and the plugins to verify all up to date. No luck on update
https://johnnybogs.com
**I also ran the woocommerce status, all green.
not sure why the font is so bold, (not intended)
**
-----------------------------------------------------------------------------------------------------------------------------
I even deactivated the woocommerce plugins but still same errors.
everything updated but still errors…
------------------------------------------------------------------------------------------------------------------------------
FILE: /home/horsemom/public_html/johnnybogs.com/wp-content/themes/x/woocommerce/single-product/up-sells.php
-----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------
** 26 | ERROR | Using a call-time pass-by-reference is deprecated since PHP 5.3 and prohibited since PHP 5.4**
-----------------------------------------------------------------------------------------------------------
FILE: /home/horsemom/public_html/johnnybogs.com/wp-content/themes/x/woocommerce/single-product/related.php
-----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------
** 26 | ERROR | Using a call-time pass-by-reference is deprecated since PHP 5.3 and prohibited since PHP 5.4**
-----------------------------------------------------------------------------------------------------------
FILE: /home/horsemom/public_html/johnnybogs.com/wp-content/themes/x/woocommerce/cart/cross-sells.php
-----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------
** 26 | ERROR | Using a call-time pass-by-reference is deprecated since PHP 5.3 and prohibited since PHP 5.4**
-----------------------------------------------------------------------------------------------------------
Hi @johnbogs,
I’m adding the sample code here,
This is the code from
wp-content/themes/x/woocommerce/cart/cross-sells.php
<?php
// =============================================================================
// WOOCOMMERCE/CART/CROSS-SELLS.PHP
// -----------------------------------------------------------------------------
// @version 3.0.0
// =============================================================================
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( $cross_sells && x_get_option( 'x_woocommerce_cart_cross_sells_enable' ) == '1' ) : ?>
<div class="cross-sells cols-<?php echo x_get_option( 'x_woocommerce_cart_cross_sells_columns' ); ?>">
<h2><?php _e( 'You may be interested in…', '__x__' ) ?></h2>
<?php woocommerce_product_loop_start(); ?>
<?php foreach ( $cross_sells as $cross_sell ) : ?>
<?php
$post_object = get_post( $cross_sell->get_id() );
setup_postdata( $GLOBALS['post'] =& $post_object );
wc_get_template_part( 'content', 'product' ); ?>
<?php endforeach; ?>
<?php woocommerce_product_loop_end(); ?>
</div>
<?php endif;
wp_reset_postdata();
Based on the error, the culprit is this line, just because of the presence of =&
setup_postdata( $GLOBALS['post'] =& $post_object );
As far as I know, the call-time pass-by-reference
is related to values passed by reference, like hello_world( &$arg );
. Like from here https://stackoverflow.com/questions/8971261/php-5-4-call-time-pass-by-reference-easy-fix-available
Having $GLOBALS['post'] =& $post_object
this is equivalent to this
$GLOBALS['post'] =& $post_object;
setup_postdata( $GLOBALS['post'] );
And if you compare, it’s not &$GLOBALS['post']
.
And this one is directly from the Woocommerce plugin itself (latest version), /wp-content/plugins/woocommerce/templates/cart/cross-sells.php
<?php
/**
* Cross-sells
*
* This template can be overridden by copying it to yourtheme/woocommerce/cart/cross-sells.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( $cross_sells ) : ?>
<div class="cross-sells">
<h2><?php _e( 'You may be interested in…', 'woocommerce' ) ?></h2>
<?php woocommerce_product_loop_start(); ?>
<?php foreach ( $cross_sells as $cross_sell ) : ?>
<?php
$post_object = get_post( $cross_sell->get_id() );
setup_postdata( $GLOBALS['post'] =& $post_object );
wc_get_template_part( 'content', 'product' ); ?>
<?php endforeach; ?>
<?php woocommerce_product_loop_end(); ?>
</div>
<?php endif;
wp_reset_postdata();
Then why their tool don’t trigger any error on that template, it has the same line of
setup_postdata( $GLOBALS['post'] =& $post_object );
The question is, does it based on actual PHP error, or is it just a random guess of their tool because of the existence of &=
? Their tools report many false positive issues, similar to this https://theme.co/apex/forums/topic/cornerstone-php-7-0-is-breaking-on-siteground-hosting/page/2/ (dates back 2016). I’m not saying they are wrong, but in comparison with other hosts, the theme, woocommerce, and cornerstone doesn’t have those errors with PHP7
I recommend trying another host with PHP7 and test it. Our theme only uses the compatible templates provided by Woocommerce, if that’s the reason you can’t upgrade because your host prevent it, then it’s something we can’t control
Thanks!
I appreciate the time and effort in your response.
I forced a push to PHP 7.1 . I still get the error message and I will report back with any hiccups.
I will also reach out to siteground to look for a solution and refer them back to this post.
Thank you!
Sure thing.
Please let us know how it goes.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.