"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "public_html/lists/base/vendor/symfony/symfony/src/Symfony/Component/Lock/Store/RedisStore.php" between
phplist-3.4.5.tgz and phplist-3.4.6.tgz

About: phpList is a one-way email announcement delivery system for newsletters, publicity lists, notifications, and many other uses (requires PHP and MySQL).

RedisStore.php  (phplist-3.4.5.tgz):RedisStore.php  (phplist-3.4.6.tgz)
skipping to change at line 17 skipping to change at line 17
* *
* 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 Symfony\Component\Cache\Traits\RedisProxy; use Symfony\Component\Cache\Traits\RedisProxy;
use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Exception\LockConflictedException;
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;
/** /**
* RedisStore is a StoreInterface implementation using Redis as store engine. * RedisStore is a StoreInterface implementation using Redis as store engine.
* *
* @author Jérémy Derussé <jeremy@derusse.com> * @author Jérémy Derussé <jeremy@derusse.com>
*/ */
class RedisStore implements StoreInterface class RedisStore implements StoreInterface
{ {
skipping to change at line 75 skipping to change at line 76
$key->reduceLifetime($this->initialTtl); $key->reduceLifetime($this->initialTtl);
if (!$this->evaluate($script, (string) $key, [$this->getToken($key), (in t) ceil($this->initialTtl * 1000)])) { if (!$this->evaluate($script, (string) $key, [$this->getToken($key), (in t) ceil($this->initialTtl * 1000)])) {
throw new LockConflictedException(); throw new LockConflictedException();
} }
$this->checkNotExpired($key); $this->checkNotExpired($key);
} }
public function waitAndSave(Key $key) public function waitAndSave(Key $key)
{ {
throw new InvalidArgumentException(sprintf('The store "%s" does not supp orts blocking locks.', \get_class($this))); throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this)));
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function putOffExpiration(Key $key, $ttl) public function putOffExpiration(Key $key, $ttl)
{ {
$script = ' $script = '
if redis.call("GET", KEYS[1]) == ARGV[1] then if redis.call("GET", KEYS[1]) == ARGV[1] then
return redis.call("PEXPIRE", KEYS[1], ARGV[2]) return redis.call("PEXPIRE", KEYS[1], ARGV[2])
skipping to change at line 128 skipping to change at line 129
public function exists(Key $key) public function exists(Key $key)
{ {
return $this->redis->get((string) $key) === $this->getToken($key); return $this->redis->get((string) $key) === $this->getToken($key);
} }
/** /**
* Evaluates a script in the corresponding redis client. * Evaluates a script in the corresponding redis client.
* *
* @param string $script * @param string $script
* @param string $resource * @param string $resource
* @param array $args
* *
* @return mixed * @return mixed
*/ */
private function evaluate($script, $resource, array $args) private function evaluate($script, $resource, array $args)
{ {
if ($this->redis instanceof \Redis || $this->redis instanceof \RedisClus ter || $this->redis instanceof RedisProxy) { if ($this->redis instanceof \Redis || $this->redis instanceof \RedisClus ter || $this->redis instanceof RedisProxy) {
return $this->redis->eval($script, array_merge([$resource], $args), 1); return $this->redis->eval($script, array_merge([$resource], $args), 1);
} }
if ($this->redis instanceof \RedisArray) { if ($this->redis instanceof \RedisArray) {
skipping to change at line 152 skipping to change at line 152
if ($this->redis instanceof \Predis\Client) { if ($this->redis instanceof \Predis\Client) {
return \call_user_func_array([$this->redis, 'eval'], array_merge([$s cript, 1, $resource], $args)); return \call_user_func_array([$this->redis, 'eval'], array_merge([$s cript, 1, $resource], $args));
} }
throw new InvalidArgumentException(sprintf('%s() expects being initializ ed with a Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD_ _, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)) ); throw new InvalidArgumentException(sprintf('%s() expects being initializ ed with a Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD_ _, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)) );
} }
/** /**
* Retrieves an unique token for the given key. * Retrieves an unique token for the given key.
* *
* @param Key $key
*
* @return string * @return string
*/ */
private function getToken(Key $key) private function getToken(Key $key)
{ {
if (!$key->hasState(__CLASS__)) { if (!$key->hasState(__CLASS__)) {
$token = base64_encode(random_bytes(32)); $token = base64_encode(random_bytes(32));
$key->setState(__CLASS__, $token); $key->setState(__CLASS__, $token);
} }
return $key->getState(__CLASS__); return $key->getState(__CLASS__);
 End of changes. 4 change blocks. 
4 lines changed or deleted 2 lines changed or added

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