Skip to content

Commit

Permalink
[BUGFIX] Prevent PHP type error and stale language cache
Browse files Browse the repository at this point in the history
PHP is raising an error if $pageId cannot be resolved to an
integer value as required by method signature.

Additionally, an internally cached array is built based on a
dynamic value but the internal cache is not keyed by this
value or flushed when the value changes.

This patch:

* Casts an unresolved page ID to integer zero.
* Removes the internal cache of languages since the array
  now depends entirely on a unique input value, $pageId.

Resolves: #89692
Resolves: #90073
Releases: master, 9.5
Change-Id: I3d74b4c7575375aae23a7e2473100104c4700966
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62974
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Alexander Schnitzler <git@alexanderschnitzler.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Alexander Schnitzler <git@alexanderschnitzler.de>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
NamelessCoder authored and bmack committed May 14, 2020
1 parent 984a360 commit e413054
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions typo3/sysext/workspaces/Classes/Service/GridDataService.php
Expand Up @@ -79,11 +79,6 @@ class GridDataService implements LoggerAwareInterface
*/
protected $workspacesCache;

/**
* @var array
*/
protected $systemLanguages;

/**
* @var IntegrityService
*/
Expand Down Expand Up @@ -598,7 +593,7 @@ protected function getLanguageValue($table, array $record)
protected function getSystemLanguageValue($id, $pageId, $key)
{
$value = null;
$systemLanguages = $this->getSystemLanguages($pageId);
$systemLanguages = $this->getSystemLanguages((int)$pageId);
if (!empty($systemLanguages[$id][$key])) {
$value = $systemLanguages[$id][$key];
}
Expand All @@ -613,11 +608,7 @@ protected function getSystemLanguageValue($id, $pageId, $key)
*/
public function getSystemLanguages(int $pageId)
{
if (!isset($this->systemLanguages)) {
$translateTools = GeneralUtility::makeInstance(TranslationConfigurationProvider::class);
$this->systemLanguages = $translateTools->getSystemLanguages($pageId);
}
return $this->systemLanguages;
return GeneralUtility::makeInstance(TranslationConfigurationProvider::class)->getSystemLanguages($pageId);
}

/**
Expand Down

0 comments on commit e413054

Please sign in to comment.