Skip to content

Commit 2e111b3

Browse files
committed
Merge branch '3.3' into 3.4
* 3.3: (27 commits) Always require symfony/polyfill-apcu to provide APCuIterator everywhere bumped Symfony version to 3.3.9 updated VERSION for 3.3.8 updated CHANGELOG for 3.3.8 [DI] Fix tracking env var placeholders nested in object graphs bumped Symfony version to 3.3.8 updated VERSION for 3.3.7 updated CHANGELOG for 3.3.7 [DI] Fix tracking env vars when merging configs (bis) removed obsolete comment install PHPUnit 6 on PHP 7.2 [Cache] Use zend.detect_unicode instead of zend.multibyte Fix case sensitive typo in use class name [VarDumper] Enhance docblock to tell about AbstractDumper::dumpLine(-1) [Debug] Remove false-positive check in DebugClassLoader [Validator] Fix use of GroupSequenceProvider in child classes Change number PHPDoc type to int|float [Cache] Workaround zend.detect_unicode + zend.multibyte [VarDumper] Strengthen dumped JS [VarDumper] Strengthen dumped JS ...
2 parents dda57e6 + ec7a2b1 commit 2e111b3

31 files changed

+370
-122
lines changed

.travis.yml

+28-5
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,38 @@ before_install:
5656
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
5757
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi'
5858
59+
nanoseconds() {
60+
local cmd="date"
61+
local format="+%s%N"
62+
local os=$(uname)
63+
if hash gdate > /dev/null 2>&1; then
64+
cmd="gdate"
65+
elif [[ "$os" = Darwin ]]; then
66+
format="+%s000000000"
67+
fi
68+
$cmd -u $format
69+
}
70+
export -f nanoseconds
71+
5972
# tfold is a helper to create folded reports
6073
tfold () {
61-
title=$1
62-
fold=$(echo $title | sed -r 's/[^-_A-Za-z\d]+/./g')
74+
local title=$1
75+
local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g')
6376
shift
64-
echo -e "travis_fold:start:$fold\\n\\e[1;34m$title\\e[0m"
65-
bash -xc "$*" 2>&1 &&
77+
local id=$(printf %08x $(( RANDOM * RANDOM )))
78+
local start=$(nanoseconds)
79+
echo -e "travis_fold:start:$fold"
80+
echo -e "travis_time:start:$id"
81+
echo -e "\\e[1;34m$title\\e[0m"
82+
83+
bash -xc "$*" 2>&1
84+
local ok=$?
85+
local end=$(nanoseconds)
86+
echo -e "\\ntravis_time:end:$id:start=$start,finish=$end,duration=$(($end-$start))"
87+
(exit $ok) &&
6688
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
67-
( echo -e "\\e[41mKO\\e[0m $title\\n" && exit 1 )
89+
echo -e "\\e[41mKO\\e[0m $title\\n"
90+
(exit $ok)
6891
}
6992
export -f tfold
7093

CHANGELOG-3.3.md

+44
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,50 @@ in 3.3 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.3.0...v3.3.1
99

