Skip to content

Commit

Permalink
Revert and fix session manager (#1666)
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh authored Sep 11, 2024
1 parent 1542461 commit 48266da
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 130 deletions.
18 changes: 10 additions & 8 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,12 @@ public function __construct($app = null)
public function getHttpDriver()
{
if ($this->httpDriver === null) {
if ($this->app->bound('cookie')) {
$this->httpDriver = $this->app->make(SessionHttpDriver::class);
} else {
$this->httpDriver = $this->app->make(SymfonyHttpDriver::class);
}
$this->httpDriver = $this->app->make(SymfonyHttpDriver::class);
}

return $this->httpDriver;
}

/**
* Enable the Debugbar and boot, if not already booted.
*/
Expand Down Expand Up @@ -740,6 +736,12 @@ public function modifyResponse(Request $request, Response $response)
// Prevent duplicate modification
$this->responseIsModified = true;

// Set the Response if required
$httpDriver = $this->getHttpDriver();
if ($httpDriver instanceof SymfonyHttpDriver) {
$httpDriver->setResponse($response);
}

// Show the Http Response Exception in the Debugbar, when available
if (isset($response->exception)) {
$this->addThrowable($response->exception);
Expand All @@ -757,11 +759,11 @@ public function modifyResponse(Request $request, Response $response)

$sessionHiddens = $app['config']->get('debugbar.options.session.hiddens', []);
if ($app->bound(SessionManager::class)) {
/** @var \Illuminate\Session\SessionManager $sessionManager */
$sessionManager = $app->make(SessionManager::class);

if ($this->shouldCollect('session') && ! $this->hasCollector('session')) {
try {
/** @var \Illuminate\Session\SessionManager $sessionManager */
$sessionManager = $app->make(SessionManager::class);
$this->addCollector(new SessionCollector($sessionManager, $sessionHiddens));
} catch (Exception $e) {
$this->addCollectorException('Cannot add SessionCollector', $e);
Expand Down
14 changes: 0 additions & 14 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ public function register()
return new LaravelDebugbar($app);
});

$this->app->singleton(SessionHttpDriver::class, function ($app) {
// Attach the Cookie Handler with Request
$cookieHandler = new CookieSessionHandler($app->make('cookie'), 0, true);
$cookieHandler->setRequest($app['request']);

return new SessionHttpDriver($cookieHandler);
});

$this->app->singleton(SymfonyHttpDriver::class, function ($app) {
return new SymfonyHttpDriver($app->make(SessionManager::class));
});
Expand Down Expand Up @@ -176,12 +168,6 @@ protected function registerResponseListener()
/** @var LaravelDebugbar $debugbar */
$debugbar = $this->app->make(LaravelDebugbar::class);
if ($debugbar->isEnabled()) {
// Now that we have a Response, set it on the Driver
$httpDriver = $debugbar->getHttpDriver();
if ($httpDriver instanceof SessionHttpDriver || $httpDriver instanceof SymfonyHttpDriver) {
$httpDriver->setResponse($event->response);
}

if ($event->response->isRedirection()) {
$debugbar->modifyResponse($event->request, $event->response);
} else {
Expand Down
107 changes: 0 additions & 107 deletions src/SessionHttpDriver.php

This file was deleted.

1 change: 0 additions & 1 deletion src/SymfonyHttpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/**
* HTTP driver for Symfony Request/Session
*
* @deprecated
*/
class SymfonyHttpDriver implements HttpDriverInterface
{
Expand Down

0 comments on commit 48266da

Please sign in to comment.