Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5ed40c0

Browse filesBrowse files
[HttpFoundation] fix registration of session proxies
1 parent af00528 commit 5ed40c0
Copy full SHA for 5ed40c0

File tree

3 files changed

+50
-3
lines changed
Filter options

3 files changed

+50
-3
lines changed

‎src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,6 @@ public function setSaveHandler($saveHandler = null)
411411
}
412412

413413
if ($this->saveHandler instanceof SessionHandlerProxy) {
414-
session_set_save_handler($this->saveHandler->getHandler(), false);
415-
} elseif ($this->saveHandler instanceof \SessionHandlerInterface) {
416414
session_set_save_handler($this->saveHandler, false);
417415
}
418416
}

‎src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* @author Drak <drak@zikula.org>
1616
*/
17-
class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface
17+
class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
1818
{
1919
protected $handler;
2020

@@ -82,4 +82,20 @@ public function gc($maxlifetime)
8282
{
8383
return (bool) $this->handler->gc($maxlifetime);
8484
}
85+
86+
/**
87+
* {@inheritdoc}
88+
*/
89+
public function validateId($sessionId)
90+
{
91+
return !$this->handler instanceof \SessionUpdateTimestampHandlerInterface || $this->handler->validateId($sessionId);
92+
}
93+
94+
/**
95+
* {@inheritdoc}
96+
*/
97+
public function updateTimestamp($sessionId, $data)
98+
{
99+
return $this->handler instanceof \SessionUpdateTimestampHandlerInterface ? $this->handler->updateTimestamp($sessionId, $data) : $this->write($sessionId, $data);
100+
}
85101
}

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,37 @@ public function testGc()
121121

122122
$this->proxy->gc(86400);
123123
}
124+
125+
/**
126+
* @requires PHPUnit 5.1
127+
*/
128+
public function testValidateId()
129+
{
130+
$mock = $this->getMockBuilder(array('SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'))->getMock();
131+
$mock->expects($this->once())
132+
->method('validateId');
133+
134+
$proxy = new SessionHandlerProxy($mock);
135+
$proxy->validateId('id');
136+
137+
$this->assertTrue($this->proxy->validateId('id'));
138+
}
139+
140+
/**
141+
* @requires PHPUnit 5.1
142+
*/
143+
public function testUpdateTimestamp()
144+
{
145+
$mock = $this->getMockBuilder(array('SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'))->getMock();
146+
$mock->expects($this->once())
147+
->method('updateTimestamp');
148+
149+
$proxy = new SessionHandlerProxy($mock);
150+
$proxy->updateTimestamp('id', 'data');
151+
152+
$this->mock->expects($this->once())
153+
->method('write');
154+
155+
$this->proxy->updateTimestamp('id', 'data');
156+
}
124157
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.