Skip to content

Commit

Permalink
Merge pull request #396 from andersundsehr/phpstan
Browse files Browse the repository at this point in the history
πŸ› fix cookie handling
  • Loading branch information
lochmueller committed Jul 25, 2023
2 parents f47b68d + 3e7f147 commit e19d853
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions Classes/Hook/DatamapHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ class DatamapHook extends AbstractHook
*/
public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, DataHandler $dataHandler): void
{
if ('pages' !== $table || !MathUtility::canBeInterpretedAsInteger($id)) {
if ('pages' !== $table) {
return;
}
if (!MathUtility::canBeInterpretedAsInteger($id)) {
return;
}

$row = BackendUtility::getRecord($table, (int) $id);
$allowSfc = (bool) $row['tx_staticfilecache_cache'];
if (!$allowSfc) {
try {
// Delete cache
// Delete right now!! do not wait until queue is deleting this
$configuration = GeneralUtility::makeInstance(ConfigurationService::class);
$configuration->override('boostMode', '0');
$cacheService = GeneralUtility::makeInstance(CacheService::class);
Expand Down
7 changes: 5 additions & 2 deletions Classes/Service/CookieService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ public function __construct(private DateTimeService $dateTimeService)
*/
public function setCookie(int $lifetime): void
{
setcookie(self::FE_COOKIE_NAME, 'typo_user_logged_in', $lifetime + $this->dateTimeService->getCurrentTime(), '/', $this->getCookieDomain(), GeneralUtility::getIndpEnv('TYPO3_SSL'));
if ($lifetime !== self::SESSION_LIFETIME) {
$lifetime += $this->dateTimeService->getCurrentTime();
}
setcookie(self::FE_COOKIE_NAME, 'typo_user_logged_in', $lifetime, '/', $this->getCookieDomain(), GeneralUtility::getIndpEnv('TYPO3_SSL'));
}

/**
* Unset the Cookie.
*/
public function unsetCookie(): void
{
$this->setCookie( -3600);
$this->setCookie(-3600);
}

public function hasCookie(): bool
Expand Down

0 comments on commit e19d853

Please sign in to comment.