@@ -404,7 +404,33 @@ private function parseFileToDOM(string $file): \DOMDocument
404
404
try {
405
405
$ dom = XmlUtils::loadFile ($ file , [$ this , 'validateSchema ' ]);
406
406
} catch (\InvalidArgumentException $ e ) {
407
- throw new InvalidArgumentException (sprintf ('Unable to parse file "%s": ' , $ file ).$ e ->getMessage (), $ e ->getCode (), $ e );
407
+ $ invalidSecurityElements = [];
408
+ $ errors = explode ("\n" , $ e ->getMessage ());
409
+ foreach ($ errors as $ i => $ error ) {
410
+ if (preg_match ("#^\[ERROR 1871] Element '\{http://symfony\.com/schema/dic/security}([^']+)'# " , $ error , $ matches )) {
411
+ $ invalidSecurityElements [$ i ] = $ matches [1 ];
412
+ }
413
+ }
414
+ if ($ invalidSecurityElements ) {
415
+ $ dom = XmlUtils::loadFile ($ file );
416
+
417
+ foreach ($ invalidSecurityElements as $ errorIndex => $ tagName ) {
418
+ foreach ($ dom ->getElementsByTagNameNS ('http://symfony.com/schema/dic/security ' , $ tagName ) as $ element ) {
419
+ if (!$ parent = $ element ->parentNode ) {
420
+ continue ;
421
+ }
422
+ if ('http://symfony.com/schema/dic/security ' !== $ parent ->namespaceURI ) {
423
+ continue ;
424
+ }
425
+ if ('provider ' === $ parent ->localName || 'firewall ' === $ parent ->localName ) {
426
+ unset($ errors [$ errorIndex ]);
427
+ }
428
+ }
429
+ }
430
+ }
431
+ if ($ errors ) {
432
+ throw new InvalidArgumentException (sprintf ('Unable to parse file "%s": ' , $ file ).implode ("/n " , $ errors ), $ e ->getCode (), $ e );
433
+ }
408
434
}
409
435
410
436
$ this ->validateExtensions ($ dom , $ file );
@@ -777,6 +803,6 @@ private function loadFromExtensions(\DOMDocument $xml)
777
803
*/
778
804
public static function convertDomElementToArray (\DOMElement $ element )
779
805
{
780
- return XmlUtils::convertDomElementToArray ($ element );
806
+ return XmlUtils::convertDomElementToArray ($ element, false );
781
807
}
782
808
}
0 commit comments