| @@ 448-465 (lines=18) @@ | ||
| 445 | /** |
|
| 446 | * Helper method to commit a transaction. |
|
| 447 | */ |
|
| 448 | private function commit() |
|
| 449 | { |
|
| 450 | if ($this->inTransaction) { |
|
| 451 | try { |
|
| 452 | // commit read-write transaction which also releases the lock |
|
| 453 | if ('sqlite' === $this->driver) { |
|
| 454 | $this->pdo->exec('COMMIT'); |
|
| 455 | } else { |
|
| 456 | $this->pdo->commit(); |
|
| 457 | } |
|
| 458 | $this->inTransaction = false; |
|
| 459 | } catch (\PDOException $e) { |
|
| 460 | $this->rollback(); |
|
| 461 | ||
| 462 | throw $e; |
|
| 463 | } |
|
| 464 | } |
|
| 465 | } |
|
| 466 | ||
| 467 | /** |
|
| 468 | * Helper method to rollback a transaction. |
|
| @@ 470-484 (lines=15) @@ | ||
| 467 | /** |
|
| 468 | * Helper method to rollback a transaction. |
|
| 469 | */ |
|
| 470 | private function rollback() |
|
| 471 | { |
|
| 472 | // We only need to rollback if we are in a transaction. Otherwise the resulting |
|
| 473 | // error would hide the real problem why rollback was called. We might not be |
|
| 474 | // in a transaction when not using the transactional locking behavior or when |
|
| 475 | // two callbacks (e.g. destroy and write) are invoked that both fail. |
|
| 476 | if ($this->inTransaction) { |
|
| 477 | if ('sqlite' === $this->driver) { |
|
| 478 | $this->pdo->exec('ROLLBACK'); |
|
| 479 | } else { |
|
| 480 | $this->pdo->rollBack(); |
|
| 481 | } |
|
| 482 | $this->inTransaction = false; |
|
| 483 | } |
|
| 484 | } |
|
| 485 | ||
| 486 | /** |
|
| 487 | * Reads the session data in respect to the different locking strategies. |
|