【问题标题】:fastcgi_finish_request() causes WP Cron to failfastcgi_finish_request() 导致 WP Cron 失败
【发布时间】:2021-06-07 23:51:14
【问题描述】:

我的 WordPress 网站无法运行计划任务。我浏览了 wp-cron.php 并发现注释掉以下 if 语句解决了问题:

if ( function_exists( 'fastcgi_finish_request' ) && version_compare( phpversion(), '7.0.16', '>=' ) ) {
        if ( ! headers_sent() ) {
                header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
                header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
        }
        fastcgi_finish_request();
}

我的猜测是,使用 Unit 作为应用服务器,而不是 FastCGI,会导致这段代码出现问题。

谁能告诉我这是否正确?为什么运行此函数会停止脚本其余部分的执行?注释掉这个语句是否安全,或者我应该做一些不同的改变来解决这个问题?

谢谢

【问题讨论】:

    标签: php wordpress nginx-unit


    【解决方案1】:

    据我所知,除了注释这些行之外,没有解决方法可以通过 GET 请求运行 wp-cron.php

    但是,您可以通过从命令行运行 php /path/to/wordpress/wp-cron.php 或设置系统 cron(例如,每 10 分钟)来运行 wp-cron.php:

    10 * * * * php /path/to/wordpress/wp-cron.php > /dev/null 2>&1
    

    【讨论】:

      猜你喜欢
      • 2013-12-10
      • 2017-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-21
      • 2020-03-13
      • 2014-02-03
      相关资源
      最近更新 更多