10+
* 3.3.8 (2017-08-28)
11+
12+
* bug #24016 [DI] Fix tracking env var placeholders nested in object graphs (nicolas-grekas)
13+
14+
* 3.3.7 (2017-08-28)
15+
16+
* bug #24009 [DI] Fix tracking env vars when merging configs (bis) (nicolas-grekas)
17+
* bug #23952 [PhpUnitBridge] install PHPUnit 6 on PHP 7.2 (xabbuh)
18+
* bug #23985 [Cache] Workaround zend.detect_unicode + zend.multibyte (nicolas-grekas)
19+
* bug #23989 [Debug] Remove false-positive check in DebugClassLoader (nicolas-grekas)
20+
* bug #23983 [VarDumper] Strengthen dumped JS (nicolas-grekas)
21+
* bug #23982 [VarDumper] Strengthen dumped JS (nicolas-grekas)
22+
* bug #23925 [Validator] Fix use of GroupSequenceProvider in child classes (linniksa)
23+
* bug #23971 [Cache] Fix lazy Memcached connections (nicolas-grekas)
24+
* bug #23970 [Cache] Fix >30 days expirations with Memcached (nicolas-grekas)
25+
* bug #23949 [Dotenv] Get env using $_SERVER to work with fastcgi_param and workaround thread safety issues (nicolas-grekas)
26+
* bug #23799 [Dotenv][WebServerBundle] Override previously loaded variables (voronkovich)
27+
* bug #23676 [WebProfilerBundle] Re add missing link to the controller (lyrixx)
28+
* bug #23870 [DI] Use GlobResource for non-tracked directories (vudaltsov)
29+
* bug #23945 [Validator] Fix Greek translation (azhurb)
30+
* bug #23940 [DI] Fix resolving env vars when compiling a ContainerBuilder (nicolas-grekas)
31+
* bug #23903 [DI] Fix merging of env vars in configs (nicolas-grekas)
32+
* bug #23825 Revert "feature #21038 [FrameworkBundle] deprecated cache:clear with warmup (fabpot)" (nicolas-grekas)
33+
* bug #23899 [DI] Fix reading env vars from fastcgi params (nicolas-grekas)
34+
* bug #23909 [Console] Initialize lazily to render exceptions properly (nicolas-grekas)
35+
* bug #23878 [VarDumper] play nice with open_basedir when looking for composer.json (nicolas-grekas)
36+
* bug #23897 Allow phpdocumentor/reflection-docblock 4 (derrabus)
37+
* bug #23865 [Workflow] fixed InvalidDefinitionException message for StateMachineValidator (fmata)
38+
* bug #23856 [DI] Fix dumping abstract with YamlDumper (nicolas-grekas)
39+
* bug #23848 restrict reflection doc block (ElectricMaxxx)
40+
* bug #23854 [DI] Fix YamlDumper not dumping abstract and autoconfigure (nicolas-grekas)
41+
* bug #23752 Ignore memcached missing key error on session destroy (jderusse)
42+
* bug #23829 Fixed the exception page design in responsive mode (javiereguiluz)
43+
* bug #23828 [Console] Log exit codes as debug messages instead of errors (haroldiedema)
44+
* bug #23763 [Cache] Hash cache key on save (lstrojny)
45+
* bug #23806 [Profiler] Fix request_collector check in main layout (ogizanagi)
46+
* bug #23658 [HttpFoundation] Generate safe fallback filename for wrongly encoded filename (xelaris)
47+
* bug #23776 [FrameworkBundle] Warmup annotations for bundle-less controllers and entities (nicolas-grekas)
48+
* bug #23783 Avoid infinite loops when profiler data is malformed (javiereguiluz)
49+
* bug #23638 [FrameworkBundle][Workflow] better errors when security deps are missing (xabbuh)
50+
* bug #23729 [Bridge\ProxyManager] Dont call __destruct() on non-instantiated services (nicolas-grekas)
51+
* bug #23703 Bump minimal PHP version to ^5.5.9|>=7.0.8 (nicolas-grekas)
52+
* bug #23755 [Config] Fix checking class existence freshness (nicolas-grekas)
53+
1054
* 3.3.6 (2017-08-01)
1155

1256
* bug #22244 [Console] Fix passing options with defaultCommand (Jakub Sacha)

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"psr/link": "^1.0",
2727
"psr/log": "~1.0",
2828
"psr/simple-cache": "^1.0",
29+
"symfony/polyfill-apcu": "~1.1",
2930
"symfony/polyfill-intl-icu": "~1.0",
3031
"symfony/polyfill-mbstring": "~1.0",
3132
"symfony/polyfill-php56": "~1.0",
@@ -97,7 +98,6 @@
9798
"predis/predis": "~1.0",
9899
"egulias/email-validator": "~1.2,>=1.2.8|~2.0",
99100
"symfony/phpunit-bridge": "~3.2",
100-
"symfony/polyfill-apcu": "~1.1",
101101
"symfony/security-acl": "~2.8|~3.0",
102102
"phpdocumentor/reflection-docblock": "^3.0|^4.0"
103103
},

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

+11-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@
1515

1616
error_reporting(-1);
1717

