From 258175149d1dceb44c382ea34339dafff3eed107 Mon Sep 17 00:00:00 2001 From: fps01 Date: Tue, 15 Mar 2016 20:51:16 +0300 Subject: [PATCH] Fixes #11125: Fixed `JSON_ERROR_SYNTAX` for `json_decode(null)` in PHP 7 --- framework/CHANGELOG.md | 1 + framework/helpers/BaseJson.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index e99161fdba..265ae86986 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -14,6 +14,7 @@ Yii Framework 2 Change Log - Bug #10974: `yii.js` - fixed error in ajaxPrefilter event handler, caused by blocked frame (maximal) - Bug #11038: Fixed handling of intervals of 0 seconds in `yii\i18n\Formatter::asDuration()` (VirtualRJ) - Bug #11093: Fixed `yii\db\QueryBuilder::buildAndCondition()` to add query params passed directly by `yii\db\Expression` (CedricYii, silverfire) +- Bug #11125: Fixed `JSON_ERROR_SYNTAX` for `json_decode(null)` in PHP 7 (fps01) - Bug: SQlite querybuilder did not create primary key with bigint for `TYPE_BIGPK` (cebe) - Enh #5469: Add mimetype validation by mask in FileValidator (kirsenn, samdark, silverfire) - Enh #8602: `yii\validators\DateValidator` skip validation for `timestampAttribute`, if it is already in correct format (klimov-paul) diff --git a/framework/helpers/BaseJson.php b/framework/helpers/BaseJson.php index a787e55d01..751efee97e 100644 --- a/framework/helpers/BaseJson.php +++ b/framework/helpers/BaseJson.php @@ -90,6 +90,8 @@ class BaseJson { if (is_array($json)) { throw new InvalidParamException('Invalid JSON data.'); + } elseif ($json === null || $json === '') { + return null; } $decode = json_decode((string) $json, $asArray); static::handleJsonError(json_last_error());