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

Skip to content

Commit b6bbe43

Browse files
Merge branch '3.1'
* 3.1: [TwigBundle] Removed redundant return statement. enable property info [Cache] Fix default lifetime being ignored [DependencyInjection] Fixed deprecated default message template with XML Reference the actual location of the documentation [TwigBridge] Removed extra arguments in 2 places. [Cache] Fix incorrect timestamps generated by FilesystemAdapter [Process] Fix write access check for pipes on Windows [HttpKernel] Use flock() for HttpCache's lock files Conflicts: src/Symfony/Component/Cache/Adapter/FilesystemAdapter.php
2 parents c7fa99e + 75ebbf8 commit b6bbe43

File tree

28 files changed

+206
-90
lines changed

28 files changed

+206
-90
lines changed

src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Twig\Extension;
1313

14-
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1514
use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;
1615

1716
/**
@@ -48,7 +47,7 @@ public function getFunctions()
4847
*/
4948
public function getLogoutPath($key = null)
5049
{
51-
return $this->generator->getLogoutPath($key, UrlGeneratorInterface::ABSOLUTE_PATH);
50+
return $this->generator->getLogoutPath($key);
5251
}
5352

5453
/**
@@ -60,7 +59,7 @@ public function getLogoutPath($key = null)
6059
*/
6160
public function getLogoutUrl($key = null)
6261
{
63-
return $this->generator->getLogoutUrl($key, UrlGeneratorInterface::ABSOLUTE_URL);
62+
return $this->generator->getLogoutUrl($key);
6463
}
6564

