CodeIgniter4: Bug: ErrorException: Undefined index: file: SYSTEMPATH\Debug\Toolbar\Collectors\Database.php at line 142

PHP Version

7.3

CodeIgniter4 Version

v4.1.6

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

MariaDB 10.2

What happened?

The issue is related to the latest build where there seems to be an issue with the trace line of the debugger (Toolbar) when the file attribute is not available.

output log of the trace line causing this issue

Array
(
    [function] => read
    [class] => CodeIgniter\Session\Handlers\DatabaseHandler
    [object] => CodeIgniter\Session\Handlers\DatabaseHandler Object
        (
            [DBGroup:protected] => default
            [table:protected] => ...

Steps to Reproduce

Update from 4.1.5 to 4.1.6.

Expected Output

Maybe check if the file attribute is set? https://github.com/codeigniter4/CodeIgniter4/commit/e97b95b2ffc8b11a4a97202cab12d6a839ddca93#diff-48dee7e39770b002fe3f48f70db03aaa01fd79d5830d5ee91ee9f8ccda44b4ea

if (!isset($traceLine['file'])) { ...then do the clean-up? }

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (12 by maintainers)

Commits related to this issue

Most upvoted comments

As temporary solution, i have modified toolbar.php file and removed database collector. image

For the database session handler, it is because it extends PHP’s native SessionHandlerInterface. When CI4 calls session_start(), PHP internally calls the session handler assigned.

From the docs:

Please note the callback methods of this class are designed to be called internally by PHP and are not meant to be called from user-space code.

Thus, there is no file/line since it is an internal call.

@kenjis As I have mentioned earlier, if you perform a read on any model, the trace line will have the type of function read and since there is no file attribute available on that trace line, an error of undefined index file will be thrown.

Updating itself is not going to throw errors, it’s for when you get data from a table/model and CI_DEBUGGER is enabled. this change (I have referenced it earlier) was added in the latest release (FYI).