Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
iprixi opened this issue Jan 4, 2022 · 20 comments · Fixed by #5553
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@iprixi
Copy link

iprixi commented Jan 4, 2022

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?
e97b95b#diff-48dee7e39770b002fe3f48f70db03aaa01fd79d5830d5ee91ee9f8ccda44b4ea

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

Anything else?

No response

@iprixi iprixi added the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 4, 2022
@kenjis
Copy link
Member

kenjis commented Jan 4, 2022

Thank you for reporting.

Could you show us how to reproduce?
Updating from 4.1.5 to 4.1.6 does not reproduce this error, because we don't have your code.

@iprixi
Copy link
Author

iprixi commented Jan 4, 2022

@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).

@yassinedoghri
Copy link
Contributor

I'm getting the same bug. Not sure how to reproduce it but adding a check before accessing the file key fixes it as @iprixi suggested.

Here's an example of the $traceLine without the file key if it can help:

image

@mkilinskidev
Copy link

Same here, there is no file key.

image

@cijagani
Copy link
Contributor

cijagani commented Jan 4, 2022

Correct i also faced same error. it only occur when you set CI_DEBUGGER true. I was using v 4.1.5 and composer installation

@cijagani
Copy link
Contributor

cijagani commented Jan 4, 2022

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

@NSURLSession0
Copy link
Contributor

NSURLSession0 commented Jan 4, 2022

Same issue here. Caused by commit e97b95b

@kenjis
Copy link
Member

kenjis commented Jan 4, 2022

Could anyone show us the minimum code that reproduce the error?
for fixing the error soon.

We need to write test code.

Note, we expect all code changes or bug-fixes to be accompanied by one or more tests added to our test suite to prove the code works. If pull requests are not accompanied by relevant tests, they will likely be closed. Since we are a team of volunteers, we don't have any more time to work on the framework than you do. Please make it as painless for your contributions to be included as possible. If you need help with getting tests running on your local machines, ask for help on the forums. We would be happy to help out.
https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md#contributions

Or sending a PR which fixes this issue is very welcome.
Thank you.

@iprixi
Copy link
Author

iprixi commented Jan 5, 2022

@kenjis I will create a PR for this.

iprixi added a commit to iprixi/CodeIgniter4 that referenced this issue Jan 5, 2022
- Fix for using undefined key of file
@iprixi
Copy link
Author

iprixi commented Jan 5, 2022

@kenjis
#5543

@tomomo
Copy link

tomomo commented Jan 5, 2022

I encountered a similar phenomenon.
It worked when I disabled the following in .env.

app_sessionDriver = 'CodeIgniter\Session\Handlers\DatabaseHandler'
app_sessionSavePath = 'ci_sessions'
app_sessionExpiration = 36000

So I wonder if the logic around the session using DB is the cause.

@kenjis
Copy link
Member

kenjis commented Jan 5, 2022

@tomomo Thanks!

I was able to get the $query['trace'] (PHP 8.1.1):

/Users/kenji/work/codeigniter/CodeIgniter4/system/Debug/Toolbar/Collectors/Database.php:139:
array (size=19)
  0 => 
    array (size=6)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Events/Events.php' (length=67)
      'line' => int 149
      'function' => string 'collect' (length=7)
      'class' => string 'CodeIgniter\Debug\Toolbar\Collectors\Database' (length=45)
      'type' => string '::' (length=2)
      'args' => 
        array (size=1)
          0 => 
            object(CodeIgniter\Database\Query)[72]
              ...
  1 => 
    array (size=6)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Database/BaseConnection.php' (length=77)
      'line' => int 636
      'function' => string 'trigger' (length=7)
      'class' => string 'CodeIgniter\Events\Events' (length=25)
      'type' => string '::' (length=2)
      'args' => 
        array (size=2)
          0 => string 'DBQuery' (length=7)
          1 => 
            object(CodeIgniter\Database\Query)[72]
              ...
  2 => 
    array (size=7)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Session/Handlers/DatabaseHandler.php' (length=86)
      'line' => int 268
      'function' => string 'query' (length=5)
      'class' => string 'CodeIgniter\Database\BaseConnection' (length=35)
      'object' => 
        object(CodeIgniter\Database\MySQLi\Connection)[68]
          protected 'DSN' => string '' (length=0)
          protected 'port' => int 3306
          protected 'hostname' => string 'localhost' (length=9)
          protected 'username' => string 'root' (length=4)
          protected 'password' => string '' (length=0)
          protected 'database' => string 'ci4' (length=3)
          public 'DBDriver' => string 'MySQLi' (length=6)
          protected 'subdriver' => null
          protected 'DBPrefix' => string '' (length=0)
          protected 'pConnect' => boolean false
          protected 'DBDebug' => boolean true
          protected 'charset' => string 'utf8' (length=4)
          protected 'DBCollat' => string 'utf8_general_ci' (length=15)
          protected 'swapPre' => string '' (length=0)
          protected 'encrypt' => boolean false
          protected 'compress' => boolean false
          protected 'strictOn' => boolean false
          protected 'failover' => 
            array (size=0)
              ...
          protected 'lastQuery' => 
            object(CodeIgniter\Database\Query)[74]
              ...
          public 'connID' => 
            object(mysqli)[71]
              ...
          public 'resultID' => 
            object(mysqli_result)[76]
              ...
          public 'protectIdentifiers' => boolean true
          protected 'reservedIdentifiers' => 
            array (size=1)
              ...
          public 'escapeChar' => string '`' (length=1)
          public 'likeEscapeStr' => string ' ESCAPE '%s' ' (length=13)
          public 'likeEscapeChar' => string '!' (length=1)
          protected 'pregEscapeChar' => 
            array (size=4)
              ...
          public 'dataCache' => 
            array (size=0)
              ...
          protected 'connectTime' => float 1641349430.1933
          protected 'connectDuration' => float 0.026990175247192
          protected 'pretend' => boolean false
          public 'transEnabled' => boolean true
          public 'transStrict' => boolean true
          protected 'transDepth' => int 0
          protected 'transStatus' => boolean true
          protected 'transFailure' => boolean false
          protected 'aliasedTables' => 
            array (size=0)
              ...
          protected 'queryClass' => string 'CodeIgniter\Database\Query' (length=26)
          public 'deleteHack' => boolean true
          public 'mysqli' => 
            object(mysqli)[71]
              ...
          public 'resultMode' => int 0
      'type' => string '->' (length=2)
      'args' => 
        array (size=1)
          0 => string 'SELECT GET_LOCK('2b892e0152f080d22f3cb0e6ae38debd', 300) AS ci_session_lock' (length=75)
  3 => 
    array (size=7)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Session/Handlers/DatabaseHandler.php' (length=86)
      'line' => int 111
      'function' => string 'lockSession' (length=11)
      'class' => string 'CodeIgniter\Session\Handlers\DatabaseHandler' (length=44)
      'object' => 
        object(CodeIgniter\Session\Handlers\DatabaseHandler)[65]
          protected 'fingerprint' => string 'ec15ca5d5a3e707de835bf7a4f33b423' (length=32)
          protected 'lock' => string '2b892e0152f080d22f3cb0e6ae38debd' (length=32)
          protected 'cookiePrefix' => string '' (length=0)
          protected 'cookieDomain' => string '' (length=0)
          protected 'cookiePath' => string '/' (length=1)
          protected 'cookieSecure' => boolean false
          protected 'cookieName' => string 'ci_session' (length=10)
          protected 'matchIP' => boolean false
          protected 'sessionID' => string '07rfo706ksmjkuiiaedaj760k9mfh2q6' (length=32)
          protected 'savePath' => string 'ci_sessions' (length=11)
          protected 'ipAddress' => string '::1' (length=3)
          protected 'logger' => 
            object(CodeIgniter\Log\Logger)[48]
              ...
          protected 'DBGroup' => string 'default' (length=7)
          protected 'table' => string 'ci_sessions' (length=11)
          protected 'db' => 
            object(CodeIgniter\Database\MySQLi\Connection)[68]
              ...
          protected 'platform' => string 'mysql' (length=5)
          protected 'rowExists' => boolean true
      'type' => string '->' (length=2)
      'args' => 
        array (size=1)
          0 => string '07rfo706ksmjkuiiaedaj760k9mfh2q6' (length=32)
  4 => 
    array (size=5)
      'function' => string 'read' (length=4)
      'class' => string 'CodeIgniter\Session\Handlers\DatabaseHandler' (length=44)
      'object' => 
        object(CodeIgniter\Session\Handlers\DatabaseHandler)[65]
          protected 'fingerprint' => string 'ec15ca5d5a3e707de835bf7a4f33b423' (length=32)
          protected 'lock' => string '2b892e0152f080d22f3cb0e6ae38debd' (length=32)
          protected 'cookiePrefix' => string '' (length=0)
          protected 'cookieDomain' => string '' (length=0)
          protected 'cookiePath' => string '/' (length=1)
          protected 'cookieSecure' => boolean false
          protected 'cookieName' => string 'ci_session' (length=10)
          protected 'matchIP' => boolean false
          protected 'sessionID' => string '07rfo706ksmjkuiiaedaj760k9mfh2q6' (length=32)
          protected 'savePath' => string 'ci_sessions' (length=11)
          protected 'ipAddress' => string '::1' (length=3)
          protected 'logger' => 
            object(CodeIgniter\Log\Logger)[48]
              ...
          protected 'DBGroup' => string 'default' (length=7)
          protected 'table' => string 'ci_sessions' (length=11)
          protected 'db' => 
            object(CodeIgniter\Database\MySQLi\Connection)[68]
              ...
          protected 'platform' => string 'mysql' (length=5)
          protected 'rowExists' => boolean true
      'type' => string '->' (length=2)
      'args' => 
        array (size=1)
          0 => string '07rfo706ksmjkuiiaedaj760k9mfh2q6' (length=32)
  5 => 
    array (size=4)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Session/Session.php' (length=69)
      'line' => int 894
      'function' => string 'session_start' (length=13)
      'args' => 
        array (size=0)
          empty
  6 => 
    array (size=7)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Session/Session.php' (length=69)
      'line' => int 238
      'function' => string 'startSession' (length=12)
      'class' => string 'CodeIgniter\Session\Session' (length=27)
      'object' => 
        object(CodeIgniter\Session\Session)[69]
          protected 'driver' => 
            object(CodeIgniter\Session\Handlers\DatabaseHandler)[65]
              ...
          protected 'sessionDriverName' => string 'CodeIgniter\Session\Handlers\DatabaseHandler' (length=44)
          protected 'sessionCookieName' => string 'ci_session' (length=10)
          protected 'sessionExpiration' => string '7200' (length=4)
          protected 'sessionSavePath' => string 'ci_sessions' (length=11)
          protected 'sessionMatchIP' => boolean false
          protected 'sessionTimeToUpdate' => int 300
          protected 'sessionRegenerateDestroy' => boolean false
          protected 'cookie' => 
            object(CodeIgniter\Cookie\Cookie)[70]
              ...
          protected 'cookieDomain' => string '' (length=0)
          protected 'cookiePath' => string '/' (length=1)
          protected 'cookieSecure' => boolean false
          protected 'cookieSameSite' => string 'Lax' (length=3)
          protected 'sidRegexp' => string '[0-9a-v]{32}' (length=12)
          protected 'logger' => 
            object(CodeIgniter\Log\Logger)[48]
              ...
      'type' => string '->' (length=2)
      'args' => 
        array (size=0)
          empty
  7 => 
    array (size=7)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Config/Services.php' (length=69)
      'line' => int 577
      'function' => string 'start' (length=5)
      'class' => string 'CodeIgniter\Session\Session' (length=27)
      'object' => 
        object(CodeIgniter\Session\Session)[69]
          protected 'driver' => 
            object(CodeIgniter\Session\Handlers\DatabaseHandler)[65]
              ...
          protected 'sessionDriverName' => string 'CodeIgniter\Session\Handlers\DatabaseHandler' (length=44)
          protected 'sessionCookieName' => string 'ci_session' (length=10)
          protected 'sessionExpiration' => string '7200' (length=4)
          protected 'sessionSavePath' => string 'ci_sessions' (length=11)
          protected 'sessionMatchIP' => boolean false
          protected 'sessionTimeToUpdate' => int 300
          protected 'sessionRegenerateDestroy' => boolean false
          protected 'cookie' => 
            object(CodeIgniter\Cookie\Cookie)[70]
              ...
          protected 'cookieDomain' => string '' (length=0)
          protected 'cookiePath' => string '/' (length=1)
          protected 'cookieSecure' => boolean false
          protected 'cookieSameSite' => string 'Lax' (length=3)
          protected 'sidRegexp' => string '[0-9a-v]{32}' (length=12)
          protected 'logger' => 
            object(CodeIgniter\Log\Logger)[48]
              ...
      'type' => string '->' (length=2)
      'args' => 
        array (size=0)
          empty
  8 => 
    array (size=6)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Config/BaseService.php' (length=72)
      'line' => int 248
      'function' => string 'session' (length=7)
      'class' => string 'CodeIgniter\Config\Services' (length=27)
      'type' => string '::' (length=2)
      'args' => 
        array (size=2)
          0 => 
            object(Config\App)[9]
              ...
          1 => boolean false
  9 => 
    array (size=6)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Config/BaseService.php' (length=72)
      'line' => int 189
      'function' => string '__callStatic' (length=12)
      'class' => string 'CodeIgniter\Config\BaseService' (length=30)
      'type' => string '::' (length=2)
      'args' => 
        array (size=2)
          0 => string 'session' (length=7)
          1 => 
            array (size=2)
              ...
  10 => 
    array (size=6)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Config/Services.php' (length=69)
      'line' => int 563
      'function' => string 'getSharedInstance' (length=17)
      'class' => string 'CodeIgniter\Config\BaseService' (length=30)
      'type' => string '::' (length=2)
      'args' => 
        array (size=2)
          0 => string 'session' (length=7)
          1 => null
  11 => 
    array (size=6)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Config/BaseService.php' (length=72)
      'line' => int 248
      'function' => string 'session' (length=7)
      'class' => string 'CodeIgniter\Config\Services' (length=27)
      'type' => string '::' (length=2)
      'args' => 
        array (size=0)
          empty
  12 => 
    array (size=6)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Common.php' (length=60)
      'line' => int 901
      'function' => string '__callStatic' (length=12)
      'class' => string 'CodeIgniter\Config\BaseService' (length=30)
      'type' => string '::' (length=2)
      'args' => 
        array (size=2)
          0 => string 'session' (length=7)
          1 => 
            array (size=0)
              ...
  13 => 
    array (size=4)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/app/Controllers/Home.php' (length=67)
      'line' => int 9
      'function' => string 'session' (length=7)
      'args' => 
        array (size=0)
          empty
  14 => 
    array (size=7)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/CodeIgniter.php' (length=65)
      'line' => int 825
      'function' => string 'index' (length=5)
      'class' => string 'App\Controllers\Home' (length=20)
      'object' => 
        object(App\Controllers\Home)[64]
          protected 'helpers' => 
            array (size=0)
              ...
          protected 'request' => 
            object(CodeIgniter\HTTP\IncomingRequest)[12]
              ...
          protected 'response' => 
            object(CodeIgniter\HTTP\Response)[28]
              ...
          protected 'logger' => 
            object(CodeIgniter\Log\Logger)[48]
              ...
          protected 'forceHTTPS' => int 0
          protected 'validator' => null
      'type' => string '->' (length=2)
      'args' => 
        array (size=0)
          empty
  15 => 
    array (size=7)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/CodeIgniter.php' (length=65)
      'line' => int 412
      'function' => string 'runController' (length=13)
      'class' => string 'CodeIgniter\CodeIgniter' (length=23)
      'object' => 
        object(CodeIgniter\CodeIgniter)[10]
          protected 'startTime' => float 1641349430.1461
          protected 'totalTime' => float 0.087
          protected 'config' => 
            object(Config\App)[9]
              ...
          protected 'benchmark' => 
            object(CodeIgniter\Debug\Timer)[36]
              ...
          protected 'request' => 
            object(CodeIgniter\HTTP\IncomingRequest)[12]
              ...
          protected 'response' => 
            object(CodeIgniter\HTTP\Response)[28]
              ...
          protected 'router' => 
            object(CodeIgniter\Router\Router)[60]
              ...
          protected 'controller' => string '\App\Controllers\Home' (length=21)
          protected 'method' => string 'index' (length=5)
          protected 'output' => string '<!-- DEBUG-VIEW START 1 APPPATH/Views/welcome_message.php -->
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Welcome to CodeIgniter 4!</title>
	<meta name="description" content="The small framework with powerful features">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="shortcut icon" type="image/png" href="/favicon.ico"/>

	<!-- STYLES -->

	<style {csp-style-nonce}>
		* {
			transition: background-color 300ms ease, color 300ms ease;
		}
		*:focu'... (length=18369)
          protected 'path' => null
          protected 'useSafeOutput' => boolean false
      'type' => string '->' (length=2)
      'args' => 
        array (size=1)
          0 => 
            object(App\Controllers\Home)[64]
              ...
  16 => 
    array (size=7)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/CodeIgniter.php' (length=65)
      'line' => int 320
      'function' => string 'handleRequest' (length=13)
      'class' => string 'CodeIgniter\CodeIgniter' (length=23)
      'object' => 
        object(CodeIgniter\CodeIgniter)[10]
          protected 'startTime' => float 1641349430.1461
          protected 'totalTime' => float 0.087
          protected 'config' => 
            object(Config\App)[9]
              ...
          protected 'benchmark' => 
            object(CodeIgniter\Debug\Timer)[36]
              ...
          protected 'request' => 
            object(CodeIgniter\HTTP\IncomingRequest)[12]
              ...
          protected 'response' => 
            object(CodeIgniter\HTTP\Response)[28]
              ...
          protected 'router' => 
            object(CodeIgniter\Router\Router)[60]
              ...
          protected 'controller' => string '\App\Controllers\Home' (length=21)
          protected 'method' => string 'index' (length=5)
          protected 'output' => string '<!-- DEBUG-VIEW START 1 APPPATH/Views/welcome_message.php -->
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Welcome to CodeIgniter 4!</title>
	<meta name="description" content="The small framework with powerful features">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="shortcut icon" type="image/png" href="/favicon.ico"/>

	<!-- STYLES -->

	<style {csp-style-nonce}>
		* {
			transition: background-color 300ms ease, color 300ms ease;
		}
		*:focu'... (length=18369)
          protected 'path' => null
          protected 'useSafeOutput' => boolean false
      'type' => string '->' (length=2)
      'args' => 
        array (size=3)
          0 => null
          1 => 
            object(Config\Cache)[53]
              ...
          2 => boolean false
  17 => 
    array (size=7)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/public/index.php' (length=59)
      'line' => int 37
      'function' => string 'run' (length=3)
      'class' => string 'CodeIgniter\CodeIgniter' (length=23)
      'object' => 
        object(CodeIgniter\CodeIgniter)[10]
          protected 'startTime' => float 1641349430.1461
          protected 'totalTime' => float 0.087
          protected 'config' => 
            object(Config\App)[9]
              ...
          protected 'benchmark' => 
            object(CodeIgniter\Debug\Timer)[36]
              ...
          protected 'request' => 
            object(CodeIgniter\HTTP\IncomingRequest)[12]
              ...
          protected 'response' => 
            object(CodeIgniter\HTTP\Response)[28]
              ...
          protected 'router' => 
            object(CodeIgniter\Router\Router)[60]
              ...
          protected 'controller' => string '\App\Controllers\Home' (length=21)
          protected 'method' => string 'index' (length=5)
          protected 'output' => string '<!-- DEBUG-VIEW START 1 APPPATH/Views/welcome_message.php -->
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Welcome to CodeIgniter 4!</title>
	<meta name="description" content="The small framework with powerful features">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="shortcut icon" type="image/png" href="/favicon.ico"/>

	<!-- STYLES -->

	<style {csp-style-nonce}>
		* {
			transition: background-color 300ms ease, color 300ms ease;
		}
		*:focu'... (length=18369)
          protected 'path' => null
          protected 'useSafeOutput' => boolean false
      'type' => string '->' (length=2)
      'args' => 
        array (size=0)
          empty
  18 => 
    array (size=4)
      'file' => string '/Users/kenji/work/codeigniter/CodeIgniter4/system/Commands/Server/rewrite.php' (length=77)
      'line' => int 43
      'args' => 
        array (size=1)
          0 => string '/Users/kenji/work/codeigniter/CodeIgniter4/public/index.php' (length=59)
      'function' => string 'require_once' (length=12)

