Debugbar: 3.2.8
Laravel: 5.7 and 5.8 and 6
Debugbar is causing cookie/session problems when being injected via InjectDebugbar() on error pages.
ErrorException/public/index.php in ?
Notice: Trying to get property 'cookies' of non-object
This occurs whenever a 404 error/page is returned. the 404 page is displayed, the debugbar is missing from it and our error tracking system reports this error.
ErrorException: Notice: Trying to get property 'cookies' of non-object
#35 /vendor/laravel/framework/src/Illuminate/Session/CookieSessionHandler.php(69): Illuminate\Session\CookieSessionHandler::read
#34 /vendor/laravel/framework/src/Illuminate/Session/Store.php(97): Illuminate\Session\Store::readFromHandler
#33 /vendor/laravel/framework/src/Illuminate/Session/Store.php(87): Illuminate\Session\Store::loadSession
#32 /vendor/laravel/framework/src/Illuminate/Session/Store.php(71): Illuminate\Session\Store::start
#31 /vendor/laravel/framework/src/Illuminate/Support/Manager.php(146): Illuminate\Support\Manager::__call
#30 /vendor/barryvdh/laravel-debugbar/src/SymfonyHttpDriver.php(42): Barryvdh\Debugbar\SymfonyHttpDriver::isSessionStarted
#29 /vendor/maximebf/debugbar/src/DebugBar/DebugBar.php(446): DebugBar\DebugBar::initStackSession
#28 /vendor/maximebf/debugbar/src/DebugBar/DebugBar.php(359): DebugBar\DebugBar::hasStackedData
#27 /vendor/maximebf/debugbar/src/DebugBar/JavascriptRenderer.php(984): DebugBar\JavascriptRenderer::render
#26 /vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php(862): Barryvdh\Debugbar\LaravelDebugbar::injectDebugbar
#25 /vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php(747): Barryvdh\Debugbar\LaravelDebugbar::modifyResponse
#24 /vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(74): Barryvdh\Debugbar\Middleware\InjectDebugbar::handle
#23 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#22 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
#21 /vendor/fideloper/proxy/src/TrustProxies.php(57): Fideloper\Proxy\TrustProxies::handle
#20 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#19 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
#18 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Foundation\Http\Middleware\TransformsRequest::handle
#17 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#16 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
#15 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Foundation\Http\Middleware\TransformsRequest::handle
#14 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#13 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
#12 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Foundation\Http\Middleware\ValidatePostSize::handle
#11 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#10 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
#9 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::handle
#8 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#7 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
#6 /vendor/barryvdh/laravel-cors/src/HandlePreflight.php(29): Barryvdh\Cors\HandlePreflight::handle
#5 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#4 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
#3 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline::then
#2 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel::handle
#0 /public/index.php(53): null
Debugbar exception: Trying to get property 'cookies' of non-object
Same Error:
Debugbar exception: Trying to get property 'cookies' of non-object
So? Who will can fix that?
+1
+1
+1
+1
+1
+1
Barry? Do you have the time to fix this? It is cluttering the logs ;-)
+1
+1
So on routes without session?
So on routes without session?
Yes
So what is your session driver, cookies? Any other non-default settings?
In development have it as file
Having same issue. Subscribing....
I have the same too...
+1
Can you share at least some configuration? Devs cannot find when this is happening.
So what is your session driver, cookies? Any other non-default settings?
@barryvdh When I use the cookie session driver, the error occurs.
SESSION_DRIVER=cookie
When I use the file session driver, the problem is solved.
SESSION_DRIVER=file
Configuration file
<?php
return [
'enabled' => env('DEBUGBAR_ENABLED', null),
'except' => [
'telescope*',
],
'storage' => [
'enabled' => true,
'driver' => 'file', // redis, file, pdo, custom
'path' => storage_path('debugbar'), // For file driver
'connection' => null, // Leave null for default connection (Redis/PDO)
'provider' => '', // Instance of StorageInterface for custom driver
],
'include_vendors' => false,
'capture_ajax' => true,
'add_ajax_timing' => false,
'error_handler' => false,
'clockwork' => false,
'collectors' => [
'phpinfo' => true, // Php version
'messages' => true, // Messages
'time' => true, // Time Datalogger
'memory' => true, // Memory usage
'exceptions' => true, // Exception displayer
'log' => true, // Logs from Monolog (merged in messages if enabled)
'db' => true, // Show database (PDO) queries and bindings
'views' => false, // Views with their data
'route' => true, // Current route information
'auth' => true, // Display Laravel authentication status
'gate' => true, // Display Laravel Gate checks
'session' => true, // Display session data
'symfony_request' => true, // Only one can be enabled..
'mail' => true, // Catch mail messages
'laravel' => false, // Laravel version and environment
'events' => false, // All events fired
'default_request' => false, // Regular or special Symfony request logger
'logs' => false, // Add the latest log messages
'files' => false, // Show the included files
'config' => false, // Display config settings
'cache' => false, // Display cache events
'models' => true, // Display models
],
'options' => [
'auth' => [
'show_name' => true, // Also show the users name/email in the debugbar
],
'db' => [
'with_params' => true, // Render SQL with the parameters substituted
'backtrace' => true, // Use a backtrace to find the origin of the query in your files.
'timeline' => true, // Add the queries to the timeline
'explain' => [ // Show EXPLAIN output on queries
'enabled' => false,
'types' => ['SELECT'], // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
],
'hints' => true, // Show hints for common mistakes
],
'mail' => [
'full_log' => false,
],
'views' => [
'data' => false, //Note: Can slow down the application, because the data can be quite large..
],
'route' => [
'label' => true, // show complete route on bar
],
'logs' => [
'file' => null,
],
'cache' => [
'values' => true, // collect cache values
],
],
'inject' => true,
'route_prefix' => '_debugbar',
'route_domain' => null,
];
I have encountered the same issue while using Laravel Vapor.
I have set SESSION_DRIVER=redis in my .env file. I thought it solved the issue but got another error :
NOTICE: PHP message: [2020-07-14 19:28:07] dev.ERROR: Undefined offset: 0 {"exception":"[object] (ErrorException(code: 0): Undefined offset: 0 at /var/task/vendor/maximebf/debugbar/src/DebugBar/Storage/RedisStorage.php:59)
EDIT :
I suppose SESSION_DRIVER=file cannot be used with Laravel Vapor.
I also realize this issue may be caused by large cookies and their size limit (in our case).
I am trying to understand why the redis session driver is not working properly on our side.
Same with the laravel/sanctum and SESSION_DRIVER=cookie. It happens on standart laravel login if you check "Remember me" after you already logged with different guard using laravel/sanctum.
+1
+1
I have encountered the same issue while using Laravel Vapor.
I have setSESSION_DRIVER=redisin my.envfile. I thought it solved the issue but got another error :NOTICE: PHP message: [2020-07-14 19:28:07] dev.ERROR: Undefined offset: 0 {"exception":"[object] (ErrorException(code: 0): Undefined offset: 0 at /var/task/vendor/maximebf/debugbar/src/DebugBar/Storage/RedisStorage.php:59)EDIT :
I supposeSESSION_DRIVER=filecannot be used with Laravel Vapor.
I also realize this issue may be caused by large cookies and their size limit (in our case).I am trying to understand why the redis session driver is not working properly on our side.
I've same issue.
After research, there is an error in maximebf/php-debugbar package.
If I edit /vendor/maximebf/debugbar/src/DebugBar/Storage/RedisStorage.php on line 59:
# list($cursor, $data) = $this->redis->hscan("$this->hash:meta", $cursor);
$data = $this->redis->hscan("$this->hash:meta", $cursor);
It fix the error ;)
Might be that it's not compatible with the latest Redis version. Not really tried using Vapor, as Debugbar is meant as a local debug tool.
I don't use Vapor, I use last 5 version of Redis, actually 5.0.10, and not the 6 release.
We use debugbar in local and staging: we can enable debugbar in case of problem with header, that's cool for debugging last minute unexpected bugs...
We can't use file storage as we work in Cloud: request can be send to other node that don't have needed files...
PS: I didn't see require version of Redis or Redis driver in composer.json in maximebf/php-debugbar or in these package :(
Redis is not required by default.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.
Same here
Most helpful comment
So? Who will can fix that?