Skip to content

Commit 5bb4fe3

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 d0d673c + 6abd495 commit 5bb4fe3

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

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>

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)