You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Thank you for reporting. I confirmed the TypeError in develop branch.
<?phpnamespaceApp\Controllers;
class Home extends BaseController
{
publicfunctionindex()
{
d($this->request->getJsonVar('myKey'));
}
}
$ php public/index.php
[TypeError]
dot_array_search(): Argument #2 ($array) must be of type array, null given, called in /Users/kenji/work/codeigniter/CodeIgniter4/system/HTTP/IncomingRequest.php on line 540
at SYSTEMPATH/Helpers/array_helper.php:21
Backtrace:
1 SYSTEMPATH/HTTP/IncomingRequest.php:540
dot_array_search('myKey', null)
2 APPPATH/Controllers/Home.php:9
CodeIgniter\HTTP\IncomingRequest()->getJsonVar('myKey')
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
kenjis
added a commit
to kenjis/CodeIgniter4
that referenced
this issue
Nov 25, 2021
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
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 appearsSolution:
The text was updated successfully, but these errors were encountered: