Skip to content

Bug: public function getJsonVar error in the code #5391

@amigoscs

Description

@amigoscs

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);

Metadata

Metadata

Assignees

Labels

bugVerified issues on the current code behavior or pull requests that will fix them

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions