8000 bug #26183 [DI] Add null check for removeChild (changmin.keum) · symfony/symfony@b271683 · GitHub
[go: up one dir, main page]

Skip to content

Commit b271683

Browse files
com 8000 mitted
bug #26183 [DI] Add null check for removeChild (changmin.keum)
This PR was submitted for the 2.8 branch but it was merged into the 2.7 branch instead (closes #26183). Discussion ---------- [DI] Add null check for removeChild | 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 | I'm using Symfony 2.8 and PHP Fatal error occurs very rarely when I do assetic:dump / cache:warmup as below.(also on Symfony 2.7) ` PHP Fatal error: Call to a member function removeChild() on null in .../symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php on line 350 ` It does occur very rarely. Also, after several retries, it works fine. The xml file which triggers error is as below(both version) and I didn't modify anything. https://github.com/symfony/swiftmailer-bundle/blob/v2.3.8/Resources/config/swiftmailer.xml https://github.com/symfony/swiftmailer-bundle/blob/v2.6.7/Resources/config/swiftmailer.xml Once more, error occurs so randomly. So, I can't be sure in what situation it occurs. But this modification does fix the problem and no side effect. Commits ------- a5f05a0 [DI] Add null check for removeChild
2 parents 2bccaaa + a5f05a0 commit b271683

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ private function processAnonymousServices(\DOMDocument $xml, $file)
324324
$domElement->parentNode->replaceChild($tmpDomElement, $domElement);
325325
$tmpDomElement->setAttribute('id', $id);
326326
} else {
327-
$domElement->parentNode->removeChild($domElement);
327+
if (null !== $domElement->parentNode) {
328+
$domElement->parentNode->removeChild($domElement);
329+
}
328330
}
329331
}
330332
}

0 commit comments

Comments
 (0)
0