diff --git a/core/Session.php b/core/Session.php index b3c49c947..683fb4f9e 100644 --- a/core/Session.php +++ b/core/Session.php @@ -66,7 +66,19 @@ class Session { } } + /** + * @deprecated 2.5 Use Session::add_to_array($name, $val) instead + */ public static function addToArray($name, $val) { + user_error('Session::addToArray() is deprecated. Please use Session::add_to_array() instead.', E_USER_NOTICE); + + return Session::add_to_array($name, $val); + } + + /** + * Add a value to a specific key in the session array + */ + public static function add_to_array($name, $val) { return Controller::curr()->getSession()->inst_addToArray($name, $val); } @@ -91,9 +103,20 @@ class Session { /** * Return all the values in session + * + * @return Array + */ + public static function get_all() { + return Controller::curr()->getSession()->inst_getAll(); + } + + /** + * @deprecated 2.5 Use Session::get_all() */ public static function getAll() { - return Controller::curr()->getSession()->inst_getAll(); + user_error('Session::getAll() is deprecated. Please use Session::get_all() instead.', E_USER_NOTICE); + + return Session::get_all(); } /** @@ -108,10 +131,19 @@ class Session { /** * Clear all the values */ - public static function clearAll() { + public static function clear_all() { return Controller::curr()->getSession()->inst_clearAll(); } + /** + * @deprecated 2.5 Use Session::clear_all() + */ + public static function clearAll() { + user_error('Session::clearAll() is deprecated. Please use Session::clear_all() instead.', E_USER_NOTICE); + + return Session::clear_all(); + } + /** * Save all the values in our session to $_SESSION */ diff --git a/forms/Form.php b/forms/Form.php index 75c54e70f..74559863a 100755 --- a/forms/Form.php +++ b/forms/Form.php @@ -358,7 +358,7 @@ class Form extends RequestHandler { * and used the next time this form is displayed. */ function addErrorMessage($fieldName, $message, $messageType) { - Session::addToArray("FormInfo.{$this->FormName()}.errors", array( + Session::add_to_array("FormInfo.{$this->FormName()}.errors", array( 'fieldName' => $fieldName, 'message' => $message, 'messageType' => $messageType, diff --git a/tests/SessionTest.php b/tests/SessionTest.php index fd85fb007..0d9de4781 100644 --- a/tests/SessionTest.php +++ b/tests/SessionTest.php @@ -26,7 +26,7 @@ class SessionTest extends SapphireTest { Session::set('Test', 'Test'); Session::set('Test-1', 'Test-1'); - Session::clearAll(); + Session::clear_all(); // should session get return null? The array key should probably be // unset from the data array @@ -38,7 +38,7 @@ class SessionTest extends SapphireTest { Session::set('Test', 'Test'); Session::set('Test-2', 'Test-2'); - $session = Session::getAll(); + $session = Session::get_all(); $this->assertEquals($session, array('Test' => 'Test', 'Test-2' => 'Test-2')); }