@@ -404,7 +404,36 @@ 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
+ $ allowedInvalidElements = [];
408
+ $ errors = explode ("\n" , $ e ->getMessage ());
409
+ foreach ($ errors as $ error ) {
410
+ if (preg_match ("#^\[ERROR 1871] Element '\{http://symfony\.com/schema/dic/security}([^']+)'# " , $ error , $ matches )) {
411
+ $ allowedInvalidElements [] = $ matches [1 ];
412
+ }
413
+ }
414
+ if ($ allowedInvalidElements ) {
415
+ $ dom = XmlUtils::loadFile ($ file );
416
+
417
+ $ allowedInvalidElements = array_filter (
418
+ $ allowedInvalidElements ,
419
+ static function (string $ tagName ) use ($ dom ): bool {
420
+ foreach ($ dom ->getElementsByTagName ($ tagName ) as $ element ) {
421
+ if (!$ parent = $ element ->parentElement ) {
422
+ return false ;
423
+ }
424
+ if ('provider ' === $ parent ->tagName || 'firewall ' === $ parent ->tagName ) {
425
+ 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 );
426
+
427
+ return true ;
428
+ }
429
+ }
430
+ return false ;
431
+ }
432
+ );
433
+ }
434
+ if (\count ($ allowedInvalidElements ) !== \count ($ errors )) {
435
+ throw new InvalidArgumentException (sprintf ('Unable to parse file "%s": ' , $ file ) . $ e ->getMessage (), $ e ->getCode (), $ e );
436
+ }
408
437
}
409
438
410
439
$ this ->validateExtensions ($ dom , $ file );
0 commit comments