Open Journal Systems  3.3.0
MigratingSessionHandler.php
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
13 
23 class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
24 {
25  private $currentHandler;
26  private $writeOnlyHandler;
27 
28  public function __construct(\SessionHandlerInterface $currentHandler, \SessionHandlerInterface $writeOnlyHandler)
29  {
30  if (!$currentHandler instanceof \SessionUpdateTimestampHandlerInterface) {
31  $currentHandler = new StrictSessionHandler($currentHandler);
32  }
33  if (!$writeOnlyHandler instanceof \SessionUpdateTimestampHandlerInterface) {
34  $writeOnlyHandler = new StrictSessionHandler($writeOnlyHandler);
35  }
36 
37  $this->currentHandler = $currentHandler;
38  $this->writeOnlyHandler = $writeOnlyHandler;
39  }
40 
44  public function close()
45  {
46  $result = $this->currentHandler->close();
47  $this->writeOnlyHandler->close();
48 
49  return $result;
50  }
51 
55  public function destroy($sessionId)
56  {
57  $result = $this->currentHandler->destroy($sessionId);
58  $this->writeOnlyHandler->destroy($sessionId);
59 
60  return $result;
61  }
62 
66  public function gc($maxlifetime)
67  {
68  $result = $this->currentHandler->gc($maxlifetime);
69  $this->writeOnlyHandler->gc($maxlifetime);
70 
71  return $result;
72  }
73 
77  public function open($savePath, $sessionName)
78  {
79  $result = $this->currentHandler->open($savePath, $sessionName);
80  $this->writeOnlyHandler->open($savePath, $sessionName);
81 
82  return $result;
83  }
84 
88  public function read($sessionId)
89  {
90  // No reading from new handler until switch-over
91  return $this->currentHandler->read($sessionId);
92  }
93 
97  public function write($sessionId, $sessionData)
98  {
99  $result = $this->currentHandler->write($sessionId, $sessionData);
100  $this->writeOnlyHandler->write($sessionId, $sessionData);
101 
102  return $result;
103  }
104 
108  public function validateId($sessionId)
109  {
110  // No reading from new handler until switch-over
111  return $this->currentHandler->validateId($sessionId);
112  }
113 
117  public function updateTimestamp($sessionId, $sessionData)
118  {
119  $result = $this->currentHandler->updateTimestamp($sessionId, $sessionData);
120  $this->writeOnlyHandler->updateTimestamp($sessionId, $sessionData);
121 
122  return $result;
123  }
124 }
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler\validateId
validateId($sessionId)
Definition: MigratingSessionHandler.php:108
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler\close
close()
Definition: MigratingSessionHandler.php:44
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler\open
open($savePath, $sessionName)
Definition: MigratingSessionHandler.php:77
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler\__construct
__construct(\SessionHandlerInterface $currentHandler, \SessionHandlerInterface $writeOnlyHandler)
Definition: MigratingSessionHandler.php:28
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler\read
read($sessionId)
Definition: MigratingSessionHandler.php:88
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler\destroy
destroy($sessionId)
Definition: MigratingSessionHandler.php:55
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler\updateTimestamp
updateTimestamp($sessionId, $sessionData)
Definition: MigratingSessionHandler.php:117
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler
Definition: MigratingSessionHandler.php:23
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler\write
write($sessionId, $sessionData)
Definition: MigratingSessionHandler.php:97
Symfony\Component\HttpFoundation\Session\Storage\Handler
Definition: lib/vendor/symfony/http-foundation/Session/Storage/Handler/MemcachedSessionHandler.php:12
Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler\gc
gc($maxlifetime)
Definition: MigratingSessionHandler.php:66
Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler
Definition: StrictSessionHandler.php:19