-
Notifications
You must be signed in to change notification settings - Fork 2k
Bug: public function getJsonVar error in the code #5391
Copy link
Copy link
Closed
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them
Description
PHP Version
8.0
CodeIgniter4 Version
4.1.2
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
No response
What happened?
If "null" is sent to the server and when trying to get data through "Services :: request () -> getVar('myKey')", the error "Argument 2 passed to dot_array_search () must be of the type array..."
Steps to Reproduce
I am sending a POST request without data
Expected Output
Services :: request () -> getVar ('myKey') function should return "null"
Anything else?
File:
system/HTTP/IncomingRequest.php
public function getJsonVar()
Line 540: $data = dot_array_search($index, $this->getJSON(true));
if $this->getJSON(true) returns null then an error appears
Solution:
$getJson = $this->getJSON(true) ?: [];
$data = dot_array_search($index, $getJson);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them