From 3346f246ed2bf65c669961249464c6c5e3df5c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Tue, 2 Jun 2020 16:52:34 +0200 Subject: [PATCH] Check error code instead of string --- lib/global-styles.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index 31438c3215632..a46473c3a2d77 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -81,9 +81,9 @@ function gutenberg_experimental_global_styles_get_from_file( $file_path ) { true ); - $json_decoding_error = json_last_error_msg(); - if ( 'No error' !== $json_decoding_error ) { - error_log( 'Error when decoding file schema: ' . $json_decoding_error ); + $json_decoding_error = json_last_error(); + if ( JSON_ERROR_NONE !== $json_decoding_error ) { + error_log( 'Error when decoding file schema: ' . json_last_error_msg() ); return $config; } @@ -105,9 +105,9 @@ function gutenberg_experimental_global_styles_get_user() { if ( array_key_exists( 'post_content', $user_cpt ) ) { $decoded_data = json_decode( $user_cpt['post_content'], true ); - $json_decoding_error = json_last_error_msg(); - if ( 'No error' !== $json_decoding_error ) { - error_log( 'Error when decoding user schema: ' . $json_decoding_error ); + $json_decoding_error = json_last_error(); + if ( JSON_ERROR_NONE !== $json_decoding_error ) { + error_log( 'Error when decoding user schema: ' . json_last_error_msg() ); return $config; }