Skip to content

Commit

Permalink
Merge pull request #192 from georgringer/patch-1
Browse files Browse the repository at this point in the history
[BUGFIX] Check for CLI usage
  • Loading branch information
balasch committed Jan 8, 2024
2 parents e1b8ae8 + 5f3009b commit ac5f83f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Classes/Factory/SecureLinkFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Leuchtfeuer\SecureDownloads\Registry\TokenRegistry;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\UserAspect;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\EventDispatcher\EventDispatcher;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Http\ServerRequest;
Expand Down Expand Up @@ -66,13 +67,15 @@ public function __construct(EventDispatcher $eventDispatcher, ExtensionConfigura
protected function initializeToken(): void
{
$this->token->setExp($this->calculateLinkLifetime());
$request = $this->getRequest();
if (ApplicationType::fromRequest($request)->isFrontend()) {
$pageArguments = $request->getAttribute('routing');
$pageId = $pageArguments->getPageId();
} elseif (ApplicationType::fromRequest($request)->isBackend()) {
$site = $request->getAttribute('site');
$pageId = $site->getRootPageId();
if (!Environment::isCli()) {
$request = $this->getRequest();
if (ApplicationType::fromRequest($request)->isFrontend()) {
$pageArguments = $request->getAttribute('routing');
$pageId = $pageArguments->getPageId();
} elseif (ApplicationType::fromRequest($request)->isBackend()) {
$site = $request->getAttribute('site');
$pageId = $site->getRootPageId();
}
}
$this->token->setPage($pageId ?? 0);

Expand Down

0 comments on commit ac5f83f

Please sign in to comment.