【问题标题】:Wordpress PHP Fatal Error with Openshift使用 Openshift 的 Wordpress PHP 致命错误
【发布时间】:2015-07-08 20:32:38
【问题描述】:

当我尝试从管理面板访问我的 wordpress 网站的插件或主题部分时,我看到了一个空白屏幕。当我运行日志时,我收到以下错误:

导航到 wp-admin/plugins.php:

PHP Fatal error:  Call to undefined function wp_json_encode() in /var/lib/openshift/{userID}/app-root/data/current/wp-includes/update.php on line 277

导航到 wp-admin/themes.php:

PHP Fatal error:  Call to undefined function wp_json_encode() in /var/lib/openshift/{userID}/app-root/data/current/wp-includes/update.php on line 440

网上的解决方案提示我应该重新添加该功能,或者重新安装Wordpress。在无法访问核心文件的情况下,我下载了应用程序的本地存储库(但注意到它不包含我通过管理界面上传的任何插件或主题)。

我提取了一个插件和主题(将它们放在各自的目录中),然后将更改推送到生产环境,希望它能提取并重新安装更新版本的 wordpress。然后我重新启动了应用程序。

错误仍然存​​在,我无法验证我上传的插件或主题是否已安装。有没有办法在 Openshift 上刷新或重新安装 wordpress 实例?

我想知道如何在不创建新设备并通过数据库迁移数据的情况下解决此问题。注意:前端工作正常。

Wordpress 版本:4.1.1

【问题讨论】:

    标签: php wordpress openshift


    【解决方案1】:

    我最终通过 SFTP 连接到应用程序并直接修改了以下文件

    /var/lib/openshift/{userID}/app-root/data/current/wp-includes/functions.php 
    

    并添加了以下功能:

    function wp_json_encode( $data, $options = 0, $depth = 512 ) {
    /*
     * json_encode() has had extra params added over the years.
     * $options was added in 5.3, and $depth in 5.5.
     * We need to make sure we call it with the correct arguments.
     */
    if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
        $args = array( $data, $options, $depth );
    } elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
        $args = array( $data, $options );
    } else {
        $args = array( $data );
    }
    
    $json = call_user_func_array( 'json_encode', $args );
    
    // If json_encode() was successful, no need to do more sanity checking.
    // ... unless we're in an old version of PHP, and json_encode() returned
    // a string containing 'null'. Then we need to do more sanity checking.
    if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) )  {
        return $json;
    }
    
    try {
        $args[0] = _wp_json_sanity_check( $data, $depth );
    } catch ( Exception $e ) {
        return false;
    }
    
    return call_user_func_array( 'json_encode', $args );
    

    }

    参考:https://wordpress.org/support/topic/fatal-error-call-to-undefined-function-wp_json_encode-in

    【讨论】:

      猜你喜欢
      • 2015-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-09
      • 1970-01-01
      相关资源
      最近更新 更多