8000 Merge branch '3.1' · symfony/symfony@673cec7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 673cec7

Browse files
Merge branch '3.1'
* 3.1: [Routing] Reorder assert parameters [Cache] Use SCAN instead of KEYS with Redis >= 2.8 Added missing czech validators translation of not expected charset Improved deprecation message Workaround another buggy PHP warning Add czech translation for Url and Length validator Add slovak translation for Url and Length validator
2 parents 64ace10 + d13c424 commit 673cec7

File tree

6 files changed

+57
-21
lines changed

6 files changed

+57
-21
lines changed

src/Symfony/Component/Cache/Adapter/RedisAdapterTrait.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ protected function doClear($namespace)
3333
// When using a native Redis cluster, clearing the cache cannot work and always returns false.
3434
// Clearing the cache should then be done by any other means (e.g. by restarting the cluster).
3535

36+
$cleared = true;
3637
$hosts = array($this->redis);
3738
$evalArgs = array(array($namespace), 0);
3839

@@ -49,6 +50,7 @@ protected function doClear($namespace)
4950
return false;
5051
}
5152
} elseif ($this->redis instanceof \RedisArray) {
53+
$hosts = array();
5254
foreach ($this->redis->_hosts() as $host) {
5355
$hosts[] = $this->redis->_instance($host);
5456
}
@@ -57,17 +59,35 @@ protected function doClear($namespace)
5759
}
5860
foreach ($hosts as $host) {
5961
if (!isset($namespace[0])) {
60-
$host->flushDb();
61-
} else {
62+
$cleared = $host->flushDb() && $cleared;
63+
continue;
64+
}
65+
66+
$info = $host->info('Server');
67+
$info = isset($info['Server']) ? $info['Server'] : $info;
68+
69+
if (!version_compare($info['redis_version'], '2.8', '>=')) {
6270
// As documented in Redis documentation (http://redis.io/commands/keys) using KEYS
6371
// can hang your server when it is executed against large databases (millions of items).
64-
// Whenever you hit this scale, it is advised to deploy one Redis database per cache pool
65-
// instead of using namespaces, so that FLUSHDB is used instead.
66-
$host->eval("local keys=redis.call('KEYS',ARGV[1]..'*') for i=1,#keys,5000 do redis.call('DEL',unpack(keys,i,math.min(i+4999,#keys))) end", $evalArgs[0], $evalArgs[1]);
72+
// Whenever you hit this scale, you should really consider upgrading to Redis 2.8 or above.
73+
$cleared = $host->eval("local keys=redis.call('KEYS',ARGV[1]..'*') for i=1,#keys,5000 do redis.call('DEL',unpack(keys,i,math.min(i+4999,#keys))) end return 1", $evalArgs[0], $evalArgs[1]) && $cleared;
74+
continue;
6775
}
76+
77+
$cursor = null;
78+
do {
79+
$keys = $host instanceof \Predis\Client ? $host->scan($cursor, 'MATCH', $namespace.'*', 'COUNT', 1000) : $host->scan($cursor, $namespace.'*', 1000);
80+
if (isset($keys[1]) && is_array($keys[1])) {
81+
$cursor = $keys[0];
82+
$keys = $keys[1];
83+
}
84+
if ($keys) {
85+
$host->del($keys);
86+
}
87+
} while ($cursor = (int) $cursor);
6888
}
6989

70-
return true;
90+
return $cleared;
7191
}
7292

7393
private function setRedis($redisClient, $namespace)

src/Symfony/Component/Process/ExecutableFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function find($name, $default = null, array $extraDirs = array())
6060
if (@is_dir($path)) {
6161
$dirs[] = $path;
6262
} else {
63-
if (basename($path) == $name && is_executable($path)) {
63+
if (basename($path) == $name && @is_executable($path)) {
6464
return $path;
6565
}
6666
}

src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ public function testDumpWithRoutes()
7777
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
7878
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
7979

80-
$this->assertEquals($absoluteUrlWithParameter, 'http://localhost/app.php/testing/bar');
81-
$this->assertEquals($absoluteUrlWithoutParameter, 'http://localhost/app.php/testing2');
82-
$this->assertEquals($relativeUrlWithParameter, '/app.php/testing/bar');
83-
$this->assertEquals($relativeUrlWithoutParameter, '/app.php/testing2');
80+
$this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter);
81+
$this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter);
82+
$this->assertEquals('/app.php/testing/bar', $relativeUrlWithParameter);
83+
$this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter);
8484
}
8585

