Commit 67e9106a authored by Kevin Ditscheid's avatar Kevin Ditscheid

[BUGFIX] Remove all getRecordOverlay logic, because it is stupidly broken

parent 1e0f5a20
......@@ -34,7 +34,6 @@ use TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetPageOverlayHookInterface;
use TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetRecordOverlayHookInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\Languagevisibility\Exception\InvalidRowException;
use TYPO3\Languagevisibility\Exception\TableNotSupportedException;
use TYPO3\Languagevisibility\Service\FrontendServices;
......@@ -104,136 +103,13 @@ class PageHook implements PageRepositoryGetPageOverlayHookInterface, PageReposit
}
}
/**
* The flow in t3lib_page is:
* - call preProcess
* - if uid and pid > then overlay if language != 0
* - after this postProcess is called - which only corrects the overlay row for certain elements
*
* @param string $table
* @param array $row
* @param integer|bool $sys_language_content
* @param string $OLmode
* @param PageRepository $parent
* @return void
*/
public function getRecordOverlay_preProcess($table, &$row, &$sys_language_content, $OLmode, PageRepository $parent
): void {
if ((!is_array($row))
|| (!isset($row['uid']))
|| !FrontendServices::isSupportedTable($table)) {
return;
}
// Set the uid to the original record uid. Solves an error, where a content element within a content element is
// not rendered.
if (
$table === 'tt_content' &&
isset($row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]) &&
(int) $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] > 0
) {
$row['uid'] = (int) $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
}
try {
$element = FrontendServices::getElement($row, $table);
$overlayLanguage = FrontendServices::getOverlayLanguageIdForElement($element, $sys_language_content);
} catch (InvalidRowException $e) {
$row['uid'] = 0;
$row['pid'] = 0;
return;
} catch (Exception $e) {
return;
}
if ($overlayLanguage === FALSE) {
$row['uid'] = 0;
$row['pid'] = 0;
return;
}
if (!$element->isMonolithicTranslated()) {
// for monolithic elements the FrontendServices::getOverlayLanguageIdForElement return 0 to "tell" us that no overlay is required
// but since the TYPO3 Core interprets a language with id 0 to not return anything we need to leave the $sys_language_content untouched for MonolithicTranslated elements
$sys_language_content = $overlayLanguage;
}
) {
// Do nothing
}
/**
*
* @param string $table
* @param array|bool $row
* @param integer $sys_language_content
* @param string $OLmode
* @param PageRepository $parent
* @return void
*/
public function getRecordOverlay_postProcess($table, &$row, &$sys_language_content, $OLmode, PageRepository $parent
): void {
if (is_array($row) && $row['uid'] === 0 && $row['pid'] === 0) {
$row = FALSE;
return;
}
if ((!is_array($row))
|| (!isset($row['uid']))
|| ($sys_language_content === 0)
|| !FrontendServices::isSupportedTable($table)) {
return;
}
try {
$element = FrontendServices::getElement($row, $table);
// todo: remove?
$overlayLanguage = FrontendServices::getOverlayLanguageIdForElement($element, $sys_language_content);
} catch (Exception $e) {
return;
}
}
/**
* @param $dsArr
* @param $dataValue
* @param $PA
* @param $structurePath
* @param $pObj
*/
public function _callback_checkXMLFieldsForFallback($dsArr, $dataValue, $PA, $structurePath, $pObj): void {
if ($dsArr['TCEforms']['l10n_mode'] === 'exclude') {
$pObj->setArrayValueByPath($structurePath, $this->_callbackVar_overlayXML, $dataValue);
} elseif ($dataValue !== '' && $dsArr['TCEforms']['l10n_mode'] === 'mergeIfNotBlank') {
$overlayValue = $pObj->getArrayValueByPath($structurePath, $this->_callbackVar_overlayXML);
if ($overlayValue === '') {
$pObj->setArrayValueByPath($structurePath, $this->_callbackVar_overlayXML, $dataValue);
}
}
}
/**
* @param $table
* @param $row
* @param $languageId
* @return mixed
*/
protected function _getDatabaseTranslationOverlayRecord($table, $row, $languageId) {
// Select overlay record:
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$olrow = $queryBuilder->select('*')
->from($table)
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($row['pid'], \PDO::PARAM_INT)),
$queryBuilder->expr()->eq(
$GLOBALS['TCA'][$table]['ctrl']['languageField'],
$queryBuilder->createNamedParameter($languageId, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($row['uid'], \PDO::PARAM_INT)
)
)
)->setMaxResults(1)->execute()->fetch();
$GLOBALS['TSFE']->sys_page->versionOL($table, $olrow);
return $olrow;
) {
// Do nothing
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment