Commit 94279ac3 authored by Oliver Hader's avatar Oliver Hader Committed by Benni Mack
Browse files

[BUGFIX] allowLanguageSynchronization flaws with pages_language_overlay

The allowLanguageSynchronization does not work correctly with the tables
pages and pages_language_overlay. This change at least provides the basic
functionality for regular non-relational values (which might work, but are
not verified with tests properly).

Resolves: #79809
Releases: master
Change-Id: Ia8402799828490e695fd7bfed1d1df51c6c43f3e
Reviewed-on: https://review.typo3.org/51671


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent cb7d3021
......@@ -38,6 +38,10 @@ use TYPO3\CMS\Core\Utility\StringUtility;
* the data-map directly, which ensures proper history entries as a side-effect.
* For inline relational record editing, this processor either triggers the copy
* or localize actions by instantiation a new local DataHandler instance.
*
* Namings in this class:
* + forTableName, forId always refers to dependencies data is provided *for*
* + fromTableName, fromId always refers to ancestors data is retrieved *from*
*/
class DataMapProcessor
{
......@@ -108,28 +112,37 @@ class DataMapProcessor
*/
protected function collectItems(string $tableName, array $idValues)
{
if (!$this->isApplicable($tableName)) {
$forTableName = $tableName;
if ($forTableName === 'pages') {
$forTableName = 'pages_language_overlay';
}
if (!$this->isApplicable($forTableName)) {
return;
}
$fieldNames = [
'uid' => 'uid',
'l10n_state' => 'l10n_state',
'language' => $GLOBALS['TCA'][$tableName]['ctrl']['languageField'],
'parent' => $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'],
'language' => $GLOBALS['TCA'][$forTableName]['ctrl']['languageField'],
'parent' => $GLOBALS['TCA'][$forTableName]['ctrl']['transOrigPointerField'],
];
if (!empty($GLOBALS['TCA'][$tableName]['ctrl']['translationSource'])) {
$fieldNames['source'] = $GLOBALS['TCA'][$tableName]['ctrl']['translationSource'];
if (!empty($GLOBALS['TCA'][$forTableName]['ctrl']['translationSource'])) {
$fieldNames['source'] = $GLOBALS['TCA'][$forTableName]['ctrl']['translationSource'];
}
$translationValues = $this->fetchTranslationValues(
$tableName,
$fieldNames,
$this->filterNumericIds(array_keys($idValues))
);
$translationValues = [];
// Fetching parent/source pointer values does not make sense for pages
if ($tableName !== 'pages') {
$translationValues = $this->fetchTranslationValues(
$tableName,
$fieldNames,
$this->filterNumericIds(array_keys($idValues))
);
}
$dependencies = $this->fetchDependencies(
$tableName,
$forTableName,
$this->filterNumericIds(array_keys($idValues))
);
......@@ -559,7 +572,7 @@ class DataMapProcessor
}
/**
* Create arary of dependent records
* Fetches translation dependencies for a given parent/source record ids.
*
* @param string $tableName
* @param array $ids
......
"pages",,,,,,,,,,,
,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title"
,1,0,256,0,0,0,0,0,0,0,"FunctionalTest"
,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest"
,89,88,256,0,0,0,0,0,0,0,"Relations"
,90,88,512,0,0,0,0,0,0,0,"Target"
,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title","media"
,1,0,256,0,0,0,0,0,0,0,"FunctionalTest",0
,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest",0
,89,88,256,0,0,0,0,0,0,0,"Relations",0
,90,88,512,0,0,0,0,0,0,0,"Target",0
......@@ -259,7 +259,16 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
*/
public function localizePage()
{
$this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
$this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
}
public function localizePageWithLanguageSynchronization()
{
$GLOBALS['TCA']['pages_language_overlay']['columns']['title']['config']['behaviour']['allowLanguageSynchronization'] = true;
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
$this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
$this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
}
/**
......
......@@ -363,6 +363,20 @@ class ActionTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\A
->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
}
/**
* @test
* @see DataSet/localizePageWSynchronization.csv
*/
public function localizePageWithLanguageSynchronization()
{
parent::localizePageWithLanguageSynchronization();
$this->assertAssertionDataSet('localizePageWSynchronization');
$responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
$this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
}
/**
* @test
* @see DataSet/changePageRecordSorting.csv
......
pages
,uid,pid,sorting,deleted,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title
,1,0,256,0,0,0,0,0,0,0,FunctionalTest
,88,1,256,0,0,0,0,0,0,0,DataHandlerTest
,89,88,256,0,0,0,0,0,0,0,Testing #1
,90,88,512,0,0,0,0,0,0,0,Target
pages_language_overlay
,uid,pid,deleted,sys_language_uid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,title
,1,89,0,1,0,0,0,0,Testing #1
tt_content
,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,l10n_source,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header
,297,89,256,0,0,0,0,0,0,0,0,0,0,Regular Element #1
,298,89,512,0,0,0,0,0,0,0,0,0,0,Regular Element #2
,299,89,768,0,0,0,0,0,0,0,0,0,0,Regular Element #3
,300,89,1024,0,1,299,299,299,0,0,0,0,0,[Translate to Dansk:] Regular Element #3
,301,89,384,0,1,297,297,297,0,0,0,0,0,[Translate to Dansk:] Regular Element #1
,302,89,448,0,2,297,301,301,0,0,0,0,0,[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1
Supports Markdown
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