18-
// PHPUnit 4.8 does not support PHP 7, while 5.1 requires PHP 5.6+
19-
$PHPUNIT_VERSION = PHP_VERSION_ID >= 50600 ? getenv('SYMFONY_PHPUNIT_VERSION') ?: '5.7' : '4.8';
18+
if (PHP_VERSION_ID >= 70200) {
19+
// PHPUnit 6 is required for PHP 7.2+
20+
$PHPUNIT_VERSION = getenv('SYMFONY_PHPUNIT_VERSION') ?: '6.3';
21+
} elseif (PHP_VERSION_ID >= 50600) {
22+
// PHPUnit 4 does not support PHP 7
23+
$PHPUNIT_VERSION = getenv('SYMFONY_PHPUNIT_VERSION') ?: '5.7';
24+
} else {
25+
// PHPUnit 5.1 requires PHP 5.6+
26+
$PHPUNIT_VERSION = '4.8';
27+
}
28+
2029
$oldPwd = getcwd();
2130
$PHPUNIT_DIR = getenv('SYMFONY_PHPUNIT_DIR') ?: (__DIR__.'/.phpunit');
2231
$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php';

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

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __construct($file, AdapterInterface $fallbackPool)
3838
{
3939
$this->file = $file;
4040
$this->fallbackPool = $fallbackPool;
41+
$this->zendDetectUnicode = ini_get('zend.detect_unicode');
4142
$this->createCacheItem = \Closure::bind(
4243
function ($key, $value, $isHit) {
4344
$item = new CacheItem();

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

+1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ public function __construct($namespace = '', $defaultLifetime = 0, $directory =
3636

3737
$e = new \Exception();
3838
$this->includeHandler = function () use ($e) { throw $e; };
39+
$this->zendDetectUnicode = ini_get('zend.detect_unicode');
3940
}
4041
}

src/Symfony/Component/Cache/Simple/PhpArrayCache.php

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct($file, CacheInterface $fallbackPool)
3434
{
3535
$this->file = $file;
3636
$this->fallbackPool = $fallbackPool;
37+
$this->zendDetectUnicode = ini_get('zend.detect_unicode');
3738
}
3839

3940
/**

src/Symfony/Component/Cache/Simple/PhpFilesCache.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ public function __construct($namespace = '', $defaultLifetime = 0, $directory =
3636

3737
$e = new \Exception();
3838
$this->includeHandler = function () use ($e) { throw $e; };
39+
$this->zendDetectUnicode = ini_get('zend.detect_unicode');
3940
}
4041
}

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

+20
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,26 @@ public function testDefaultLifeTime()
5050
$this->assertFalse($item->isHit());
5151
}
5252

53+
public function testExpiration()
54+
{
55+
if (isset($this->skippedTests[__FUNCTION__])) {
56+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
57+
}
58+
59+
$cache = $this->createCachePool();
60+
$cache->save($cache->getItem('k1')->set('v1')->expiresAfter(2));
61+
$cache->save($cache->getItem('k2')->set('v2')->expiresAfter(366 * 86400));
62+
63+
sleep(3);
64+
$item = $cache->getItem('k1');
65+
$this->assertFalse($item->isHit());
66+
$this->assertNull($item->get(), "Item's value must be null when isHit() is false.");
67+
68+
$item = $cache->getItem('k2');
69+
$this->assertTrue($item->isHit());
70+
$this->assertSame('v2', $item->get());
71+
}
72+
5373
public function testNotUnserializable()
5474
{
5575
if (isset($this->skippedTests[__FUNCTION__])) {

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

+25
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,31 @@ public function testVersion()
7777
$this->assertNull($item->get());
7878
}
7979

80+
public function testNamespace()
81+
{
82+
$namespace = str_replace('\\', '.', get_class($this));
83+
84+
$pool1 = new ApcuAdapter($namespace.'_1', 0, 'p1');
85+
86+
$item = $pool1->getItem('foo');
87+
$this->assertFalse($item->isHit());
88+
$this->assertTrue($pool1->save($item->set('bar')));
89+
90+
$item = $pool1->getItem('foo');
91+
$this->assertTrue($item->isHit());
92+
$this->assertSame('bar', $item->get());
93+
94+
$pool2 = new ApcuAdapter($namespace.'_2', 0, 'p1');
95+
96+
$item = $pool2->getItem('foo');
97+
$this->assertFalse($item->isHit());
98+
$this->assertNull($item->get());
99+
100+
$item = $pool1->getItem('foo');
101+
$this->assertTrue($item->isHit());
102+
$this->assertSame('bar', $item->get());
103+
}
104+
80105
public function testWithCliSapi()
81106
{
82107
try {

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

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
class MemcachedAdapterTest extends AdapterTestCase
1818
{
1919
protected $skippedTests = array(
20-
'testExpiration' => 'Testing expiration slows down the test suite',
2120
'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite',
2221
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
2322
);

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

+39-10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ trait MemcachedTrait
3030
);
3131

3232
private $client;
33+
private $lazyClient;
3334

3435
public static function isSupported()
3536
{
@@ -41,14 +42,18 @@ private function init(\Memcached $client, $namespace, $defaultLifetime)
4142
if (!static::isSupported()) {
4243
throw new CacheException('Memcached >= 2.2.0 is required');
4344
}
44-
$opt = $client->getOption(\Memcached::OPT_SERIALIZER);
45-
if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) {
46-
throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
45+
if (get_class($client) === 'Memcached') {
46+
$opt = $client->getOption(\Memcached::OPT_SERIALIZER);
47+
if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) {
48+
throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
49+
}
50+
$this->maxIdLength -= strlen($client->getOption(\Memcached::OPT_PREFIX_KEY));
51+
$this->client = $client;
52+
} else {
53+
$this->lazyClient = $client;
4754
}
48-
$this->maxIdLength -= strlen($client->getOption(\Memcached::OPT_PREFIX_KEY));
4955

5056
parent::__construct($namespace, $defaultLifetime);
51-
$this->client = $client;
5257
}
5358

5459
/**
@@ -187,7 +192,11 @@ public static function createConnection($servers, array $options = array())
187192
*/
188193
protected function doSave(array $values, $lifetime)
189194
{
190-
return $this->checkResultCode($this->client->setMulti($values, $lifetime));
195+
if ($lifetime && $lifetime > 30 * 86400) {
196+
$lifetime += time();
197+
}
198+
199+
return $this->checkResultCode($this->getClient()->setMulti($values, $lifetime));
191200
}
192201

193202
/**
@@ -197,7 +206,7 @@ protected function doFetch(array $ids)
197206
{
198207
$unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
199208
try {
200-
return $this->checkResultCode($this->client->getMulti($ids));
209+
return $this->checkResultCode($this->getClient()->getMulti($ids));
201210
} catch (\Error $e) {
202211
throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
203212
} finally {
@@ -210,7 +219,7 @@ protected function doFetch(array $ids)
210219
*/
211220
protected function doHave($id)
212221
{
213-
return false !== $this->client->get($id) || $this->checkResultCode(\Memcached::RES_SUCCESS === $this->client->getResultCode());
222+
return false !== $this->getClient()->get($id) || $this->checkResultCode(\Memcached::RES_SUCCESS === $this->client->getResultCode());
214223
}
215224

216225
/**
@@ -219,7 +228,7 @@ protected function doHave($id)
219228
protected function doDelete(array $ids)
220229
{
221230
$ok = true;
222-
foreach ($this->checkResultCode($this->client->deleteMulti($ids)) as $result) {
231+
foreach ($this->checkResultCode($this->getClient()->deleteMulti($ids)) as $result) {
223232
if (\Memcached::RES_SUCCESS !== $result && \Memcached::RES_NOTFOUND !== $result) {
224233
$ok = false;
225234
}
@@ -233,7 +242,7 @@ protected function doDelete(array $ids)
233242
*/
234243
protected function doClear($namespace)
235244
{
236-
return $this->checkResultCode($this->client->flush());
245+
return $this->checkResultCode($this->getClient()->flush());
237246
}
238247

239248
private function checkResultCode($result)
@@ -246,4 +255,24 @@ private function checkResultCode($result)
246255

247256
throw new CacheException(sprintf('MemcachedAdapter client error: %s.', strtolower($this->client->getResultMessage())));
248257
}
258+
259+
/**
260+
* @return \Memcached
261+
*/
262+
private function getClient()
263+
{
264+
if ($this->client) {
265+
return $this->client;
266+
}
267+
268+
$opt = $this->lazyClient->getOption(\Memcached::OPT_SERIALIZER);
269+
if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) {
270+
throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
271+
}
272+
if ('' !== $prefix = (string) $this->lazyClient->getOption(\Memcached::OPT_PREFIX_KEY)) {
273+
throw new CacheException(sprintf('MemcachedAdapter: "prefix_key" option must be empty when using proxified connections, "%s" given.', $prefix));
274+
}
275+
276+
return $this->client = $this->lazyClient;
277+
}
249278
}

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ trait PhpArrayTrait
2525
private $file;
2626
private $values;
2727
private $fallbackPool;
28+
private $zendDetectUnicode;
2829

