Skip to content

Commit

Permalink
Compatibility with CLI mode #9183
Browse files Browse the repository at this point in the history
When in CLI mode `TYPO3_REQUEST` might not always exist. So we cannot
access it blindly. Instead, we use the pattern officially recommended
by `\TYPO3\CMS\Core\Http\ApplicationType`.

Without this patch, extensions such as `messenger` would crash when
sending emails.
  • Loading branch information
PowerKiKi committed Nov 2, 2022
1 parent 790bd51 commit 55342f0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Classes/Configuration/TcaTweak.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\ApplicationType;
use Fab\Vidi\Tca\TcaServiceInterface;

Expand Down Expand Up @@ -93,12 +95,11 @@ protected function getForeignTable($dataType, $fieldName)

/**
* Returns whether the current mode is Frontend
*
* @return bool
*/
protected function isFrontendMode()
protected function isFrontendMode(): bool
{
return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend();
return ($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
&& ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend();
}

}

0 comments on commit 55342f0

Please sign in to comment.