Undefined array key uid and username in FrontendUserAuthentication
Patta opened this issue · 1 comments
Bug Report
Current Behavior
Undefined array key uid and username warnings if crawler is executed in cli or scheduler task like this vendor/bin/typo3 crawler:processQueue --amount 1000 --sleepafter 10 --sleeptime 1000
for every requested login protected page in queue. This blows up the logs.
Production warning log:
Fri, 12 May 2023 14:42:08 +0200 [WARNING] request="cd25b394a668a" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (BE): PHP Warning: Undefined array key "uid" in /var/www/vhosts/REMOVED/vendor/typo3/cms-frontend/Classes/Authentication/FrontendUserAuthentication.php line 286
Fri, 12 May 2023 14:42:08 +0200 [WARNING] request="cd25b394a668a" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (BE): PHP Warning: Undefined array key "username" in /var/www/vhosts/REMOVED/vendor/typo3/cms-frontend/Classes/Authentication/FrontendUserAuthentication.php line 287
Development warning log:
Fri, 12 May 2023 14:58:13 +0200 [CRITICAL] request="f3d2583f1f32e" component="TYPO3.CMS.Core.Error.DebugExceptionHandler": Core: Exception handler (WEB: BE): TYPO3\CMS\Core\Error\Exception, code #1476107295, file /var/www/html/vendor/typo3/cms-core/Classes/Error/ErrorHandler.php, line 137: PHP Warning: Undefined array key "uid" in /var/www/html/vendor/typo3/cms-frontend/Classes/Authentication/FrontendUserAuthentication.php line 286- Exception: PHP Warning: Undefined array key "uid" in /var/www/html/vendor/typo3/cms-frontend/Classes/Authentication/FrontendUserAuthentication.php line 286, in file /var/www/html/vendor/typo3/cms-core/Classes/Error/ErrorHandler.php:137 - {"mode":"WEB","application_mode":"BE","exception_class":"TYPO3\\CMS\\Core\\Error\\Exception","exception_code":1476107295,"file":"/var/www/html/vendor/typo3/cms-core/Classes/Error/ErrorHandler.php","line":137,"message":"PHP Warning: Undefined array key \"uid\" in /var/www/html/vendor/typo3/cms-frontend/Classes/Authentication/FrontendUserAuthentication.php line 286","request_url":"https://REMOVED.localhost/","exception":"TYPO3\\CMS\\Core\\Error\\Exception: PHP Warning: Undefined array key \"uid\" in /var/www/html/vendor/typo3/cms-frontend/Classes/Authentication/FrontendUserAuthentication.php line 286 in /var/www/html/vendor/typo3/cms-core/Classes/Error/ErrorHandler.php:137\nStack trace:\n#0 /var/www/html/vendor/typo3/cms-frontend/Classes/Authentication/FrontendUserAuthentication.php(286): TYPO3\\CMS\\Core\\Error\\ErrorHandler->handleError(2, 'Undefined array...', '/var/www/html/v...', 286)\n#1 /var/www/html/vendor/tomasnorre/crawler/Classes/Middleware/FrontendUserAuthenticator.php(130): TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication->fetchGroupData(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#2 /var/www/html/vendor/tomasnorre/crawler/Classes/Middleware/FrontendUserAuthenticator.php(94): AOE\\Crawler\\Middleware\\FrontendUserAuthenticator->getFrontendUser('491', Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#3 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): AOE\\Crawler\\Middleware\\FrontendUserAuthenticator->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#4 /var/www/html/vendor/typo3/cms-frontend/Classes/Middleware/SiteBaseRedirectResolver.php(94): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#5 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Frontend\\Middleware\\SiteBaseRedirectResolver->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#6 /var/www/html/vendor/typo3/cms-redirects/Classes/Http/Middleware/RedirectHandler.php(85): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#7 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Redirects\\Http\\Middleware\\RedirectHandler->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#8 /var/www/html/vendor/leuchtfeuer/secure-downloads/Classes/Middleware/FileDeliveryMiddleware.php(59): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#9 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): Leuchtfeuer\\SecureDownloads\\Middleware\\FileDeliveryMiddleware->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#10 /var/www/html/vendor/lochmueller/staticfilecache/Classes/Middleware/PrepareMiddleware.php(45): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#11 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): SFC\\Staticfilecache\\Middleware\\PrepareMiddleware->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#12 /var/www/html/vendor/lochmueller/staticfilecache/Classes/Middleware/GenerateMiddleware.php(47): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#13 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): SFC\\Staticfilecache\\Middleware\\GenerateMiddleware->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#14 /var/www/html/vendor/lochmueller/staticfilecache/Classes/Middleware/FrontendUserMiddleware.php(25): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#15 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): SFC\\Staticfilecache\\Middleware\\FrontendUserMiddleware->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#16 /var/www/html/vendor/typo3/cms-frontend/Classes/Middleware/FrontendUserAuthenticator.php(97): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#17 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Frontend\\Middleware\\FrontendUserAuthenticator->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#18 /var/www/html/vendor/typo3/cms-frontend/Classes/Middleware/BackendUserAuthenticator.php(78): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#19 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Frontend\\Middleware\\BackendUserAuthenticator->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#20 /var/www/html/vendor/typo3/cms-frontend/Classes/Middleware/MaintenanceMode.php(55): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#21 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Frontend\\Middleware\\MaintenanceMode->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#22 /var/www/html/vendor/typo3/cms-frontend/Classes/Middleware/SiteResolver.php(65): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#23 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Frontend\\Middleware\\SiteResolver->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#24 /var/www/html/vendor/typo3/cms-frontend/Classes/Middleware/EidHandler.php(64): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#25 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Frontend\\Middleware\\EidHandler->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#26 /var/www/html/vendor/typo3/cms-core/Classes/Middleware/NormalizedParamsAttribute.php(45): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#27 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Core\\Middleware\\NormalizedParamsAttribute->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#28 /var/www/html/vendor/typo3/cms-core/Classes/Middleware/VerifyHostHeader.php(55): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#29 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Core\\Middleware\\VerifyHostHeader->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#30 /var/www/html/vendor/typo3/cms-frontend/Classes/Middleware/TimeTrackerInitialization.php(58): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#31 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): TYPO3\\CMS\\Frontend\\Middleware\\TimeTrackerInitialization->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#32 /var/www/html/vendor/lochmueller/staticfilecache/Classes/Middleware/FallbackMiddleware.php(49): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#33 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(172): SFC\\Staticfilecache\\Middleware\\FallbackMiddleware->process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(Psr\\Http\\Server\\RequestHandlerInterface@anonymous))\n#34 /var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php(78): Psr\\Http\\Server\\RequestHandlerInterface@anonymous->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#35 /var/www/html/vendor/typo3/cms-core/Classes/Http/AbstractApplication.php(86): TYPO3\\CMS\\Core\\Http\\MiddlewareDispatcher->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#36 /var/www/html/vendor/typo3/cms-frontend/Classes/Http/Application.php(69): TYPO3\\CMS\\Core\\Http\\AbstractApplication->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#37 /var/www/html/vendor/typo3/cms-core/Classes/Http/AbstractApplication.php(100): TYPO3\\CMS\\Frontend\\Http\\Application->handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#38 /var/www/html/public/index.php(20): TYPO3\\CMS\\Core\\Http\\AbstractApplication->run()\n#39 /var/www/html/public/index.php(21): {closure}()\n#40 {main}"}
Expected behavior/output
Crawler processes queue without errors.
Steps to reproduce
- Setup below environment, typo3 site with frontend user groups, users, login protected pages and public pages.
- Add pages to queue with scheduler task or cli command:
vendor/bin/typo3 crawler:buildQueue 10844 config1,config2 --depth 5 --mode queue
- config1 = no frontend user groups selected in crawler config (public pages)
- config2 = forntend user groups selected in crawler config (private protected pages)
- Process queue with scheduler task or cli command:
vendor/bin/typo3 crawler:processQueue --amount 1000 --sleepafter 10 --sleeptime 1000
- Open typo3-warning.log or watch log while crawler is processing queue
Environment
- Crawler version(s): 11.0.7
- TYPO3 version(s): 11.5.27
- Is your TYPO3 installation set up with Composer (Composer Mode): yes
- PHP: 8.1.18
Possible Solution
Thought is an core issue and added this first to typo3 forge: https://forge.typo3.org/issues/100864
Markus Klein wrote:
The problem is rather rooted here:
https://github.com/tomasnorre/crawler/blob/main/Classes/Middleware/FrontendUserAuthenticator.php#L123
This is insufficient initialization.
Please open a bug-report there.
Closed as merged. Thanks for your PR @Patta