8686
public function testDumpWithTooManyRoutes()
@@ -108,10 +108,10 @@ public function testDumpWithTooManyRoutes()
108108
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
109109
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
110110

111-
$this->assertEquals($absoluteUrlWithParameter, 'http://localhost/app.php/testing/bar');
112-
$this->assertEquals($absoluteUrlWithoutParameter, 'http://localhost/app.php/testing2');
113-
$this->assertEquals($relativeUrlWithParameter, '/app.php/testing/bar');
114-
$this->assertEquals($relativeUrlWithoutParameter, '/app.php/testing2');
111+
$this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter);
112+
$this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter);
113+
$this->assertEquals('/app.php/testing/bar', $relativeUrlWithParameter);
114+
$this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter);
115115
}
116116

117117
/**
@@ -151,7 +151,7 @@ public function testDumpForRouteWithDefaults()
151151
$projectUrlGenerator = new \DefaultRoutesUrlGenerator(new RequestContext());
152152
$url = $projectUrlGenerator->generate('Test', array());
153153

154-
$this->assertEquals($url, '/testing');
154+
$this->assertEquals('/testing', $url);
155155
}
156156

157157
public function testDumpWithSchemeRequirement()
@@ -166,15 +166,15 @@ public function testDumpWithSchemeRequirement()
166166
$absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL);
167167
$relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
168168

169-
$this->assertEquals($absoluteUrl, 'ftp://localhost/app.php/testing');
170-
$this->assertEquals($relativeUrl, 'ftp://localhost/app.php/testing');
169+
$this->assertEquals('ftp://localhost/app.php/testing', $absoluteUrl);
170+
$this->assertEquals('ftp://localhost/app.php/testing', $relativeUrl);
171171

172172
$projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https'));
173173

174174
$absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL);
175175
$relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
176176

177-
$this->assertEquals($absoluteUrl, 'https://localhost/app.php/testing');
178-
$this->assertEquals($relativeUrl, '/app.php/testing');
177+
$this->assertEquals('https://localhost/app.php/testing', $absoluteUrl);
178+
$this->assertEquals('/app.php/testing', $relativeUrl);
179179
}
180180
}

src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@
302302
<source>An empty file is not allowed.</source>
303303
<target>Soubor nesmí být prázdný.</target>
304304
</trans-unit>
305+
<trans-unit id="79">
306+
<source>The host could not be resolved.</source>
307+
<target>Hostitele nebylo možné rozpoznat.</target>
308+
</trans-unit>
309+
<trans-unit id="80">
310+
<source>This value does not match the expected {{ charset }} charset.</source>
311+
<target>Tato hodnota neodpovídá očekávané znakové sadě {{ charset }}.</target>
312+
</trans-unit>
305313
</body>
306314
</file>
307315
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.sk.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@
302302
<source>An empty file is not allowed.</source>
303303
<target>Súbor nesmie byť prázdny.</target>
304304
</trans-unit>
305+
<trans-unit id="79">
306+
<source>The host could not be resolved.</source>
307+
<target>Hostiteľa nebolo možné rozpoznať.</target>
308+
</trans-unit>
309+
<trans-unit id="80">
310+
<source>This value does not match the expected {{ charset }} charset.</source>
311+
<target>Táto hodnota nezodpovedá očakávanej znakovej sade {{ charset }}.</target>
312+
</trans-unit>
305313
</body>
306314 </file>
307315
</xliff>

src/Symfony/Component/Yaml/Inline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, $str
320320
}
321321

322322
if ($output && '%' === $output[0]) {
323-
@trigger_error('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
323+
@trigger_error(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.' , $output), E_USER_DEPRECATED);
324324
}
325325

326326
if ($evaluate) {

0 commit comments

Comments
 (0)
0