From 06bf0a40a67004a52c3dd1d9291a5df06f146c88 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 1 Nov 2011 00:10:25 -0500 Subject: [PATCH] refactoring the session payload. --- laravel/session/payload.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/laravel/session/payload.php b/laravel/session/payload.php index f9516a87..71f2c029 100644 --- a/laravel/session/payload.php +++ b/laravel/session/payload.php @@ -236,20 +236,11 @@ protected function age() if (strpos($key, ':old:') === 0) $this->forget($key); } - $this->replace(':new:', ':old:', array_keys($this->session['data'])); - } - - /** - * Re-address the session data by performing a string replacement on the keys. - * - * @param string $search - * @param string $replace - * @param array $keys - * @return void - */ - protected function replace($search, $replace, $keys) - { - $keys = str_replace($search, $replace, $keys); + // Now that all of the "old" keys have been removed from the session data, + // we can re-address all of the newly flashed keys to have old addresses. + // The array_combine method uses the first array for keys, and the second + // array for values to construct a single array from both. + $keys = str_replace(':new', ':old:', array_keys($this->session['data'])); $this->session['data'] = array_combine($keys, array_values($this->session['data'])); }