add ISession::getId() wrapper for session_id

This commit is contained in:
Christoph Wurst 2016-04-25 10:23:06 +02:00
parent 74de72e75e
commit 0d53e86421
No known key found for this signature in database
GPG Key ID: FEECD2543CA6EAF0
5 changed files with 47 additions and 0 deletions

View File

@ -141,6 +141,16 @@ class CryptoSessionData implements \ArrayAccess, ISession {
$this->session->regenerateId($deleteOldSession);
}
/**
* Wrapper around session_id
*
* @return string
* @since 9.1.0
*/
public function getId() {
return $this->session->getId();
}
/**
* Close the session and release the lock, also writes all changed data in batch
*/

View File

@ -111,6 +111,16 @@ class Internal extends Session {
@session_regenerate_id($deleteOldSession);
}
/**
* Wrapper around session_id
*
* @return string
* @since 9.1.0
*/
public function getId() {
return @session_id();
}
/**
* @throws \Exception
*/

View File

@ -88,6 +88,16 @@ class Memory extends Session {
*/
public function regenerateId($deleteOldSession = true) {}
/**
* Wrapper around session_id
*
* @return string
* @since 9.1.0
*/
public function getId() {
throw new \Exception('Memory session does not have an ID');
}
/**
* Helper function for PHPUnit execution - don't use in non-test code
*/

View File

@ -95,4 +95,12 @@ interface ISession {
* @since 9.0.0
*/
public function regenerateId($deleteOldSession = true);
/**
* Wrapper around session_id
*
* @return string
* @since 9.1.0
*/
public function getId();
}

View File

@ -10,8 +10,17 @@
namespace Test\Session;
class Memory extends Session {
protected function setUp() {
parent::setUp();
$this->instance = new \OC\Session\Memory($this->getUniqueID());
}
/**
* @expectedException \Exception
*/
public function testThrowsExceptionOnGetId() {
$this->instance->getId();
}
}