Skip to content

Commit

Permalink
BackwardsCompatibilityBreak - the first parameter of fSession::clear(…
Browse files Browse the repository at this point in the history
…) was removed, fSession::delete() should now be used instead
  • Loading branch information
wbond committed Apr 12, 2012
1 parent d6d9c90 commit a158d01
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
13 changes: 7 additions & 6 deletions classes/fAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @package Flourish
* @link http://flourishlib.com/fAuthorization
*
* @version 1.0.0b2
* @version 1.0.0b3
* @changes 1.0.0b3 Updated class to use new fSession API [wb, 2009-05-08]
* @changes 1.0.0b2 Fixed a bug with using named IP ranges in ::checkIP() [wb, 2009-01-10]
* @changes 1.0.0b The initial implementation [wb, 2007-06-14]
*/
Expand Down Expand Up @@ -233,10 +234,10 @@ static public function checkLoggedIn()
*/
static public function destroyUserInfo()
{
fSession::clear('user_auth_level', __CLASS__ . '::');
fSession::clear('user_acls', __CLASS__ . '::');
fSession::clear('user_token', __CLASS__ . '::');
fSession::clear('requested_url', __CLASS__ . '::');
fSession::delete('user_auth_level', __CLASS__ . '::');
fSession::delete('user_acls', __CLASS__ . '::');
fSession::delete('user_token', __CLASS__ . '::');
fSession::delete('requested_url', __CLASS__ . '::');
}


Expand All @@ -251,7 +252,7 @@ static public function getRequestedURL($clear, $default_url=NULL)
{
$requested_url = fSession::get('requested_url', $default_url, __CLASS__ . '::');
if ($clear) {
fSession::clear('requested_url', __CLASS__ . '::');
fSession::delete('requested_url', __CLASS__ . '::');
}
return $requested_url;
}
Expand Down
5 changes: 3 additions & 2 deletions classes/fCRUD.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @package Flourish
* @link http://flourishlib.com/fCRUD
*
* @version 1.0.0b3
* @version 1.0.0b4
* @changes 1.0.0b4 Updated class to use new fSession API [wb, 2009-05-08]
* @changes 1.0.0b3 Backwards Compatiblity Break - moved ::printOption() to fHTML::printOption(), ::showChecked() to fHTML::showChecked(), ::removeListItems() and ::reorderListItems() to fException::splitMessage(), ::generateRequestToken() to fRequest::generateCSRFToken(), and ::validateRequestToken() to fRequest::validateCSRFToken() [wb, 2009-05-08]
* @changes 1.0.0b2 Fixed a bug preventing loaded search values from being included in redirects [wb, 2009-03-18]
* @changes 1.0.0b The initial implementation [wb, 2007-06-14]
Expand Down Expand Up @@ -311,7 +312,7 @@ static public function redirectWithLoadedValues()
*/
static public function reset()
{
fSession::clear(NULL, __CLASS__ . '::');
fSession::clear(__CLASS__ . '::');

self::$loaded_values = array();
self::$row_number = 1;
Expand Down
7 changes: 4 additions & 3 deletions classes/fMessaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @package Flourish
* @link http://flourishlib.com/fMessaging
*
* @version 1.0.0b2
* @version 1.0.0b3
* @changes 1.0.0b3 Updated class to use new fSession API [wb, 2009-05-08]
* @changes 1.0.0b2 Changed ::show() to accept more than one message name, or * for all messages [wb, 2009-01-12]
* @changes 1.0.0b The initial implementation [wb, 2008-03-05]
*/
Expand Down Expand Up @@ -59,7 +60,7 @@ static public function create($name, $recipient, $message)
*/
static public function reset()
{
fSession::clear(NULL, __CLASS__ . '::');
fSession::clear(__CLASS__ . '::');
}


Expand All @@ -74,7 +75,7 @@ static public function retrieve($name, $recipient)
{
$prefix = __CLASS__ . '::' . $recipient . '::';
$message = fSession::get($name, NULL, $prefix);
fSession::clear($name, $prefix);
fSession::delete($name, $prefix);
return $message;
}

Expand Down
5 changes: 3 additions & 2 deletions classes/fRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* @package Flourish
* @link http://flourishlib.com/fRequest
*
* @version 1.0.0b2
* @version 1.0.0b3
* @changes 1.0.0b3 Updated class to use new fSession API [wb, 2009-05-08]
* @changes 1.0.0b2 Added ::generateCSRFToken() from fCRUD::generateRequestToken() and ::validateCSRFToken() from fCRUD::validateRequestToken() [wb, 2009-05-08]
* @changes 1.0.0b The initial implementation [wb, 2007-06-14]
*/
Expand Down Expand Up @@ -492,7 +493,7 @@ static private function processAcceptHeader($header)
*/
static public function reset()
{
fSession::clear(NULL, __CLASS__ . '::');
fSession::clear(__CLASS__ . '::');

self::$backup_files = NULL;
self::$backup_get = NULL;
Expand Down
37 changes: 22 additions & 15 deletions classes/fSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* @package Flourish
* @link http://flourishlib.com/fSession
*
* @version 1.0.0b5
* @version 1.0.0b6
* @changes 1.0.0b6 Backwards Compatibility Break - the first parameter of ::clear() was removed, use ::delete() instead [wb, 2009-05-08]
* @changes 1.0.0b5 Added documentation about session cache limiter warnings [wb, 2009-05-04]
* @changes 1.0.0b4 The class now works with existing sessions [wb, 2009-05-04]
* @changes 1.0.0b3 Fixed ::clear() to properly handle when `$key` is `NULL` [wb, 2009-02-05]
Expand All @@ -26,6 +27,7 @@ class fSession
// The following constants allow for nice looking callbacks to static methods
const clear = 'fSession::clear';
const close = 'fSession::close';
const delete = 'fSession::delete';
const destroy = 'fSession::destroy';
const get = 'fSession::get';
const ignoreSubdomain = 'fSession::ignoreSubdomain';
Expand All @@ -45,31 +47,21 @@ class fSession


/**
* Unsets a key from the `$_SESSION` superglobal using the prefix provided
* Removes all session values with the provided prefix
*
* @param string $key The key to unset, if no key is specified all keys with the prefix will be removed
* @param string $prefix The prefix to stick before the key
* @param string $prefix The prefix to clear all session values for
* @return void
*/
static public function clear($key=NULL, $prefix='fSession::')
static public function clear($prefix='fSession::')
{
self::open();

if ($key !== NULL) {
unset($_SESSION[$prefix . $key]);
return;
}

$remove = array();
foreach ($_SESSION as $key => $value) {
if (strpos($key, $prefix) === 0) {
$remove[] = $key;
unset($_SESSION[$key]);
}
}

foreach ($remove as $key) {
unset($_SESSION[$key]);
}
}


Expand All @@ -87,6 +79,21 @@ static public function close()
}


/**
* Deletes a value from the session
*
* @param string $key The key of the value to delete
* @param string $prefix The prefix to use for the key
* @return void
*/
static public function delete($key, $prefix='fSession::')
{
self::open();

unset($_SESSION[$prefix . $key]);
}


/**
* Destroys the session, removing all values
*
Expand Down

0 comments on commit a158d01

Please sign in to comment.