Wordpress PHP Fatal Error with Openshift -


when try access plugins or themes section of wordpress site admin panel presented blank screen. when run logs following error:

navigating wp-admin/plugins.php:

php fatal error:  call undefined function wp_json_encode() in /var/lib/openshift/{userid}/app-root/data/current/wp-includes/update.php on line 277 

navigating wp-admin/themes.php:

php fatal error:  call undefined function wp_json_encode() in /var/lib/openshift/{userid}/app-root/data/current/wp-includes/update.php on line 440 

solutions online indicated should re-add function, or re-install wordpress. without access core files, downloaded local repository of application (but noticed did not contain of plugins or themes had uploaded via admin interface).

i extracted plugin , theme (placing them in respective directories) pushed changes production in hopes extract , re-install updated version of wordpress. restarted app.

the error still persists , can not validate if plugin or theme uploaded installed. there way refresh or reinstall wordpress instance on openshift?

i'm wondering how can fix issue without creating new gear , migrating data via database. note: front end working fine.

version of wordpress: 4.1.1

i ended connecting app via sftp , modified file following directly

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

and added following function:

function wp_json_encode( $data, $options = 0, $depth = 512 ) { /*  * json_encode() has had params added on years.  * $options added in 5.3, , $depth in 5.5.  * need make sure call 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() successful, no need more sanity checking. // ... unless we're in old version of php, , json_encode() returned // string containing 'null'. need 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 ); 

}

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


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -