Skip to content

Commit

Permalink
[BUGFIX] Check queueRec before usage to avoid PHP errors (#1078)
Browse files Browse the repository at this point in the history
Resolves #1031 #backport
  • Loading branch information
tomasnorre authored Jun 10, 2024
1 parent db27249 commit 670b2ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog TYPO3 Crawler

## Crawler 11.0.10-dev

### Fixed

* Check queueRec before usages to avoid php-errors

## Crawler 11.0.9

Crawler 11.0.9 was released on May 30th, 2024
Expand Down
6 changes: 5 additions & 1 deletion Classes/Middleware/FrontendUserAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$queueRec = $this->findByQueueId($queueId);

// If a crawler record was found and hash was matching, set it up
if (! $this->isRequestHashMatchingQueueRecord($queueRec, $hash)) {
if (!$this->isRequestHashMatchingQueueRecord($queueRec, $hash)) {
return GeneralUtility::makeInstance(ErrorController::class)->unavailableAction($request, 'No crawler entry found');
}

Expand Down Expand Up @@ -116,6 +116,10 @@ public function getContext(): Context

protected function isRequestHashMatchingQueueRecord(?array $queueRec, string $hash): bool
{
if ($queueRec === null || !array_key_exists('qid', $queueRec) || !array_key_exists('set_id', $queueRec)) {
return false;
}

return is_array($queueRec) && hash_equals($hash, md5($queueRec['qid'] . '|' . $queueRec['set_id'] . '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']));
}

Expand Down

0 comments on commit 670b2ec

Please sign in to comment.