admin管理员组文章数量:1415140
I have an issue with php 7.2 on my wordpress site . My host currently running on php 5.6 and after wordpress send notice that you need to upgrade your php version to 7.2 Cpu usage of my host increased to 90% !!! Thats a huge bug of wordpress
But now i'm gonna upgrade php to 7.2 but after upgrading every thing works fine except searching between products ! When my users using search box trying to find something after wordpress crashes and display this error :
The site is experiencing technical difficulties
The log Stored these lines of error :
#0 /home/censured-site/public_html/wp-includes/template.php(724): require()
#1 /home/censured-site/public_html/wp-includes/template.php(671): load_template('/home/censured...', false)
#2 /home/censured-site/public_html/wp-includes/general-template.php(168): locate_template(Array, true, false)
#3 /home/censured-site/public_html/wp-content/themes/mytheme/search-download.php(89): get_template_part('includes/loop-s...')
#4 /home/censured-site/public_html/wp-includes/template.php(724): require('/home/censured...')
#5 /home/censured-site/public_html/wp-includes/template.php(671): load_template('/home/censured...', false)
#6 /home/censured-site/public_html/wp-includes/general-template.php(168): locate_template(Array, true, false)
#7 /home/censured-site/public_html/wp-content/themes/mytheme/search.php(12): get_template_part('search', 'download')
#8 /home/censured-site/publ in /home/censured-site/public_html/wp-content/themes/mytheme/includes/loop-shop-listings.php on line 24
This is my whole loop-shop-listings.php:
$eddColumn=get_theme_mod('olam_edd_columns');
// var_dump($eddColumn);
switch ($eddColumn) {
case '2 columns':
$colsize=6;
$division=2;
$colclass="col-sm-6";
break;
case '3 columns':
$colsize=4;
$division=3;
$colclass="col-sm-3";
break;
case '4 columns':
$colsize=3;
$division=4;
$colclass="col-sm-6";
break;
default:
$colclass="col-sm-3";
break;
}
if(($wp_query->current_post)%($division)==0){ echo "<div class='row'>"; } ?>
<div class="col-md-<?php echo $colsize; ?> <?php echo $colclass; ?>">
<div class="edd_download_inner">
<div class="thumb">
<?php $videoCode=get_post_meta(get_the_ID(),"download_item_video_id");
$audioCode=get_post_meta(get_the_ID(),"download_item_audio_id");
if(isset($videoCode[0]) && (strlen($videoCode[0])>0) ){
// if(is_numeric($videoCode[0])){
// $videoUrl=wp_get_attachment_url($videoCode[0]);
// }
// else{
$videoUrl=$videoCode[0];
// }
//$videoUrl=wp_get_attachment_url($videoCode[0]);
if (strpos($videoUrl, 'vimeo') !== false) {
echo '<div class="media-thumb vimeovid">'.do_shortcode("[video src='".esc_url($videoUrl)."' muted='1']").'</div>';
} else {
echo '<div class="media-thumb othervid">'.do_shortcode("[video src='".esc_url($videoUrl)."']").'</div>';
}
}
else if(isset($audioCode[0]) && (strlen($audioCode[0])>0) ){
$audioUrl=wp_get_attachment_url($audioCode[0]);
?>
<div class="media-thumb">
<?php echo do_shortcode("[audio src='".$audioUrl."']"); ?>
</div><?php
} ?>
<a href="<?php the_permalink(); ?>"><span><i class="demo-icons icon-link"></i></span>
<?php $square_img = get_post_meta(get_the_ID(),"download_item_square_img");
if (!empty($square_img) && strlen($square_img[0])>0) {
echo '<img src="' . esc_url($square_img[0]) .'" />';
}
elseif ( has_post_thumbnail() ) {
the_post_thumbnail('olam-product-thumb');
}
else {
echo '<img src="' . get_template_directory_uri(). '/img/thumbnail-default.jpg" />';
}
?>
</a>
</div>
<div class="product-details">
<?php $defaultPriceID=edd_get_default_variable_price( get_the_ID() ); ?>
<div class="product-name"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div class="product-price"><?php edd_price(get_the_ID(),true,$defaultPriceID); ?></div>
<?php if ( has_excerpt() ) : // Only show custom excerpts not autoexcerpts ?>
<p class="olam-custom-excerpt"><?php echo get_the_excerpt(); ?></p>
<?php endif; ?>
<div class="details-bottom">
<div class="product-options">
<a href="<?php the_permalink(); ?>" title="<?php esc_attr_e('View','olam'); ?> "><i class="demo-icons icon-search"></i></a>
<?php if(!olam_check_if_added_to_cart(get_the_ID())){
$eddOptionAddtocart=edd_get_option( 'add_to_cart_text' );
$addCartText=(isset($eddOptionAddtocart) && $eddOptionAddtocart != '') ?$eddOptionAddtocart:esc_html__("Add to cart","olam");
if(edd_has_variable_prices(get_the_ID())){
$downloadArray=array('edd_action'=>'add_to_cart','download_id'=>$post->ID,'edd_options[price_id]'=>$defaultPriceID);
}
else{
$downloadArray=array('edd_action'=>'add_to_cart','download_id'=>$post->ID);
}
?>
<a href="<?php echo esc_url(add_query_arg($downloadArray,edd_get_checkout_uri())); ?>" title="<?php esc_attr_e('Buy Now','olam'); ?>"><i class="demo-icons icon-download"></i></a>
<?php
$purchase_link_args = array(
'download_id' => get_the_ID(),
'price' => false,
'direct' => false,
'style' => 'plain',
'class' => 'demo-icons icon-cart cart-icon-btn',
'text' => '',
);
$purchase_link_args = apply_filters( 'edd_rp_purchase_link_args', $purchase_link_args );
echo edd_get_purchase_link( $purchase_link_args );
} else { ?>
<a class="cart-added" href="<?php echo edd_get_checkout_uri(); ?>" title="<?php esc_attr_e('Checkout','olam'); ?> "><i class="fa fa-check"></i></a>
<?php } ?>
</div>
<?php $olamct=get_theme_mod('olam_show_cats');
if(isset($olamct)&& $olamct==1 ){
$cat = wp_get_post_terms(get_the_ID(),'download_category');
if(count($cat)>0){
$mlink = get_term_link($cat[0]->slug,'download_category');
?><div class="product-author"><a href="<?php echo $mlink; ?>"><?php echo($cat[0]->name); ?></a></div><?php
} }
else{
?> <div class="product-author"><a href="<?php echo esc_url(add_query_arg( 'author_downloads', 'true', get_author_posts_url( get_the_author_meta('ID')) )); ?>"><?php esc_html_e("By","olam"); ?>: <?php the_author(); ?></a></div><?php
}
?>
</div>
</div>
</div>
</div>
<?php if(($wp_query->current_post+1)%($division)==0){ echo "</div>"; }
else if(($wp_query->current_post+1)==$wp_query->post_count ){ echo "</div>"; }```
please help me . Thanks
I have an issue with php 7.2 on my wordpress site . My host currently running on php 5.6 and after wordpress send notice that you need to upgrade your php version to 7.2 Cpu usage of my host increased to 90% !!! Thats a huge bug of wordpress
But now i'm gonna upgrade php to 7.2 but after upgrading every thing works fine except searching between products ! When my users using search box trying to find something after wordpress crashes and display this error :
The site is experiencing technical difficulties
The log Stored these lines of error :
#0 /home/censured-site/public_html/wp-includes/template.php(724): require()
#1 /home/censured-site/public_html/wp-includes/template.php(671): load_template('/home/censured...', false)
#2 /home/censured-site/public_html/wp-includes/general-template.php(168): locate_template(Array, true, false)
#3 /home/censured-site/public_html/wp-content/themes/mytheme/search-download.php(89): get_template_part('includes/loop-s...')
#4 /home/censured-site/public_html/wp-includes/template.php(724): require('/home/censured...')
#5 /home/censured-site/public_html/wp-includes/template.php(671): load_template('/home/censured...', false)
#6 /home/censured-site/public_html/wp-includes/general-template.php(168): locate_template(Array, true, false)
#7 /home/censured-site/public_html/wp-content/themes/mytheme/search.php(12): get_template_part('search', 'download')
#8 /home/censured-site/publ in /home/censured-site/public_html/wp-content/themes/mytheme/includes/loop-shop-listings.php on line 24
This is my whole loop-shop-listings.php:
$eddColumn=get_theme_mod('olam_edd_columns');
// var_dump($eddColumn);
switch ($eddColumn) {
case '2 columns':
$colsize=6;
$division=2;
$colclass="col-sm-6";
break;
case '3 columns':
$colsize=4;
$division=3;
$colclass="col-sm-3";
break;
case '4 columns':
$colsize=3;
$division=4;
$colclass="col-sm-6";
break;
default:
$colclass="col-sm-3";
break;
}
if(($wp_query->current_post)%($division)==0){ echo "<div class='row'>"; } ?>
<div class="col-md-<?php echo $colsize; ?> <?php echo $colclass; ?>">
<div class="edd_download_inner">
<div class="thumb">
<?php $videoCode=get_post_meta(get_the_ID(),"download_item_video_id");
$audioCode=get_post_meta(get_the_ID(),"download_item_audio_id");
if(isset($videoCode[0]) && (strlen($videoCode[0])>0) ){
// if(is_numeric($videoCode[0])){
// $videoUrl=wp_get_attachment_url($videoCode[0]);
// }
// else{
$videoUrl=$videoCode[0];
// }
//$videoUrl=wp_get_attachment_url($videoCode[0]);
if (strpos($videoUrl, 'vimeo') !== false) {
echo '<div class="media-thumb vimeovid">'.do_shortcode("[video src='".esc_url($videoUrl)."' muted='1']").'</div>';
} else {
echo '<div class="media-thumb othervid">'.do_shortcode("[video src='".esc_url($videoUrl)."']").'</div>';
}
}
else if(isset($audioCode[0]) && (strlen($audioCode[0])>0) ){
$audioUrl=wp_get_attachment_url($audioCode[0]);
?>
<div class="media-thumb">
<?php echo do_shortcode("[audio src='".$audioUrl."']"); ?>
</div><?php
} ?>
<a href="<?php the_permalink(); ?>"><span><i class="demo-icons icon-link"></i></span>
<?php $square_img = get_post_meta(get_the_ID(),"download_item_square_img");
if (!empty($square_img) && strlen($square_img[0])>0) {
echo '<img src="' . esc_url($square_img[0]) .'" />';
}
elseif ( has_post_thumbnail() ) {
the_post_thumbnail('olam-product-thumb');
}
else {
echo '<img src="' . get_template_directory_uri(). '/img/thumbnail-default.jpg" />';
}
?>
</a>
</div>
<div class="product-details">
<?php $defaultPriceID=edd_get_default_variable_price( get_the_ID() ); ?>
<div class="product-name"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div class="product-price"><?php edd_price(get_the_ID(),true,$defaultPriceID); ?></div>
<?php if ( has_excerpt() ) : // Only show custom excerpts not autoexcerpts ?>
<p class="olam-custom-excerpt"><?php echo get_the_excerpt(); ?></p>
<?php endif; ?>
<div class="details-bottom">
<div class="product-options">
<a href="<?php the_permalink(); ?>" title="<?php esc_attr_e('View','olam'); ?> "><i class="demo-icons icon-search"></i></a>
<?php if(!olam_check_if_added_to_cart(get_the_ID())){
$eddOptionAddtocart=edd_get_option( 'add_to_cart_text' );
$addCartText=(isset($eddOptionAddtocart) && $eddOptionAddtocart != '') ?$eddOptionAddtocart:esc_html__("Add to cart","olam");
if(edd_has_variable_prices(get_the_ID())){
$downloadArray=array('edd_action'=>'add_to_cart','download_id'=>$post->ID,'edd_options[price_id]'=>$defaultPriceID);
}
else{
$downloadArray=array('edd_action'=>'add_to_cart','download_id'=>$post->ID);
}
?>
<a href="<?php echo esc_url(add_query_arg($downloadArray,edd_get_checkout_uri())); ?>" title="<?php esc_attr_e('Buy Now','olam'); ?>"><i class="demo-icons icon-download"></i></a>
<?php
$purchase_link_args = array(
'download_id' => get_the_ID(),
'price' => false,
'direct' => false,
'style' => 'plain',
'class' => 'demo-icons icon-cart cart-icon-btn',
'text' => '',
);
$purchase_link_args = apply_filters( 'edd_rp_purchase_link_args', $purchase_link_args );
echo edd_get_purchase_link( $purchase_link_args );
} else { ?>
<a class="cart-added" href="<?php echo edd_get_checkout_uri(); ?>" title="<?php esc_attr_e('Checkout','olam'); ?> "><i class="fa fa-check"></i></a>
<?php } ?>
</div>
<?php $olamct=get_theme_mod('olam_show_cats');
if(isset($olamct)&& $olamct==1 ){
$cat = wp_get_post_terms(get_the_ID(),'download_category');
if(count($cat)>0){
$mlink = get_term_link($cat[0]->slug,'download_category');
?><div class="product-author"><a href="<?php echo $mlink; ?>"><?php echo($cat[0]->name); ?></a></div><?php
} }
else{
?> <div class="product-author"><a href="<?php echo esc_url(add_query_arg( 'author_downloads', 'true', get_author_posts_url( get_the_author_meta('ID')) )); ?>"><?php esc_html_e("By","olam"); ?>: <?php the_author(); ?></a></div><?php
}
?>
</div>
</div>
</div>
</div>
<?php if(($wp_query->current_post+1)%($division)==0){ echo "</div>"; }
else if(($wp_query->current_post+1)==$wp_query->post_count ){ echo "</div>"; }```
please help me . Thanks
Share
Improve this question
edited Aug 30, 2019 at 23:57
TheXrion
asked Aug 30, 2019 at 14:17
TheXrionTheXrion
57 bronze badges
11
|
Show 6 more comments
1 Answer
Reset to default 2I'm going to guess that PHP's settings have changed with the upgrade. Division by zero suggests some variable is not initialized (and is being dynamically typed as 0). The PHP manual has a lot of information on the changes between 5.x and 7.x. This bit on how variables are handled supports my hypothesis, especially if your theme was created before 7.x was released.
On the same lines, I am going to guess that PHP is running out of memory (because the new settings file sets the value too low by default for your theme). I am guessing this is the case because the lines from the error log do not appear to be FATAL but rather, WARNING (based on your comment). When PHP runs out of memory, it sometimes doesn't even have enough to write to the error log, which makes debugging this type of error very difficult.
I suggest you do three things:
- Contact the theme author and see if they have an updated version of the theme available (assuming it is not your own).
- Increase the amount of memory PHP can use to something like 64MB or even 128MB and see if you can reproduce the error. You can do this in a variety of ways. See this link for more info.
- Turn display_errors off and instead send them to a log file so your users don't see PHP errors when using the site. Put the code snippet below in wp-config.php just before the STOP EDITING HERE line:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
本文标签: Issue with php version 72 in running search
版权声明:本文标题:Issue with php version 7.2 in running search 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745197396a2647208.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
includes/loop-shop-listings.php
has a problem on line 24 but it's not clear what the problem is without the error message – Tom J Nowell ♦ Commented Aug 30, 2019 at 15:14