@kenjis
Copy link
Member

kenjis commented Jan 5, 2022

Only In this array, there is no file. Why?
Is it a bug of PHP?

  4 => 
    array (size=5)
      'function' => string 'read' (length=4)
      'class' => string 'CodeIgniter\Session\Handlers\DatabaseHandler' (length=44)
      'object' => 
        object(CodeIgniter\Session\Handlers\DatabaseHandler)[65]
          protected 'fingerprint' => string 'ec15ca5d5a3e707de835bf7a4f33b423' (length=32)
          protected 'lock' => string '2b892e0152f080d22f3cb0e6ae38debd' (length=32)
          protected 'cookiePrefix' => string '' (length=0)
          protected 'cookieDomain' => string '' (length=0)
          protected 'cookiePath' => string '/' (length=1)
          protected 'cookieSecure' => boolean false
          protected 'cookieName' => string 'ci_session' (length=10)
          protected 'matchIP' => boolean false
          protected 'sessionID' => string '07rfo706ksmjkuiiaedaj760k9mfh2q6' (length=32)
          protected 'savePath' => string 'ci_sessions' (length=11)
          protected 'ipAddress' => string '::1' (length=3)
          protected 'logger' => 
            object(CodeIgniter\Log\Logger)[48]
              ...
          protected 'DBGroup' => string 'default' (length=7)
          protected 'table' => string 'ci_sessions' (length=11)
          protected 'db' => 
            object(CodeIgniter\Database\MySQLi\Connection)[68]
              ...
          protected 'platform' => string 'mysql' (length=5)
          protected 'rowExists' => boolean true
      'type' => string '->' (length=2)
      'args' => 
        array (size=1)
          0 => string '07rfo706ksmjkuiiaedaj760k9mfh2q6' (length=32)

