Skip to content

Commit 0148161

Browse files
committed
Admin: prevent PHP fatal error inside of get_transient_value_type()
This commit lowers the priority of the "is_object( json_decode( $value ) )" check and places it inside of a "is_string()" call. See: https://wordpress.org/support/topic/2-0-0-warning-json_decode-expects-parameter-1-to-be-string-object-given-in/ Fixes #59.
1 parent 69dd863 commit 0148161

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

transients-manager.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,6 @@ private function get_transient_value_type( $transient ) {
825825
if ( is_array( $value ) ) {
826826
$type = esc_html__( 'array', 'transients-manager' );
827827

828-
// JSON
829-
} elseif ( is_object( json_decode( $value ) ) ) {
830-
$type = esc_html__( 'json', 'transients-manager' );
831-
832828
// Object
833829
} elseif ( is_object( $value ) ) {
834830
$type = esc_html__( 'object', 'transients-manager' );
@@ -859,6 +855,11 @@ private function get_transient_value_type( $transient ) {
859855
$type = esc_html__( 'numeric', 'transients-manager' );
860856
}
861857

858+
// JSON
859+
} elseif ( is_string( $value ) && is_object( json_decode( $value ) ) ) {
860+
$type = esc_html__( 'json', 'transients-manager' );
861+
862+
// Scalar
862863
} else {
863864
$type = esc_html__( 'scalar', 'transients-manager' );
864865
}

0 commit comments

Comments
 (0)