DmitryDulepov\Realurl\Decoder\UrlDecoder::checkExpiration PHP Method

checkExpiration() protected method

Checks if the entry is expired and redirects to a non-expired entry.
protected checkExpiration ( DmitryDulepov\Realurl\Cache\UrlCacheEntry $cacheEntry )
$cacheEntry DmitryDulepov\Realurl\Cache\UrlCacheEntry
    protected function checkExpiration(UrlCacheEntry $cacheEntry)
    {
        if ($cacheEntry->getExpiration() > 0) {
            $newerCacheEntry = $this->cache->getUrlFromCacheByOriginalUrl($cacheEntry->getRootPageId(), $cacheEntry->getOriginalUrl());
            if ($newerCacheEntry->getExpiration() === 0) {
                if ($cacheEntry->getSpeakingUrl() !== $newerCacheEntry->getSpeakingUrl()) {
                    @ob_end_clean();
                    header(self::REDIRECT_STATUS_HEADER);
                    header(self::REDIRECT_INFO_HEADER . ': redirecting expired URL to a fresh one');
                    header('Location: ' . GeneralUtility::locationHeaderUrl($newerCacheEntry->getSpeakingUrl()));
                    die;
                } else {
                    // Got expired and non-expired entry for the same speaking url. Remove expired one.
                    $this->cache->clearUrlCacheById($cacheEntry->getCacheId());
                }
            }
        }
    }