Permalink
Browse files

Improved array keey_flashdata + Changelog

  • Loading branch information...
johnathancroom committed Nov 25, 2012
1 parent 9d9849b commit 8d8543da992985ae61a6903a138d949f189721e9
Showing with 16 additions and 13 deletions.
  1. +15 −13 system/libraries/Session/Session.php
  2. +1 −0 user_guide_src/source/changelog.rst
@@ -392,24 +392,26 @@ public function set_flashdata($newdata = array(), $newval = '')
* @param mixed Item key(s)
* @return void
*/
- public function keep_flashdata($data)
+ public function keep_flashdata($key)
{
- // Wrap item as array if singular
- if (!is_array($data))
- {
- $data = array($data);
- }
- foreach ($data as $key)
+ if (is_array($key))
{
- // 'old' flashdata gets removed. Here we mark all flashdata as 'new' to preserve it from _flashdata_sweep()
- // Note the function will return NULL if the $key provided cannot be found
- $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key;
- $value = $this->userdata($old_flashdata_key);
+ foreach ($key as $k)
+ {
+ $this->keep_flashdata($k);
+ }
- $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
- $this->set_userdata($new_flashdata_key, $value);
+ return;
}
+
+ // 'old' flashdata gets removed. Here we mark all flashdata as 'new' to preserve it from _flashdata_sweep()
+ // Note the function will return NULL if the $key provided cannot be found
+ $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key;
+ $value = $this->userdata($old_flashdata_key);
+
+ $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
+ $this->set_userdata($new_flashdata_key, $value);
}
// ------------------------------------------------------------------------
@@ -198,6 +198,7 @@ Release Date: Not Released
- Added ``all_flashdata()`` method to session class. Returns an associative array of only flashdata.
- Added ``has_userdata()`` method to verify existence of userdata item.
- Added ``tempdata()``, ``set_tempdata()``, and ``unset_tempdata()`` methods for manipulating tempdata.
+ - ``keep_flashdata()`` now accepts an array of values.
- :doc:`File Uploading Library <libraries/file_uploading>` changes include:
- Added *max_filename_increment* config setting.
- Added an "index" parameter to the ``data()`` method.

0 comments on commit 8d8543d

Please sign in to comment.