2930
/**
3031
* Store an array of cached values.
@@ -106,7 +107,7 @@ public function warmUp(array $values)
106107

107108
@rename($tmpFile, $this->file);
108109

109-
$this->values = (include $this->file) ?: array();
110+
$this->initialize();
110111
}
111112

112113
/**
@@ -126,6 +127,15 @@ public function clear()
126127
*/
127128
private function initialize()
128129
{
129-
$this->values = file_exists($this->file) ? (include $this->file ?: array()) : array();
130+
if ($this->zendDetectUnicode) {
131+
$zmb = ini_set('zend.detect_unicode', 0);
132+
}
133+
try {
134+
$this->values = file_exists($this->file) ? (include $this->file ?: array()) : array();
135+
} finally {
136+
if ($this->zendDetectUnicode) {
137+
ini_set('zend.detect_unicode', $zmb);
138+
}
139+
}
130140
}
131141
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ trait PhpFilesTrait
2626
use FilesystemCommonTrait;
2727

2828
private $includeHandler;
29+
private $zendDetectUnicode;
2930

3031
public static function isSupported()
3132
{
@@ -69,6 +70,9 @@ protected function doFetch(array $ids)
6970
$values = array();
7071
$now = time();
7172

73+
if ($this->zendDetectUnicode) {
74+
$zmb = ini_set('zend.detect_unicode', 0);
75+
}
7276
set_error_handler($this->includeHandler);
7377
try {
7478
foreach ($ids as $id) {
@@ -84,6 +88,9 @@ protected function doFetch(array $ids)
8488
}
8589
} finally {
8690
restore_error_handler();
91+
if ($this->zendDetectUnicode) {
92+
ini_set('zend.detect_unicode', $zmb);
93+
}
8794
}
8895

8996
foreach ($values as $id => $value) {

0 commit comments

Comments
 (0)