Skip to content

Commit

Permalink
Removing CakeSession::watch() and CakeSession::ignore(). You should u…
Browse files Browse the repository at this point in the history
…se logging, or an interactive debugger instead.
  • Loading branch information
markstory committed Dec 15, 2010
1 parent 75af48b commit 84414ee
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 95 deletions.
53 changes: 0 additions & 53 deletions cake/libs/cake_session.php
Expand Up @@ -100,13 +100,6 @@ class CakeSession {
*/
public static $sessionTime = false;

/**
* Keeps track of keys to watch for writes on
*
* @var array
*/
public static $watchKeys = array();

/**
* Current Session id
*
Expand Down Expand Up @@ -261,9 +254,6 @@ public static function id($id = null) {
*/
public static function delete($name) {
if (self::check($name)) {
if (in_array($name, self::$watchKeys)) {
throw new CakeSessionException(__('Deleting session key {%s}', $name));
}
self::__overwrite($_SESSION, Set::remove($_SESSION, $name));
return (self::check($name) == false);
}
Expand Down Expand Up @@ -402,46 +392,6 @@ private static function __returnSessionVars() {
return false;
}

/**
* Tells Session to write a notification when a certain session path or subpath is written to
*
* @param mixed $var The variable path to watch
* @return void
*/
public static function watch($var) {
if (!self::started() && !self::start()) {
return false;
}
if (empty($var)) {
return false;
}
if (!in_array($var, self::$watchKeys, true)) {
self::$watchKeys[] = $var;
}
}

/**
* Tells Session to stop watching a given key path
*
* @param mixed $var The variable path to watch
* @return void
*/
public static function ignore($var) {
if (!self::started() && !self::start()) {
return false;
}
if (!in_array($var, self::$watchKeys)) {
return;
}
foreach (self::$watchKeys as $i => $key) {
if ($key == $var) {
unset(self::$watchKeys[$i]);
self::$watchKeys = array_values(self::$watchKeys);
return;
}
}
}

/**
* Writes value to given session variable name.
*
Expand All @@ -461,9 +411,6 @@ public static function write($name, $value = null) {
$write = array($name => $value);
}
foreach ($write as $key => $val) {
if (in_array($key, self::$watchKeys)) {
throw new CakeSessionException(__('Writing session key {%s}: %s', $key, var_export($val, true)));
}
self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val));
if (Set::classicExtract($_SESSION, $key) !== $val) {
return false;
Expand Down
42 changes: 0 additions & 42 deletions cake/tests/cases/libs/cake_session.test.php
Expand Up @@ -88,7 +88,6 @@ function setup() {
'ini' => array(),
));
TestCakeSession::init();
TestCakeSession::$watchKeys = array();
}

/**
Expand Down Expand Up @@ -365,47 +364,6 @@ function testDelete() {
$this->assertFalse(TestCakeSession::check('Clearing'));
}

/**
* testWatchVar method
*
* @expectedException CakeSessionException
* @access public
* @return void
*/
function testWatchVarWrite() {
$this->assertFalse(TestCakeSession::watch(null));

TestCakeSession::write('Watching', "I'm watching you");
TestCakeSession::watch('Watching');
TestCakeSession::write('Watching', 'They found us!');
}

/**
* Test that deleting watched vars causes exceptions
*
* @expectedException CakeSessionException
* @return void
*/
function testWatchVarDelete() {
TestCakeSession::write('Watching', 'I am watching you.');

TestCakeSession::watch('Watching');
TestCakeSession::delete('Watching');
}

/**
* testIgnore method
*
* @access public
* @return void
*/
function testIgnore() {
TestCakeSession::write('Watching', "I'm watching you");
TestCakeSession::watch('Watching');
TestCakeSession::ignore('Watching');
$this->assertTrue(TestCakeSession::write('Watching', 'They found us!'));
}

/**
* testDestroy method
*
Expand Down

0 comments on commit 84414ee

Please sign in to comment.