8000 bug #26443 [Fix][3.4][HttpFoundation] Fix the updating of timestamp i… · symfony/symfony@8f4a0b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f4a0b6

Browse files
committed
bug #26443 [Fix][3.4][HttpFoundation] Fix the updating of timestamp in the MemcachedSessionHandler (Alessandro Loffredo)
This PR was merged into the 3.4 branch. Discussion ---------- [Fix][3.4][HttpFoundation] Fix the updating of timestamp in the MemcachedSessionHandler | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Conditions: Symfony 3.4, PHP7 and sessions handled over memcache. Apparently `memcached::touch()` returns `false` on a subsequent call with the same parameters. Since `updateTimestamp` is used in `AbstractSessionHandler::write()` ``` public function write($sessionId, $data) { if (\PHP_VERSION_ID < 70000 && $this->prefetchData) { $readData = $this->prefetchData; $this->prefetchData = null; if ($readData === $data) { return $this->updateTimestamp($sessionId, $data); } } ... ``` the result is that `write()` will return `false` on **any subsequent request within the same second** causing the following error: ``` HP Fatal error: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/var/lib/php/sessions) in Unknown:0 Stack trace: #0 [internal function]: Symfony\Component\Debug\ErrorHandler->handleError(2, 'session_write_c...', 'Unknown', 0, NULL) #1 [internal function]: session_write_close() #2 {main} thrown in Unknown on line 0 ``` Can be reproduced on `symfony/skeleton:3.4` adding the following code to `public/index.php` and performing two consecutive requests: ``` $session = $kernel->getContainer()->get('session'); $session->set("foo", "bar"); ``` Commits ------- d007469 fix the updating of timestamp in the MemcachedSessionHandler
2 parents 957588a + d007469 commit 8f4a0b6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ protected function doRead($sessionId)
8080
*/
8181
public function updateTimestamp($sessionId, $data)
8282
{
83-
return $this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl);
83+
$this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl);
84+
85+
return true;
8486
}
8587

8688
/**

0 commit comments

Comments
 (0)
0