@@ -204,7 +204,8 @@ PHP_JSON_API zend_result php_json_decode_ex(zval *return_value, const char *str,
204204
205205 if (php_json_yyparse (& parser )) {
206206 php_json_error_code error_code = php_json_parser_error_code (& parser );
207- if (!(options & PHP_JSON_THROW_ON_ERROR )) {
207+ if (!(options & PHP_JSON_THROW_ON_ERROR ) &&
208+ (EG (current_execute_data )-> prev_execute_data -> func -> common .fn_flags & ZEND_ACC_THROW_WARNING ) == 0 ) {
208209 JSON_G (error_code ) = error_code ;
209210 } else {
210211 zend_throw_exception (php_json_exception_ce , php_json_get_error_msg (error_code ), error_code );
@@ -237,7 +238,9 @@ PHP_FUNCTION(json_encode)
237238 encoder .max_depth = (int )depth ;
238239 php_json_encode_zval (& buf , parameter , (int )options , & encoder );
239240
240- if (!(options & PHP_JSON_THROW_ON_ERROR ) || (options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR )) {
241+ if ((!(options & PHP_JSON_THROW_ON_ERROR ) &&
242+ (EX (prev_execute_data )-> func -> common .fn_flags & ZEND_ACC_THROW_WARNING ) == 0 )
243+ || (options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR )) {
241244 JSON_G (error_code ) = encoder .error_code ;
242245 if (encoder .error_code != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR )) {
243246 smart_str_free (& buf );
@@ -277,17 +280,19 @@ PHP_FUNCTION(json_decode)
277280 Z_PARAM_LONG (options )
278281 ZEND_PARSE_PARAMETERS_END ();
279282
280- if (!(options & PHP_JSON_THROW_ON_ERROR )) {
283+ if (!(options & PHP_JSON_THROW_ON_ERROR ) &&
284+ (EX (prev_execute_data )-> func -> common .fn_flags & ZEND_ACC_THROW_WARNING ) == 0 ) {
281285 JSON_G (error_code ) = PHP_JSON_ERROR_NONE ;
282286 }
283287
284288 if (!str_len ) {
285- if (!(options & PHP_JSON_THROW_ON_ERROR )) {
289+ if (!(options & PHP_JSON_THROW_ON_ERROR ) &&
290+ (EX (prev_execute_data )-> func -> common .fn_flags & ZEND_ACC_THROW_WARNING ) == 0 ) {
286291 JSON_G (error_code ) = PHP_JSON_ERROR_SYNTAX ;
287- } else {
288- zend_throw_exception (php_json_exception_ce , php_json_get_error_msg (PHP_JSON_ERROR_SYNTAX ), PHP_JSON_ERROR_SYNTAX );
292+ RETURN_NULL ();
289293 }
290- RETURN_NULL ();
294+ zend_throw_exception (php_json_exception_ce , php_json_get_error_msg (PHP_JSON_ERROR_SYNTAX ), PHP_JSON_ERROR_SYNTAX );
295+ RETURN_THROWS ();
291296 }
292297
293298 if (depth <= 0 ) {
0 commit comments