Skip to content

Commit ec51b2c

Browse files
Merge branch '4.1'
* 4.1: [DoctrineBridge] support __toString as documented for UniqueEntityValidator [travis] enable Redis cluster [Cache] enable Memcached::OPT_TCP_NODELAY to fix perf of misses fix data mapper return type in docblock fix type error handling when writing values
2 parents b959d85 + 51525e6 commit ec51b2c

File tree

14 files changed

+221
-5
lines changed

14 files changed

+221
-5
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@ services:
4141
- mongodb
4242
- redis-server
4343
- rabbitmq
44+
- docker
4445

4546
before_install:
47+
- |
48+
# Start Redis cluster
49+
docker pull grokzen/redis-cluster:4.0.8
50+
docker run -d -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 7005:7005 --name redis-cluster grokzen/redis-cluster:4.0.8
51+
export REDIS_CLUSTER_HOSTS='localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
52+
4653
- |
4754
# General configuration
4855
set -e

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ public function testAssociatedEntity()
482482

483483
$this->buildViolation('myMessage')
484484
->atPath('property.path.single')
485-
->setParameter('{{ value }}', 'object("Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity") identified by (id => 1)')
485+
->setParameter('{{ value }}', 'foo')
486486
->setInvalidValue($entity1)
487487
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
488488
->setCause(array($associated, $associated2))

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class,
186186
return $this->formatValue($value, self::PRETTY_DATE);
187187
}
188188

189+
if (\method_exists($value, '__toString')) {
190+
return (string) $value;
191+
}
192+
189193
if ($class->getName() !== $idClass = \get_class($value)) {
190194
// non unique value might be a composite PK that consists of other entity objects
191195
if ($em->getMetadataFactory()->hasMetadataFor($idClass)) {

src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function testDefaultOptions()
8989

9090
$this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION));
9191
$this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL));
92+
$this->assertSame(1, $client->getOption(\Memcached::OPT_TCP_NODELAY));
9293
$this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE));
9394
}
9495

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Tests\Adapter;
13+
14+
class RedisClusterAdapterTest extends AbstractRedisAdapterTest
15+
{
16+
public static function setupBeforeClass()
17+
{
18+
if (!class_exists('RedisCluster')) {
19+
self::markTestSkipped('The RedisCluster class is required.');
20+
}
21+
if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) {
22+
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
23+
}
24+
25+
self::$redis = new \RedisCluster(null, explode(' ', $hosts));
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Tests\Simple;
13+
14+
class RedisClusterCacheTest extends AbstractRedisCacheTest
15+
{
16+
public static function setupBeforeClass()
17+
{
18+
if (!class_exists('RedisCluster')) {
19+
self::markTestSkipped('The RedisCluster class is required.');
20+
}
21+
if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) {
22+
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
23+
}
24+
25+
self::$redis = new \RedisCluster(null, explode(' ', $hosts));
26+
}
27+
}

src/Symfony/Component/Cache/Traits/MemcachedTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public static function createConnection($servers, array $options = array())
138138
$options = array_change_key_case($options, CASE_UPPER);
139139
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
140140
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
141+
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
141142
if (!array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
142143
$client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
143144
}

src/Symfony/Component/Form/FormConfigInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function getModelTransformers();
9999
/**
100100
* Returns the data mapper of the form.
101101
*
102-
* @return DataMapperInterface The data mapper
102+
* @return DataMapperInterface|null The data mapper
103103
*/
104104
public function getDataMapper();
105105

src/Symfony/Component/Lock/Store/RedisStore.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ public function save(Key $key)
5454
$script = '
5555
if redis.call("GET", KEYS[1]) == ARGV[1] then
5656
return redis.call("PEXPIRE", KEYS[1], ARGV[2])
57+
elseif redis.call("SET", KEYS[1], ARGV[1], "NX", "PX", ARGV[2]) then
58+
return 1
5759
else
58-
return redis.call("set", KEYS[1], ARGV[1], "NX", "PX", ARGV[2])
60+
return 0
5961
end
6062
';
6163

@@ -140,7 +142,7 @@ private function evaluate(string $script, string $resource, array $args)
140142
return \call_user_func_array(array($this->redis, 'eval'), array_merge(array($script, 1, $resource), $args));
141143
}
142144

143-
throw new InvalidArgumentException(sprintf('%s() expects been initialized with a Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));
145+
throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));
144146
}
145147

146148
/**
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Lock\Tests\Store;
13+
14+
/**
15+
* @author Jérémy Derussé <jeremy@derusse.com>
16+
*
17+
* @requires extension redis
18+
*/
19+
class RedisClusterStoreTest extends AbstractRedisStoreTest
20+
{
21+
public static function setupBeforeClass()
22+
{
23+
if (!class_exists('RedisCluster')) {
24+
self::markTestSkipped('The RedisCluster class is required.');
25+
}
26+
if (!getenv('REDIS_CLUSTER_HOSTS')) {
27+
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
28+
}
29+
}
30+
31+
protected function getRedisConnection()
32+
{
33+
return new \RedisCluster(null, explode(' ', getenv('REDIS_CLUSTER_HOSTS')));
34+
}
35+
}

0 commit comments

Comments
 (0)