@iRedds
Copy link
Collaborator

iRedds commented Jan 5, 2022

Only In this array, there is no file. Why? Is it a bug of PHP?

I think this is a php bug related to an internal call.

set_exception_handler(function ($e) {
   var_dump(debug_backtrace());
});
throw new Exception('test');

//array(1) {
//    [0]=>
//        array(2) {
//            ["function"]=>
//            string(9) "{closure}"
//            ["args"]=>
//            array(1) {
//            }
//        }
//}

same behavior with session_set_save_handler

@kenjis
Copy link
Member

kenjis commented Jan 6, 2022

@iRedds Thank you for your insight.
Do you report it to https://bugs.php.net/ ?

I found https://bugs.php.net/bug.php?id=44428
and it is surely fixed on PHP 8.0 and 8.1.

@iRedds
Copy link
Collaborator

iRedds commented Jan 6, 2022

@kenjis No, I did not report. Checked online php 8.1.1, the behavior is the same.
I seem to have heard that the bug tracker has moved to the github issue.

Now I'm not sure if this is a bug.
The default php functions are not in scripts. They are either in binary or in modules. In this case, it is not clear which file or line the backtrace should point to.

For example, in Kint, if there is no file and line, then the backtrace is marked as php internal calls.

if ($frame->trace['file']) {
$framedesc .= $this->renderer->ideLink($frame->trace['file'], $frame->trace['line']).PHP_EOL;
} else {
$framedesc .= 'PHP internal call'.PHP_EOL;
}

if (!empty($o->trace['file']) && !empty($o->trace['line'])) {
$header = '<var>'.$this->renderer->ideLink($o->trace['file'], (int) $o->trace['line']).'</var> ';
} else {
$header = '<var>PHP internal call</var> ';
}

@kenjis
Copy link
Member

kenjis commented Jan 6, 2022

@iRedds

I seem to have heard that the bug tracker has moved to the github issue.

Thanks. you're correct.
https://wiki.php.net/rfc/github_issues
https://github.com/php/php-src/issues

@paulbalandan
Copy link
Member

Also, in our CLI exception renderer in app/Views/errors/cli/error_exception.php if file is not set then we mark it as internal function.

if (isset($error['file'])) {

@mkilinskidev
Copy link

@iRedds Thank you for your insight. Do you report it to https://bugs.php.net/ ?

I found https://bugs.php.net/bug.php?id=44428 and it is surely fixed on PHP 8.0 and 8.1.

I am using PHP 8.0.11 and I have the same issue...

@paulbalandan
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
9 participants