Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit db3f554

Browse filesBrowse files
committed
bug #19439 [DependencyInjection] Fixed deprecated default message template with XML (jeremyFreeAgent)
This PR was merged into the 2.8 branch. Discussion ---------- [DependencyInjection] Fixed deprecated default message template with XML | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 165529b [DependencyInjection] Fixed deprecated default message template with XML
2 parents af47008 + 165529b commit db3f554
Copy full SHA for db3f554

File tree

3 files changed

+27
-1
lines changed
Filter options

3 files changed

+27
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private function parseDefinition(\DOMElement $service, $file)
187187
}
188188

189189
if ($deprecated = $this->getChildren($service, 'deprecated')) {
190-
$definition->setDeprecated(true, $deprecated[0]->nodeValue);
190+
$definition->setDeprecated(true, $deprecated[0]->nodeValue ?: null);
191191
}
192192

193193
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));
+11Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,21 @@ public function testParseTagWithEmptyNameThrowsException()
324324
$loader->load('tag_with_empty_name.xml');
325325
}
326326

327+
public function testDeprecated()
328+
{
329+
$container = new ContainerBuilder();
330+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
331+
$loader->load('services_deprecated.xml');
332+
333+
$this->assertTrue($container->getDefinition('foo')->isDeprecated());
334+
$message = 'The "foo" service is deprecated. You should stop using it, as it will soon be removed.';
335+
$this->assertSame($message, $container->getDefinition('foo')->getDeprecationMessage('foo'));
336+
337+
$this->assertTrue($container->getDefinition('bar')->isDeprecated());
338+
$message = 'The "bar" service is deprecated.';
339+
$this->assertSame($message, $container->getDefinition('bar')->getDeprecationMessage('bar'));
340+
}
341+
327342
public function testConvertDomElementToArray()
328343
{
329344
$doc = new \DOMDocument('1.0');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.