From a3ef933f2db294316a2d40b28abc874bb9587575 Mon Sep 17 00:00:00 2001 From: stan Date: Fri, 22 Jul 2011 08:34:35 +0000 Subject: [PATCH] Check for json_last_error function existence before invoking. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@3482 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/includes/functions.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index 41ac8e549..dc962f98d 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -2206,20 +2206,23 @@ function isVector ( &$array ) function checkJsonError() { - switch( json_last_error() ) + if ( function_exists('json_last_error') ) { - case JSON_ERROR_DEPTH : - Fatal( "Unable to decode JSON string '$value', maximum stack depth exceeded" ); - case JSON_ERROR_CTRL_CHAR : - Fatal( "Unable to decode JSON string '$value', unexpected control character found" ); - case JSON_ERROR_STATE_MISMATCH : - Fatal( "Unable to decode JSON string '$value', invalid or malformed JSON" ); - case JSON_ERROR_SYNTAX : - Fatal( "Unable to decode JSON string '$value', syntax error" ); - default : - Fatal( "Unable to decode JSON string '$value', unexpected error ".json_last_error() ); - case JSON_ERROR_NONE: - break; + switch( json_last_error() ) + { + case JSON_ERROR_DEPTH : + Fatal( "Unable to decode JSON string '$value', maximum stack depth exceeded" ); + case JSON_ERROR_CTRL_CHAR : + Fatal( "Unable to decode JSON string '$value', unexpected control character found" ); + case JSON_ERROR_STATE_MISMATCH : + Fatal( "Unable to decode JSON string '$value', invalid or malformed JSON" ); + case JSON_ERROR_SYNTAX : + Fatal( "Unable to decode JSON string '$value', syntax error" ); + default : + Fatal( "Unable to decode JSON string '$value', unexpected error ".json_last_error() ); + case JSON_ERROR_NONE: + break; + } } }