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

[5.5] Fix Problem with using old() in templates #22082

Merged
merged 1 commit into from
Nov 15, 2017

Conversation

ameenross
Copy link
Contributor

@ameenross ameenross commented Nov 15, 2017

  • Laravel Version: 5.5.*
  • PHP Version: 7.1.7
  • Database Driver & Version: N/A

Description:

According to the docs, it's possible to use the old() method in Blade templates. However, when rendering views manually (via tinker, for example), it breaks. You have to jump through hoops to get it working again. The reason is this line of code:

// @see https://github.com/laravel/framework/blob/5.5/src/Illuminate/Http/Concerns/InteractsWithFlashData.php#L16
return $this->session()->getOldInput($key, $default);

The functionality has a hard requirement on a session being available in the request. This is obviously not the case when using tinker. This PR fixes that by checking whether the session exists.

@taylorotwell taylorotwell merged commit a7cbe21 into laravel:5.5 Nov 15, 2017
@ameenross ameenross deleted the patch-2 branch November 15, 2017 14:34
@GrahamCampbell GrahamCampbell changed the title Fix Problem with using old() in templates [5.5] Fix Problem with using old() in templates Nov 18, 2017
@andrewicarlson
Copy link

This is just what I needed. I was getting exceptions on all HTTP error pages (404, 500, etc) due to session not being set. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants