Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MigratingSessionHandler.php

class MigratingSessionHandler

Migrating session handler for migrating from one handler to another. It reads from the current handler and writes both the current and new ones.

It ignores errors from the new handler.

@author Ross Motley <ross.motley@amara.com> @author Oliver Radwell <oliver.radwell@amara.com>

Hierarchy

  • class \Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler implements \Symfony\Component\HttpFoundation\Session\Storage\Handler\SessionHandlerInterface, \Symfony\Component\HttpFoundation\Session\Storage\Handler\SessionUpdateTimestampHandlerInterface

Expanded class hierarchy of MigratingSessionHandler

File

vendor/symfony/http-foundation/Session/Storage/Handler/MigratingSessionHandler.php, line 23

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler
View source
class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface {
    private \SessionHandlerInterface&\SessionUpdateTimestampHandlerInterface $currentHandler;
    private \SessionHandlerInterface&\SessionUpdateTimestampHandlerInterface $writeOnlyHandler;
    public function __construct(\SessionHandlerInterface $currentHandler, \SessionHandlerInterface $writeOnlyHandler) {
        if (!$currentHandler instanceof \SessionUpdateTimestampHandlerInterface) {
            $currentHandler = new StrictSessionHandler($currentHandler);
        }
        if (!$writeOnlyHandler instanceof \SessionUpdateTimestampHandlerInterface) {
            $writeOnlyHandler = new StrictSessionHandler($writeOnlyHandler);
        }
        $this->currentHandler = $currentHandler;
        $this->writeOnlyHandler = $writeOnlyHandler;
    }
    public function close() : bool {
        $result = $this->currentHandler
            ->close();
        $this->writeOnlyHandler
            ->close();
        return $result;
    }
    public function destroy(string $sessionId) : bool {
        $result = $this->currentHandler
            ->destroy($sessionId);
        $this->writeOnlyHandler
            ->destroy($sessionId);
        return $result;
    }
    public function gc(int $maxlifetime) : int|false {
        $result = $this->currentHandler
            ->gc($maxlifetime);
        $this->writeOnlyHandler
            ->gc($maxlifetime);
        return $result;
    }
    public function open(string $savePath, string $sessionName) : bool {
        $result = $this->currentHandler
            ->open($savePath, $sessionName);
        $this->writeOnlyHandler
            ->open($savePath, $sessionName);
        return $result;
    }
    public function read(string $sessionId) : string {
        // No reading from new handler until switch-over
        return $this->currentHandler
            ->read($sessionId);
    }
    public function write(string $sessionId, string $sessionData) : bool {
        $result = $this->currentHandler
            ->write($sessionId, $sessionData);
        $this->writeOnlyHandler
            ->write($sessionId, $sessionData);
        return $result;
    }
    public function validateId(string $sessionId) : bool {
        // No reading from new handler until switch-over
        return $this->currentHandler
            ->validateId($sessionId);
    }
    public function updateTimestamp(string $sessionId, string $sessionData) : bool {
        $result = $this->currentHandler
            ->updateTimestamp($sessionId, $sessionData);
        $this->writeOnlyHandler
            ->updateTimestamp($sessionId, $sessionData);
        return $result;
    }

}

Members

Title Sort descending Modifiers Object type Summary
MigratingSessionHandler::$currentHandler private property
MigratingSessionHandler::$writeOnlyHandler private property
MigratingSessionHandler::close public function
MigratingSessionHandler::destroy public function
MigratingSessionHandler::gc public function
MigratingSessionHandler::open public function
MigratingSessionHandler::read public function
MigratingSessionHandler::updateTimestamp public function
MigratingSessionHandler::validateId public function
MigratingSessionHandler::write public function
MigratingSessionHandler::__construct public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal