Skip to content

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

Description

@fijas

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

  • OS: Ubuntu Server
  • Web server: Apache 2
  • PHP version: 7.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions