运行搜索时php版本7.2出现问题

时间:2019-08-30 作者:TheXrion

我在wordpress网站上对php 7.2有一个问题。我的主机目前运行在php 5.6上,wordpress发送通知后,您需要将php版本升级到7.2,我的主机的Cpu使用率增加到90%!!!这是wordpress的一个巨大缺陷

但现在我要将php升级到7.2,但升级后,除了在产品之间搜索之外,其他一切都很好!当我的用户在wordpress崩溃后使用搜索框试图查找内容并显示此错误时:
The site is experiencing technical difficulties

日志存储了以下错误行:

#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

1 个回复
SO网友:Ted Stresen-Reuter

我猜PHP的设置随着升级而改变。被零除表示某个变量未初始化(并且动态键入为0)。PHP手册中有很多关于5之间更改的信息。x和7。x。This bit on how variables are handled 支持我的假设,尤其是如果你的主题是在7点之前创建的。x已发布。

同样,我猜PHP内存不足(因为新的设置文件在默认情况下为主题设置的值太低)。我猜这是因为错误日志中的行看起来不是致命的,而是警告(根据您的评论)。当PHP内存不足时,它有时甚至没有足够的内存写入错误日志,这使得调试此类错误非常困难。

我建议你做三件事:

联系主题作者,看看他们是否有主题的更新版本(假设不是你自己的)See this link for more info.

define( \'WP_DEBUG\', true );
define( \'WP_DEBUG_LOG\', true );
define( \'WP_DEBUG_DISPLAY\', false );

相关推荐

使用Reaction而不是php进行动态古登堡拦截

我正在基于wordpress rest api构建wordpress主题,因此前端的所有内容都是使用react构建的。但我想建立一个古腾堡自定义块,显示最受欢迎的帖子。是否有一种方法可以使用react而不是PHP构建动态部分(保存部分)。如果没有,我如何将“阅读更多”链接bahave设置为React router Navlink,而不是HTML标记,这样当用户单击它时,浏览器不会刷新,新路由将被推送到道具历史记录中。非常感谢。update : 当我们构建一个gutenberg块时,“edit:(props