8000 bug #24809 [Config] Fix dump of config references for deprecated node… · symfony/symfony@e973c24 · GitHub
[go: up one dir, main page]

Skip to content

Commit e973c24

Browse files
committed
bug #24809 [Config] Fix dump of config references for deprecated nodes (chalasr)
This PR was merged into the 3.4 branch. Discussion ---------- [Config] Fix dump of config references for deprecated nodes | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a ```yaml # before trusted_proxies: [] # Deprecated (The "framework.trusted_proxies.trusted_proxies" configuration key has been deprecated in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.) #after trusted_proxies: [] # Deprecated (The "framework.trusted_proxies" configuration key has been deprecated in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.) ``` Commits ------- 188eb34 Fix reference dump for deprecated nodes
2 parents 107881f + 188eb34 commit e973c24

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name
154154
}
155155

156156
if ($child->isDeprecated()) {
157-
$comments[] = sprintf('Deprecated (%s)', $child->getDeprecationMessage($child->getName(), $child->getPath()));
157+
$comments[] = sprintf('Deprecated (%s)', $child->getDeprecationMessage($child->getName(), $node->getPath()));
158158
}
159159

160160
if ($child instanceof EnumNode) {

src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ public function dumpNode(NodeInterface $node)
7070
}
7171

7272
/**
73-
* @param NodeInterface $node
74-
* @param int $depth
75-
* @param bool $prototypedArray
73+
* @param NodeInterface $node
74+
* @param NodeInterface|null $parentNode
75+
* @param int $depth
76+
* @param bool $prototypedArray
7677
*/
77-
private function writeNode(NodeInterface $node, $depth = 0, $prototypedArray = false)
78+
private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, $depth = 0, $prototypedArray = false)
7879
{
7980
$comments = array();
8081
$default = '';
@@ -125,7 +126,7 @@ private function writeNode(NodeInterface $node, $depth = 0, $prototypedArray = f
125126

126127
// deprecated?
127128
if ($node->isDeprecated()) {
128-
$comments[] = sprintf('Deprecated (%s)', $node->getDeprecationMessage($node->getName(), $node->getPath()));
129+
$comments[] = sprintf('Deprecated (%s)', $node->getDeprecationMessage($node->getName(), $parentNode ? $parentNode->getPath() : $node->getPath()));
129130
}
130131

131132
// example
@@ -171,7 +172,7 @@ private function writeNode(NodeInterface $node, $depth = 0, $prototypedArray = f
171172

172173
if ($children) {
173174
foreach ($children as $childNode) {
174-
$this->writeNode($childNode, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute());
175+
$this->writeNode($childNode, $node, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute());
175176
}
176177
}
177178
}

src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ private function getConfigurationAsString()
3838
return str_replace("\n", PHP_EOL, <<<'EOL'
3939
<!-- Namespace: http://example.org/schema/dic/acme_root -->
4040
<!-- scalar-required: Required -->
41-
<!-- scalar-deprecated: Deprecated (The child node "scalar_deprecated" at path "acme_root.scalar_deprecated" is deprecated.) -->
42-
<!-- scalar-deprecated-with-message: Deprecated (Deprecation custom message for "scalar_deprecated_with_message" at "acme_root.scalar_deprecated_with_message") -->
41+
<!-- scalar-deprecated: Deprecated (The child node "scalar_deprecated" at path "acme_root" is deprecated.) -->
42+
<!-- scalar-deprecated-with-message: Deprecated (Deprecation custom message for "scalar_deprecated_with_message" at "acme_root") -->
4343
<!-- enum-with-default: One of "this"; "that" -->
4444
<!-- enum: One of "this"; "that" -->
4545
<config

src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ private function getConfigurationAsString()
9898
- elem1
9999
- elem2
100100
scalar_required: ~ # Required
101-
scalar_deprecated: ~ # Deprecated (The child node "scalar_deprecated" at path "acme_root.scalar_deprecated" is deprecated.)
102-
scalar_deprecated_with_message: ~ # Deprecated (Deprecation custom message for "scalar_deprecated_with_message" at "acme_root.scalar_deprecated_with_message")
101+
scalar_deprecated: ~ # Deprecated (The child node "scalar_deprecated" at path "acme_root" is deprecated.)
102+
scalar_deprecated_with_message: ~ # Deprecated (Deprecation custom message for "scalar_deprecated_with_message" at "acme_root")
103103
node_with_a_looong_name: ~
104104
enum_with_default: this # One of "this"; "that"
105105
enum: ~ # One of "this"; "that"

0 commit comments

Comments
 (0)
0