Skip to content

Commit

Permalink
Merge pull request barryvdh#583 from martindilling/martindilling/upda…
Browse files Browse the repository at this point in the history
…te-for-5.4

Update for 5.4
  • Loading branch information
barryvdh authored Jan 6, 2017
2 parents 65b0465 + e946255 commit b551206
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/DataCollector/SessionCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

class SessionCollector extends DataCollector implements DataCollectorInterface, Renderable
{
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $session */
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface|\Illuminate\Contracts\Session\Session $session */
protected $session;

/**
* Create a new SessionCollector
*
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface|\Illuminate\Contracts\Session\Session $session
*/
public function __construct($session)
{
Expand Down
11 changes: 10 additions & 1 deletion src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,16 @@ function ($view) use ($debugbar) {
$logger = new MessagesCollector('log');
$this['messages']->aggregate($logger);
$this->app['log']->listen(
function ($level, $message, $context) use ($logger) {
function ($level, $message = null, $context = null) use ($logger) {
// Laravel 5.4 changed how the global log listeners are called. We must account for
// the first argument being an "event object", where arguments are passed
// via object properties, instead of individual arguments.
if ($level instanceof \Illuminate\Log\Events\MessageLogged) {
$message = $level->message;
$context = $level->context;
$level = $level->level;
}

try {
$logMessage = (string) $message;
if (mb_check_encoding($logMessage, 'UTF-8')) {
Expand Down
9 changes: 8 additions & 1 deletion src/SymfonyHttpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class SymfonyHttpDriver implements HttpDriverInterface
{
/** @var \Symfony\Component\HttpFoundation\Session\Session */
/** @var \Symfony\Component\HttpFoundation\Session\Session|\Illuminate\Contracts\Session\Session */
protected $session;
/** @var \Symfony\Component\HttpFoundation\Response */
protected $response;
Expand Down Expand Up @@ -48,6 +48,13 @@ public function isSessionStarted()
*/
public function setSessionValue($name, $value)
{
// In Laravel 5.4 the session changed to use their own custom implementation
// instead of the one from Symfony. One of the changes was the set method
// that was changed to put. Here we check if we are using the new one.
if ($this->session instanceof \Illuminate\Contracts\Session\Session) {
$this->session->put($name, $value);
return;
}
$this->session->set($name, $value);
}

Expand Down

0 comments on commit b551206

Please sign in to comment.