Skip to content

[BUG] Request object may be null in EnrichHashBase hook #96

@fsuter

Description

@fsuter

TYPO3 version

12.4.19

PHP version

8.2.22

Extension version

3.0.2

Composer mode

  • I'm running TYPO3 in composer mode.

Operating system

Linux 3.10.0 / MacOS 14.6.1

Current behavior

I have an installation with both "solr" and "t3api". I have a number of tables exposed with the API provided by "t3api", which are also indexed with "solr". The indexing task of "solr" crashes because of the \SourceBroker\T3api\Hook\EnrichHashBase hook which is called when "solr" initializes a TSFE during indexing. The hook tries to get the TYPO3 request object using \SourceBroker\T3api\Service\RouteService::getRequest() which just returns $GLOBALS['TYPO3_REQUEST']. However this method does not expect the request object to be null, which it is in this particular context.

This is a change of behaviour induced by the following commit: c36be25

Expected behavior

\SourceBroker\T3api\Service\RouteService::getRequest() should allow for the request object to be null.

The simple solution is to change the method signature to allow null as a return value:

    protected static function getRequest(): ?ServerRequestInterface
    {
        return $GLOBALS['TYPO3_REQUEST'];
    }

but this has an impact on the rest of the above-mentioned commit.

Steps to reproduce

  1. install both solr and t3api
  2. expose a table in the API and index it with solr
  3. when running the Scheduler task from the command-line, the task crashes, with the following exception:
Uncaught TYPO3 Exception ApacheSolrForTypo3\Solr\Task\IndexQueueWorkerTask::getInitializedIndexService(): Argument #1 ($site) must be of type ApacheSolrForTypo3\Solr\Domain\Site\Site, null given, called in /var/www/html/vendor/apache-solr-for-typo3/solr/Classes/Task/IndexQueueWorkerTask.php on line 64
thrown in file /var/www/html/vendor/apache-solr-for-typo3/solr/Classes/Task/IndexQueueWorkerTask.php
in line 176

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions