Skip to content

Commit b551206

Browse files
authored
Merge pull request barryvdh#583 from martindilling/martindilling/update-for-5.4
Update for 5.4
2 parents 65b0465 + e946255 commit b551206

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/DataCollector/SessionCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
class SessionCollector extends DataCollector implements DataCollectorInterface, Renderable
1010
{
11-
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $session */
11+
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface|\Illuminate\Contracts\Session\Session $session */
1212
protected $session;
1313

1414
/**
1515
* Create a new SessionCollector
1616
*
17-
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
17+
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface|\Illuminate\Contracts\Session\Session $session
1818
*/
1919
public function __construct($session)
2020
{

src/LaravelDebugbar.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,16 @@ function ($view) use ($debugbar) {
231231
$logger = new MessagesCollector('log');
232232
$this['messages']->aggregate($logger);
233233
$this->app['log']->listen(
234-
function ($level, $message, $context) use ($logger) {
234+
function ($level, $message = null, $context = null) use ($logger) {
235+
// Laravel 5.4 changed how the global log listeners are called. We must account for
236+
// the first argument being an "event object", where arguments are passed
237+
// via object properties, instead of individual arguments.
238+
if ($level instanceof \Illuminate\Log\Events\MessageLogged) {
239+
$message = $level->message;
240+
$context = $level->context;
241+
$level = $level->level;
242+
}
243+
235244
try {
236245
$logMessage = (string) $message;
237246
if (mb_check_encoding($logMessage, 'UTF-8')) {

src/SymfonyHttpDriver.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
class SymfonyHttpDriver implements HttpDriverInterface
1313
{
14-
/** @var \Symfony\Component\HttpFoundation\Session\Session */
14+
/** @var \Symfony\Component\HttpFoundation\Session\Session|\Illuminate\Contracts\Session\Session */
1515
protected $session;
1616
/** @var \Symfony\Component\HttpFoundation\Response */
1717
protected $response;
@@ -48,6 +48,13 @@ public function isSessionStarted()
4848
*/
4949
public function setSessionValue($name, $value)
5050
{
51+
// In Laravel 5.4 the session changed to use their own custom implementation
52+
// instead of the one from Symfony. One of the changes was the set method
53+
// that was changed to put. Here we check if we are using the new one.
54+
if ($this->session instanceof \Illuminate\Contracts\Session\Session) {
55+
$this->session->put($name, $value);
56+
return;
57+
}
5158
$this->session->set($name, $value);
5259
}
5360

0 commit comments

Comments
 (0)