diff options
-rw-r--r-- | lib/private/Session/CryptoSessionData.php | 10 | ||||
-rw-r--r-- | lib/private/Session/Internal.php | 10 | ||||
-rw-r--r-- | lib/private/Session/Memory.php | 10 | ||||
-rw-r--r-- | lib/public/isession.php | 8 | ||||
-rw-r--r-- | tests/lib/session/memory.php | 9 |
5 files changed, 47 insertions, 0 deletions
diff --git a/lib/private/Session/CryptoSessionData.php b/lib/private/Session/CryptoSessionData.php index f6c585c1611..23731ef4560 100644 --- a/lib/private/Session/CryptoSessionData.php +++ b/lib/private/Session/CryptoSessionData.php @@ -142,6 +142,16 @@ class CryptoSessionData implements \ArrayAccess, ISession { } /** + * 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 */ public function close() { diff --git a/lib/private/Session/Internal.php b/lib/private/Session/Internal.php index 09175bf1f2f..4fadb1ac801 100644 --- a/lib/private/Session/Internal.php +++ b/lib/private/Session/Internal.php @@ -112,6 +112,16 @@ class Internal extends Session { } /** + * Wrapper around session_id + * + * @return string + * @since 9.1.0 + */ + public function getId() { + return @session_id(); + } + + /** * @throws \Exception */ public function reopen() { diff --git a/lib/private/Session/Memory.php b/lib/private/Session/Memory.php index 777458a9aa5..3dba274f395 100644 --- a/lib/private/Session/Memory.php +++ b/lib/private/Session/Memory.php @@ -89,6 +89,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 */ public function reopen() { diff --git a/lib/public/isession.php b/lib/public/isession.php index 25c76906d63..16c6f9bc6a5 100644 --- a/lib/public/isession.php +++ b/lib/public/isession.php @@ -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(); } diff --git a/tests/lib/session/memory.php b/tests/lib/session/memory.php index 1ca4956c6ea..750fcf2ec6f 100644 --- a/tests/lib/session/memory.php +++ b/tests/lib/session/memory.php @@ -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(); + } + } |