8000 [9.x] Added argument transformNullToEmptyString to the functions old() and … by Loots-it · Pull Request #35853 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[9.x] Added argument transformNullToEmptyString to the functions old() and … #35853

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

Merged
merged 2 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Removed argument transformNullToEmptyString from the functions old() …
…and getOldInput()
  • Loading branch information
Loots-it committed Jan 12, 2021
commit 5a3b7d9af0ed7b1f145b05d2b7cbbac8ef808e8e
5 changes: 2 additions & 3 deletions src/Illuminate/Foundation/helpers.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,11 @@ function now($tz = null)
*
* @param string|null $key
* @param mixed $default
* @param bool $transformNullToEmptyString
* @return mixed
*/
function old($key = null, $default = null, $transformNullToEmptyString = false)
function old($key = null, $default = null)
{
return app('request')->old($key, $default, $transformNullToEmptyString);
return app('request')->old($key, $default);
}
}

Expand Down
11 changes: 2 additions & 9 deletions src/Illuminate/Session/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,11 @@ public function hasOldInput($key = null)
*
* @param string|null $key
* @param mixed $default
* @param bool $transformNullToEmptyString
* @return mixed
*/
public function getOldInput($key = null, $default = null, $transformNullToEmptyString = false)
public function getOldInput($key = null, $default = null)
{
$oldInputs = $this->get('_old_input', []);
$result = Arr::get($oldInputs, $key, $default);

if ($transformNullToEmptyString && is_null($result) && Arr::has($oldInputs, $key)) {
return '';
}
return $result;
return Arr::get($this->get('_old_input', []), $key, $default);
}

/**
Expand Down
2 changes: 0 additions & 2 deletions tests/Session/SessionStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ public function testOldInputFlashing()
$this->assertFalse($session->hasOldInput('boom'));

$this->assertSame('default', $session->getOldInput('input', 'default'));
$this->assertSame('default', $session->getOldInput('input', 'default', true));
$this->assertSame('', $session->getOldInput('name', 'default', true));
$this->assertSame(null, $session->getOldInput('name', 'default'));
}

Expand Down
0