Skip to content

Commit

Permalink
[BUGFIX] Fixed the get_cache_timeout within StructuredDataProviderMan…
Browse files Browse the repository at this point in the history
…ager, introduced constant for the OverviewController request argument
  • Loading branch information
RinyVT committed Jan 6, 2025
1 parent 6d25008 commit f37c70c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function saveScoresAction(
return $this->saveScoresHandler->handle($request);
}

public function promimentWordsAction(
public function prominentWordsAction(
ServerRequestInterface $request
): ResponseInterface {
return $this->prominentWordsHandler->handle($request);
Expand Down
2 changes: 2 additions & 0 deletions Classes/Controller/OverviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

class OverviewController extends AbstractBackendController
{
public const REQUEST_ARGUMENT = 'tx_yoastseo_yoast_yoastseooverview';

public function __construct(
protected ModuleTemplateFactory $moduleTemplateFactory,
protected LanguageMenuFactory $languageMenuFactory,
Expand Down
5 changes: 3 additions & 2 deletions Classes/Service/Overview/LanguageMenu/LanguageMenuFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use YoastSeoForTypo3\YoastSeo\Controller\OverviewController;
use YoastSeoForTypo3\YoastSeo\Service\Overview\Dto\LanguageMenuItem;
use YoastSeoForTypo3\YoastSeo\Traits\BackendUserTrait;
use YoastSeoForTypo3\YoastSeo\Traits\LanguageServiceTrait;
Expand Down Expand Up @@ -94,7 +95,7 @@ protected function getLanguageMenuItems(
->setRequest($this->request)
->setTargetPageUid($this->pageUid)
->setArguments([
'tx_yoastseo_yoast_yoastseooverview' => [
OverviewController::REQUEST_ARGUMENT => [
'filter' => $filter,
'language' => $language->getLanguageId(),
'returnUrl' => $returnUrl,
Expand All @@ -116,6 +117,6 @@ protected function getLanguageMenuItems(
*/
protected function getArguments(): array
{
return $this->request->getArguments()['tx_yoastseo_yoast_yoastseooverview'] ?? $this->request->getArguments();
return $this->request->getArguments()[OverviewController::REQUEST_ARGUMENT] ?? $this->request->getArguments();
}
}
3 changes: 2 additions & 1 deletion Classes/Service/Overview/OverviewService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use YoastSeoForTypo3\YoastSeo\Controller\OverviewController;
use YoastSeoForTypo3\YoastSeo\DataProviders\OverviewDataProviderInterface;
use YoastSeoForTypo3\YoastSeo\Service\Overview\Dto\DataProviderRequest;
use YoastSeoForTypo3\YoastSeo\Service\Overview\Dto\OverviewData;
Expand Down Expand Up @@ -93,7 +94,7 @@ protected function getDataProviderRequest(RequestInterface $request): DataProvid
{
return new DataProviderRequest(
(int)($request->getQueryParams()['id'] ?? 0),
(int)($request->getQueryParams()['tx_yoastseo_yoast_yoastseooverview']['language'] ?? $request->getQueryParams()['language'] ?? 0),
(int)($request->getQueryParams()[OverviewController::REQUEST_ARGUMENT]['language'] ?? $request->getQueryParams()['language'] ?? 0),
'pages'
);
}
Expand Down
31 changes: 29 additions & 2 deletions Classes/StructuredData/StructuredDataProviderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

/**
Expand Down Expand Up @@ -82,8 +85,7 @@ public function getStructuredData(): array
$cacheIdentifier,
$data,
['pageId_' . ($this->getTypoScriptFrontendController()->page['uid'] ?? $this->getTypoScriptFrontendController()->id)],
// TODO: Fix this call, protected method since v13
//$this->getTypoScriptFrontendController()->get_cache_timeout()
$this->getCacheTimeout(),
);
}

Expand Down Expand Up @@ -186,4 +188,29 @@ protected function getSourceComment(): string
{
return '<!-- This site is optimized with the Yoast SEO for TYPO3 plugin - https://yoast.com/typo3-extensions-seo/ -->';
}

protected function getCacheTimeout(): int
{
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
return $this->getTypoScriptFrontendController()->get_cache_timeout();

Check failure on line 195 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (8.2, 13, composerInstallLowest)

Call to protected method get_cache_timeout() of class TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController.

Check failure on line 195 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (8.2, 13, composerInstallLowest)

Method TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::get_cache_timeout() invoked with 0 parameters, 1 required.

Check failure on line 195 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (8.3, 13, composerInstallLowest)

Call to protected method get_cache_timeout() of class TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController.

Check failure on line 195 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (8.3, 13, composerInstallLowest)

Method TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::get_cache_timeout() invoked with 0 parameters, 1 required.
}

$request = $GLOBALS['TYPO3_REQUEST'] ?? null;
if ($request === null) {
return 0;
}

$pageInformation = $request->getAttribute('frontend.page.information');
$typoScriptConfigArray = $request->getAttribute('frontend.typoscript')->getConfigArray();
$context = GeneralUtility::makeInstance(Context::class);

return GeneralUtility::makeInstance(CacheLifetimeCalculator::class)

Check failure on line 207 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (8.2, 11, composerInstallLowest)

Call to method calculateLifetimeForPage() on an unknown class TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator.

Check failure on line 207 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (8.2, 11, composerInstallLowest)

Class TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator not found.

Check failure on line 207 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (8.3, 11, composerInstallLowest)

Call to method calculateLifetimeForPage() on an unknown class TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator.

Check failure on line 207 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (8.3, 11, composerInstallLowest)

Class TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator not found.

Check failure on line 207 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (11, 8.1, composerInstallLowest)

Call to method calculateLifetimeForPage() on an unknown class TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator.

Check failure on line 207 in Classes/StructuredData/StructuredDataProviderManager.php

View workflow job for this annotation

GitHub Actions / Tests (11, 8.1, composerInstallLowest)

Class TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator not found.
->calculateLifetimeForPage(
$pageInformation->getId(),
$pageInformation->getPageRecord(),
$typoScriptConfigArray,
0,
$context
);
}
}
2 changes: 1 addition & 1 deletion Configuration/Backend/AjaxRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
'yoast_prominent_words' => [
'path' => 'yoast/prominentwords',
'target' => AjaxController::class . '::promimentWordsAction',
'target' => AjaxController::class . '::prominentWordsAction',
],
'yoast_internal_linking_suggestions' => [
'path' => 'yoast/internallinkingsuggestions',
Expand Down

0 comments on commit f37c70c

Please sign in to comment.