Wordpress PHP的致命错误与Openshift


Wordpress PHP Fatal Error with Openshift

当我试图从管理面板访问我的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。然后重新启动应用程序。

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

我想知道如何解决这个问题,而不创建一个新的齿轮和通过数据库迁移我的数据。注意:前端工作正常

Wordpress版本:4.1.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