Kephson / paste_reference

Paste reference instead of copy for content elements in TYPO3
MIT License
14 stars 18 forks source link

[BUG] TYPO3_REQUEST not available in CLI context (TYPO3 12) #30

Open 3l73 opened 3 months ago

3l73 commented 3 months ago

Summary / Description

The global variable TYPO3_REQUEST is accessed without checking the existence. After that the request ist used to retrieve the query parameters.

Within the CLI context this leads to the exception: Call to a member function getQueryParams() on null

See: Classes/DataHandler/ProcessCmdmap.php

Version

development branch for TYPO3 12

Steps to reproduce

-

Expected behaviour

The command map should not be executed.

Actual behavior

The CLI command will leads to an exception.

Additional

Possible fix

Check if the server request is available or stop processing

$request = $GLOBALS['TYPO3_REQUEST'] ?? null;
if (!($request instanceof ServerRequestInterface)) {
           return;
}
$queryParams = $request->getQueryParams();
Kephson commented 3 months ago

Hi, I merged your pull request and will close the ticket afters test is successfull.