Skip to content

Commit

Permalink
[BUGFIX] Reinitialize ContentObjectRenderer for pages
Browse files Browse the repository at this point in the history
The menu generation must not reuse the page record from the current page
but must use the data from the linked page.

Resolves: #101883
Releases: main, 12.4
Change-Id: I491ed6d2f0d33f9bbe2ef934c4304adfae656808
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83654
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
  • Loading branch information
georgringer authored and bmack committed Apr 3, 2024
1 parent 9e94d70 commit 6578a96
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,13 @@ protected function menuTypoLink(array $page, string $oTarget, $addParams, $typeO
$conf['section'] = $page['sectionIndex_uid'];
}
$conf['page'] = new Page($page);
return $this->parent_cObj->createLink('|', $conf);

$backupData = $this->parent_cObj->data;
$this->parent_cObj->data = $page;
$link = $this->parent_cObj->createLink('|', $conf);
$this->parent_cObj->data = $backupData;

return $link;
}

/**
Expand Down

1 comment on commit 6578a96

@jurajsulek
Copy link

@jurajsulek jurajsulek commented on 6578a96 May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem. If the $link = $this->parent_cObj->createLink('|', $conf); trows an error the original data is newer restored, because the code doesn't reaches the '$this->parent_cObj->data = $backupData;'
you should change it to e.g.
try{
$link = $this->parent_cObj->createLink('|', $conf);
} catch(.......) {
$link = null;
}

We have this problem on Project where one page is a shortcut and the page where the shortcut shows is not translated In that case $this->parent_cObj->data ends with the datas from the shortcut page.

Please sign in to comment.