6665
/**

src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<argument type="service" id="serializer.mapping.class_metadata_factory" />
2222
<argument>null</argument> <!-- name converter -->
2323
<argument type="service" id="serializer.property_accessor" />
24+
<argument type="service" id="property_info" on-invalid="ignore" />
2425

2526
<!-- Run after all custom serializers -->
2627
<tag name="serializer.normalizer" priority="-1000" />

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
'enable_annotations' => true,
6969
'name_converter' => 'serializer.name_converter.camel_case_to_snake_case',
7070
),
71+
'property_info' => true,
7172
'ide' => 'file%%link%%format',
7273
'request' => array(
7374
'formats' => array(

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@
4141
<framework:validation enabled="true" cache="validator.mapping.cache.doctrine.apc" />
4242
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
4343
<framework:serializer enabled="true" enable-annotations="true" name-converter="serializer.name_converter.camel_case_to_snake_case" />
44+
<framework:property-info />
4445
</framework:config>
4546
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ framework:
5353
enabled: true
5454
enable_annotations: true
5555
name_converter: serializer.name_converter.camel_case_to_snake_case
56+
property_info: ~
5657
ide: file%%link%%format
5758
request:
5859
formats:

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ public function testSerializerEnabled()
469469
$this->assertEquals('Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader', $argument[0]->getClass());
470470
$this->assertNull($container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1));
471471
$this->assertEquals(new Reference('serializer.name_converter.camel_case_to_snake_case'), $container->getDefinition('serializer.normalizer.object')->getArgument(1));
472+
$this->assertEquals(new Reference('property_info', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE), $container->getDefinition('serializer.normalizer.object')->getArgument(3));
472473
}
473474

474475
public function testRegisterSerializerExtractor()

src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testExists()
4848
;
4949
$loader = new FilesystemLoader($locator, $parser);
5050

51-
return $this->assertTrue($loader->exists($template));
51+
$this->assertTrue($loader->exists($template));
5252
}
5353

5454
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function ($deferred, $namespace, &$expiredIds) {
5656

5757
foreach ($deferred as $key => $item) {
5858
if (null === $item->expiry) {
59-
$byLifetime[0][$namespace.$key] = $item->value;
59+
$byLifetime[0 < $item->defaultLifetime ? $item->defaultLifetime : 0][$namespace.$key] = $item->value;
6060
} elseif ($item->expiry > $now) {
6161
$byLifetime[$item->expiry - $now][$namespace.$key] = $item->value;
6262
} else {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ public function save(CacheItemInterface $item)
151151
return false;
152152
}
153153
}
154+
if (null === $expiry && 0 < $item["\0*\0defaultLifetime"]) {
155+
$expiry = time() + $item["\0*\0defaultLifetime"];
156+
}
154157

155158
$this->values[$key] = $value;
156159
$this->expiries[$key] = null !== $expiry ? $expiry : PHP_INT_MAX;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected function doHave($id)
7171
protected function doSave(array $values, $lifetime)
7272
{
7373
$ok = true;
74-
$expiresAt = $lifetime ? time() + $lifetime : PHP_INT_MAX;
74+
$expiresAt = time() + ($lifetime ?: 31557600); // 31557600s = 1 year
7575

7676
foreach ($values as $id => $value) {
7777
$ok = $this->write($this->getFile($id, true), $expiresAt."\n".rawurlencode($id)."\n".serialize($value), $expiresAt) && $ok;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ private function doSave(CacheItemInterface $item, $method)
144144
}
145145
$item = (array) $item;
146146
$expiry = $item["\0*\0expiry"];
147+
if (null === $expiry && 0 < $item["\0*\0defaultLifetime"]) {
148+
$expiry = time() + $item["\0*\0defaultLifetime"];
149+
}
147150
$innerItem = $item["\0*\0poolHash"] === $this->poolHash ? $item["\0*\0innerItem"] : $this->pool->getItem($this->namespace.$item["\0*\0key"]);
148151
$innerItem->set($item["\0*\0value"]);
149152
$innerItem->expiresAt(null !== $expiry ? \DateTime::createFromFormat('U', $expiry) : null);

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@
1111

1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

14-
use Cache\IntegrationTests\CachePoolTest;
1514
use Symfony\Component\Cache\Adapter\RedisAdapter;
1615

17-
abstract class AbstractRedisAdapterTest extends CachePoolTest
16+
abstract class AbstractRedisAdapterTest extends AdapterTestCase
1817
{
1918
protected static $redis;
2019

21-
public function createCachePool()
20+
public function createCachePool($defaultLifetime = 0)
2221
{
2322
if (defined('HHVM_VERSION')) {
2423
$this->skippedTests['testDeferredSaveWithoutCommit'] = 'Fails on HHVM';
2524
}
2625

27-
return new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__));
26+
return new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
2827
}
2928

3029
public static function setupBeforeClass()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
use Cache\IntegrationTests\CachePoolTest;
15+
16+
abstract class AdapterTestCase extends CachePoolTest
17+
{
18+
public function testDefaultLifeTime()
19+
{
20+
if (isset($this->skippedTests[__FUNCTION__])) {
21+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
22+
23+
return;
24+
}
25+
26+
$this->cache = $this->createCachePool(2);
27+
28+
$item = $this->cache->getItem('key.dlt');
29+
$item->set('value');
30+
$this->cache->save($item);
31+
sleep(1);
32+
33+
$item = $this->cache->getItem('key.dlt');
34+
$this->assertTrue($item->isHit());
35+
36+
sleep(2);
37+
$item = $this->cache->getItem('key.dlt');
38+
$this->assertFalse($item->isHit());
39+
}
40+
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111

1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

14-
use Cache\IntegrationTests\CachePoolTest;
1514
use Symfony\Component\Cache\Adapter\ApcuAdapter;
1615

17-
class ApcuAdapterTest extends CachePoolTest
16+
class ApcuAdapterTest extends AdapterTestCase
1817
{
19-
public function createCachePool()
18+
public function createCachePool($defaultLifetime = 0)
2019
{
2120
if (defined('HHVM_VERSION')) {
2221
$this->skippedTests['testDeferredSaveWithoutCommit'] = 'Fails on HHVM';
@@ -28,7 +27,7 @@ public function createCachePool()
2827
$this->markTestSkipped('Fails transiently on Windows.');
2928
}
3029

31-
return new ApcuAdapter(str_replace('\\', '.', __CLASS__));
30+
return new ApcuAdapter(str_replace('\\', '.', __CLASS__), $defaultLifetime);
3231
}
3332

3433
public function testUnserializable()

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@
1111

1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

14-
use Cache\IntegrationTests\CachePoolTest;
1514
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1615

1716
/**
1817
* @group time-sensitive
1918
*/
20-
class ArrayAdapterTest extends CachePoolTest
19+
class ArrayAdapterTest extends AdapterTestCase
2120
{
2221
protected $skippedTests = array(
2322
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.',
2423
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.',
2524
);
2625

27-
public function createCachePool()
26+
public function createCachePool($defaultLifetime = 0)
2827
{
29-
return new ArrayAdapter();
28+
return new ArrayAdapter($defaultLifetime);
3029
}
3130
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

14-
use Cache\IntegrationTests\CachePoolTest;
1514
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
1615
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1716
use Symfony\Component\Cache\Adapter\ChainAdapter;
@@ -20,15 +19,15 @@
2019
/**
2120
* @author Kévin Dunglas <dunglas@gmail.com>
2221
*/
23-
class ChainAdapterTest extends CachePoolTest
22+
class ChainAdapterTest extends AdapterTestCase
2423
{
25-
public function createCachePool()
24+
public function createCachePool($defaultLifetime = 0)
2625
{
2726
if (defined('HHVM_VERSION')) {
2827
$this->skippedTests['testDeferredSaveWithoutCommit'] = 'Fails on HHVM';
2928
}
3029

31-
return new ChainAdapter(array(new ArrayAdapter(), new ExternalAdapter(), new FilesystemAdapter()));
30+
return new ChainAdapter(array(new ArrayAdapter($defaultLifetime), new ExternalAdapter(), new FilesystemAdapter('', $defaultLifetime)), $defaultLifetime);
3231
}
3332

3433
/**

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@
1111

1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

14-
use Cache\IntegrationTests\CachePoolTest;
1514
use Doctrine\Common\Cache\ArrayCache;
1615
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
1716

1817
/**
1918
* @group time-sensitive
2019
*/
21-
class DoctrineAdapterTest extends CachePoolTest
20+
class DoctrineAdapterTest extends AdapterTestCase
2221
{
2322
protected $skippedTests = array(
2423
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayCache is not.',
2524
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayCache is not.',
2625
);
2726

28-
public function createCachePool()
27+
public function createCachePool($defaultLifetime = 0)
2928
{
30-
return new DoctrineAdapter(new ArrayCache());
29+
return new DoctrineAdapter(new ArrayCache(), '', $defaultLifetime);
3130
}
3231
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@
1111

1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

14-
use Cache\IntegrationTests\CachePoolTest;
1514
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
1615

1716
/**
1817
* @group time-sensitive
1918
*/
20-
class FilesystemAdapterTest extends CachePoolTest
19+
class FilesystemAdapterTest extends AdapterTestCase
2120
{
22-
public function createCachePool()
21+
public function createCachePool($defaultLifetime = 0)
2322
{
2423
if (defined('HHVM_VERSION')) {
2524
$this->skippedTests['testDeferredSaveWithoutCommit'] = 'Fails on HHVM';
2625
}
2726

28-
return new FilesystemAdapter('sf-cache');
27+
return new FilesystemAdapter('', $defaultLifetime);
2928
}
3029

3130
public static function tearDownAfterClass()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
class NamespacedProxyAdapterTest extends ProxyAdapterTest
2121
{
22-
public function createCachePool()
22+
public function createCachePool($defaultLifetime = 0)
2323
{
24-
return new ProxyAdapter(new ArrayAdapter(), 'foo');
24+
return new ProxyAdapter(new ArrayAdapter(), 'foo', $defaultLifetime);
2525
}
2626
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

14-
use Cache\IntegrationTests\CachePoolTest;
1514
use Psr\Cache\CacheItemInterface;
1615
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1716
use Symfony\Component\Cache\Adapter\ProxyAdapter;
@@ -20,16 +19,16 @@
2019
/**
2120
* @group time-sensitive
2221
*/
23-
class ProxyAdapterTest extends CachePoolTest
22+
class ProxyAdapterTest extends AdapterTestCase
2423
{
2524
protected $skippedTests = array(
2625
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.',
2726
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.',
2827
);
2928

30-
public function createCachePool()
29+
public function createCachePool($defaultLifetime = 0)
3130
{
32-
return new ProxyAdapter(new ArrayAdapter());
31+
return new ProxyAdapter(new ArrayAdapter(), '', $defaultLifetime);
3332
}
3433

3534
/**

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private function parseDefinition(\DOMElement $service, $file)
166166
}
167167

168168
if ($deprecated = $this->getChildren($service, 'deprecated')) {
169-
$definition->setDeprecated(true, $deprecated[0]->nodeValue);
169+
$definition->setDeprecated(true, $deprecated[0]->nodeValue ?: null);
170170
}
171171

172172
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
3+
<services>
4+
<service id="foo" class="Foo">
5+
<deprecated />
6+
</service>
7+
<service id="bar" class="Bar">
8+
<deprecated>The "%service_id%" service is deprecated.</deprecated>
9+
</service>
10+
</services>
11+
</container>

src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,21 @@ public function testParseTagWithEmptyNameThrowsException()
302302
$loader->load('tag_with_empty_name.xml');
303303
}
304304

305+
public function testDeprecated()
306+
{
307+
$container = new ContainerBuilder();
308+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
309+
$loader->load('services_deprecated.xml');
310+
311+
$this->assertTrue($container->getDefinition('foo')->isDeprecated());
312+
$message = 'The "foo" service is deprecated. You should stop using it, as it will soon be removed.';
313+
$this->assertSame($message, $container->getDefinition('foo')->getDeprecationMessage('foo'));
314+
315+
$this->assertTrue($container->getDefinition('bar')->isDeprecated());
316+
$message = 'The "bar" service is deprecated.';
317+
$this->assertSame($message, $container->getDefinition('bar')->getDeprecationMessage('bar'));
318+
}
319+
305320
public function testConvertDomElementToArray()
306321
{
307322
$doc = new \DOMDocument('1.0');

0 commit comments

Comments
 (0)
0