fix: IncomingRequest::getJsonVar() may cause TypeError#5392
fix: IncomingRequest::getJsonVar() may cause TypeError#5392kenjis merged 2 commits intocodeigniter4:developfrom
IncomingRequest::getJsonVar() may cause TypeError#5392Conversation
See codeigniter4#5391 [TypeError] dot_array_search(): Argument #2 ($array) must be of type array, null given, called in .../system/HTTP/IncomingRequest.php on line 540 at SYSTEMPATH/Helpers/array_helper.php:21
ErrorException: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated
|
JSON can contain null as a value. Therefore, I do not know if this way of solving the problem is correct. |
|
If the user input is |
|
i mean // body: {"var" : null}
$request->getVar('var'); // null
// body: {}
$request->getVar('var'); // null
// body: null
$request->getVar('var'); // nullIf we assume that the value "var" can be null, then the last two examples are incorrect behavior. If we compare it with working with an array, then: $a = [];
$a['test'];
// Warning: Undefined array key "test"
$a = null;
$a['test'];
// Warning: Trying to access array offset on value of type null |
|
It depends on If it should throw an exception, #5391 is not a bug. |
|
@kenjis could you verify PHPUnit error on develop branch? |
|
@samsonasik Do you mean this?
It is an error of PhpCoveralls: php-coveralls/php-coveralls#327 |
|
Yes, is there a way to pin to specific coveralls version that is working? |
|
Adding this to composer.json? |
|
Yes, that's probably the temporary fix 👍 |
|
@samsonasik Okay, I will do it. |
Description
Fixes #5391
Checklist: