@@ -404,7 +404,32 @@ 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 ->getElementsByTagName ($ tagName ) as $ element ) {
419
+ if (!$ parent = $ element ->parentElement ) {
420
+ continue ;
421
+ }
422
+ if ('provider ' === $ parent ->tagName || 'firewall ' === $ parent ->tagName ) {
423
+ trigger_deprecation ('symfony/security-bundle ' , '5.4.41 ' , 'Third-party %s must now be namespaced; please update your security configuration "%s" tag. ' , 'provider ' === $ parent ->tagName ? 'providers ' : 'authenticators ' , $ tagName );
424
+
425
+ unset($ errors [$ errorIndex ]);
426
+ }
427
+ }
428
+ }
429
+ }
430
+ if ($ errors ) {
431
+ throw new InvalidArgumentException (sprintf ('Unable to parse file "%s": ' , $ file ) . implode ("/n " , $ errors ), $ e ->getCode (), $ e );
432
+ }
408
433
}
409
434
410
435
$ this ->validateExtensions ($ dom , $ file );
0 commit comments