You are here

private function PdoSessionHandler::beginTransaction in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler::beginTransaction()

Helper method to begin a transaction.

Since SQLite does not support row level locks, we have to acquire a reserved lock on the database immediately. Because of https://bugs.php.net/42766 we have to create such a transaction manually which also means we cannot use PDO::commit or PDO::rollback or PDO::inTransaction for SQLite.

Also MySQLs default isolation, REPEATABLE READ, causes deadlock for different sessions due to http://www.mysqlperformanceblog.com/2013/12/12/one-more-innodb-gap-lock-... . So we change it to READ COMMITTED.

1 call to PdoSessionHandler::beginTransaction()
PdoSessionHandler::getSelectSql in vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php
Return a locking or nonlocking SQL query to read session information.

File

vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php, line 436

Class

PdoSessionHandler
Session handler using a PDO connection to read and write data.

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

private function beginTransaction() {
  if (!$this->inTransaction) {
    if ('sqlite' === $this->driver) {
      $this->pdo
        ->exec('BEGIN IMMEDIATE TRANSACTION');
    }
    else {
      if ('mysql' === $this->driver) {
        $this->pdo
          ->exec('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
      }
      $this->pdo
        ->beginTransaction();
    }
    $this->inTransaction = true;
  }
}