crawler icon indicating copy to clipboard operation
crawler copied to clipboard

php 8 warnings in FrontendUserAuthenticator

Open lisardo2 opened this issue 1 year ago • 4 comments

Bug Report

Current Behavior Thausends of warnings in the TYPO3 log (typical php 8 warning of missing array key): Core: Error handler (BE): PHP Warning: Undefined array key "set_id" in /srv/www/htdocs/stmwi.bayern.www/apps/stmwi_bayern/typo3-stmwi-hhp-v11/public/typo3conf/ext/crawler/Classes/Middleware/FrontendUserAuthenticator.php line 119 and: Core: Error handler (BE): PHP Warning: Undefined array key "set_id" in /srv/www/htdocs/stmwi.bayern.www/apps/stmwi_bayern/typo3-stmwi-hhp-v11/public/typo3conf/ext/crawler/Classes/Middleware/FrontendUserAuthenticator.php line 119

Expected behavior/output No Warning

Steps to reproduce It is easy to see in the code:

protected function isRequestHashMatchingQueueRecord(?array $queueRec, string $hash): bool
{
    return is_array($queueRec) && hash_equals($hash, md5($queueRec['qid'] . '|' . $queueRec['set_id'] . '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']));
}

$queueRec['qid'] and $queueRec['set_id'] aren`t secured against this kind of error. If the keys are missing the warning will be thrown.

Environment

  • Crawler version(s): [11.0.7]
  • TYPO3 version(s): [11.5.36]
  • Is your TYPO3 installation set up with Composer (Composer Mode): [yes]
  • php 8.0

Possible Solution

Additional context Add any additional context, are you using indexed_search etc.

lisardo2 avatar Mar 07 '24 08:03 lisardo2

Hi there, thank you for taking your time to create your first issue. Please give us a bit of time to review it.

github-actions[bot] avatar Mar 07 '24 08:03 github-actions[bot]

Thanks for your report. I thought we had caught all these already. But will have to check it again.

It would be great if you could provide a PR, at least for the case reported here.

Please be aware that two branches are currently maintained. v11.x and main, which needs a PR each.

tomasnorre avatar Mar 07 '24 08:03 tomasnorre

Which TYPO3 Log do you mean ? The Log Module in TYPO3 Backend? Or a file written on disk?

Which steps do I need to do to reproduce this?

tomasnorre avatar May 22 '24 16:05 tomasnorre

I can confirm these PHP warnings in a TYPO3 v11 instance. The warnings appear in the backend log module and in the configured warning log file. For me, this warning only occurs after a "No crawler entry found" exception, which sometimes appears, but not usually.

typo3-warning.log:

Thu, 23 May 2024 12:12:49 +0200 [CRITICAL] request="0d01884c37155" component="TYPO3.CMS.Core.Error.ProductionExceptionHandler": Core: Exception handler (WEB: BE): TYPO3\CMS\Core\Error\Http\ServiceUnavailableException, code #1518472181, file /var/www/vhosts/REMOVED/vendor/typo3/cms-frontend/Classes/Controller/ErrorController.php, line 75: No crawler entry found - {"mode":"WEB","application_mode":"BE","exception_class":"TYPO3\\CMS\\Core\\Error\\Http\\ServiceUnavailableException","exception_code":1518472181,"file":"/var/www/vhosts/REMOVED/vendor/typo3/cms-frontend/Classes/Controller/ErrorController.php","line":75,"message":"No crawler entry found","request_url":"REMOVED/REMOVED/","exception":null}
Thu, 23 May 2024 12:12:49 +0200 [WARNING] request="b41011cf9116b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (BE): PHP Warning: Undefined array key "qid" in /var/www/vhosts/REMOVED/vendor/tomasnorre/crawler/Classes/Middleware/FrontendUserAuthenticator.php line 119 
Thu, 23 May 2024 12:12:49 +0200 [WARNING] request="b41011cf9116b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (BE): PHP Warning: Undefined array key "set_id" in /var/www/vhosts/REMOVED/vendor/tomasnorre/crawler/Classes/Middleware/FrontendUserAuthenticator.php line 119 

Patta avatar May 24 '24 08:05 Patta

Could one of you @lisardo2 or @Patta be so kind and test this PR? https://github.com/tomasnorre/crawler/pull/1073

The fix should work for both v11.x and v12.x (dev-main) branches.

tomasnorre avatar May 30 '24 09:05 tomasnorre

According to my own testing, this is solving the problem. Please confirm.

tomasnorre avatar May 31 '24 18:05 tomasnorre

@zenoussi Would you mind testing this, as it's probably the solution to your problem too in #1021 which I closed earlier as duplicated.

tomasnorre avatar May 31 '24 18:05 tomasnorre

@tomasnorre would be great if you could release this fix also for v11 and TYPO3 v11. Thanks!

Patta avatar Jul 03 '24 10:07 Patta

Sorry @Patta thought i had done that already. I'll add it to my todo. Hope to get in done in the next days.

tomasnorre avatar Jul 03 '24 17:07 tomasnorre

This is now released https://packagist.org/packages/tomasnorre/crawler#11.0.10

tomasnorre avatar Jul 04 '24 18:07 tomasnorre