"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Symfony/Component/Lock/Store/PdoStore.php" between
symfony-4.4.14.tar.gz and symfony-4.4.15.tar.gz

About: Symfony is a web application framework for PHP projects. Source code (4.4 series).

PdoStore.php  (symfony-4.4.14):PdoStore.php  (symfony-4.4.15)
skipping to change at line 16 skipping to change at line 16
* (c) Fabien Potencier <fabien@symfony.com> * (c) Fabien Potencier <fabien@symfony.com>
* *
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Symfony\Component\Lock\Store; namespace Symfony\Component\Lock\Store;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\InvalidTtlException; use Symfony\Component\Lock\Exception\InvalidTtlException;
use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Exception\NotSupportedException; use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key; use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface; use Symfony\Component\Lock\StoreInterface;
skipping to change at line 176 skipping to change at line 175
$sql = "UPDATE $this->table SET $this->expirationCol = {$this->getCurren tTimestampStatement()} + $ttl, $this->tokenCol = :token1 WHERE $this->idCol = :i d AND ($this->tokenCol = :token2 OR $this->expirationCol <= {$this->getCurrentTi mestampStatement()})"; $sql = "UPDATE $this->table SET $this->expirationCol = {$this->getCurren tTimestampStatement()} + $ttl, $this->tokenCol = :token1 WHERE $this->idCol = :i d AND ($this->tokenCol = :token2 OR $this->expirationCol <= {$this->getCurrentTi mestampStatement()})";
$stmt = $this->getConnection()->prepare($sql); $stmt = $this->getConnection()->prepare($sql);
$uniqueToken = $this->getUniqueToken($key); $uniqueToken = $this->getUniqueToken($key);
$stmt->bindValue(':id', $this->getHashedKey($key)); $stmt->bindValue(':id', $this->getHashedKey($key));
$stmt->bindValue(':token1', $uniqueToken); $stmt->bindValue(':token1', $uniqueToken);
$stmt->bindValue(':token2', $uniqueToken); $stmt->bindValue(':token2', $uniqueToken);
$result = $stmt->execute(); $result = $stmt->execute();
// If this method is called twice in the same second, the row wouldn't b e updated. We have to call exists to know if we are the owner // If this method is called twice in the same second, the row wouldn't b e updated. We have to call exists to know if we are the owner
if (!($result instanceof Result ? $result : $stmt)->rowCount() && !$this ->exists($key)) { if (!(\is_object($result) ? $result : $stmt)->rowCount() && !$this->exis ts($key)) {
throw new LockConflictedException(); throw new LockConflictedException();
} }
$this->checkNotExpired($key); $this->checkNotExpired($key);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function delete(Key $key) public function delete(Key $key)
skipping to change at line 208 skipping to change at line 207
*/ */
public function exists(Key $key) public function exists(Key $key)
{ {
$sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND $this->t okenCol = :token AND $this->expirationCol > {$this->getCurrentTimestampStatement ()}"; $sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND $this->t okenCol = :token AND $this->expirationCol > {$this->getCurrentTimestampStatement ()}";
$stmt = $this->getConnection()->prepare($sql); $stmt = $this->getConnection()->prepare($sql);
$stmt->bindValue(':id', $this->getHashedKey($key)); $stmt->bindValue(':id', $this->getHashedKey($key));
$stmt->bindValue(':token', $this->getUniqueToken($key)); $stmt->bindValue(':token', $this->getUniqueToken($key));
$result = $stmt->execute(); $result = $stmt->execute();
return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt-> fetchColumn()); return (bool) (\is_object($result) ? $result->fetchOne() : $stmt->fetchC olumn());
} }
/** /**
* Returns a hashed version of the key. * Returns a hashed version of the key.
*/ */
private function getHashedKey(Key $key): string private function getHashedKey(Key $key): string
{ {
return hash('sha256', (string) $key); return hash('sha256', (string) $key);
} }
 End of changes. 3 change blocks. 
3 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)