codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.35k stars 1.9k forks source link

Debug Toolbar causes error if an array is provided as session value since Beta 2 #1919

Closed fijas closed 5 years ago

fijas commented 5 years ago

name: Bug report about: Help us improve the framework by reporting bugs!


Describe the bug If I set an array as a session value, the Debug Toolbar causes the following error:

preg_match() expects parameter 2 to be string, array given

SYSTEMPATH/Debug/Toolbar.php at line 144

143                 // Replace the binary data with string to avoid json_encode failure.
144                 if (preg_match('~[^\x20-\x7E\t\r\n]~', $value))
145                 {
146                     $value = 'binary data';
147                 }

Probably related to this issue #1779 and it's fix. This was working in beta 1 iirc.

CodeIgniter 4 version 4.0.0-beta.2

Affected module(s) Debug Toolbar

Expected behavior, and steps to reproduce if appropriate The Debug Toolbar should just display the array properly.

It should be easily reproducible by setting a nested array as a session value:

$arr = [
   'a' => 1,
   'b' => [2, 3, 4]
];
session()->set($arr);

Context

atishhamte commented 5 years ago

@fijas, could you check with the changes done in PR, whether it solves your problem or not.

fijas commented 5 years ago

@atishamte Yes, that seems to fix it...