Skip to content

Commit

Permalink
[BUGFIX] Unhide page translations by default
Browse files Browse the repository at this point in the history
In TYPO3 v8, new page translations within pages_language_overlay
were visible by default when using plain DataHandler.

In TYPO3 v9, due to the merge into "pages" for translations,
the default value for "hidden" is used. Every new page translation
is now hidden by default - this is a different behavior.

Tests had to be modified to make this work again. However,
the change now removes the "hacks" within the tests,
and adds the functionality to take-over the "hidden" flag
from the default record.

For future TYPO3 major versions, the hidden field could be migrated
into a "allowLanguageSynchronization" once the Context API
is used throughout Core properly.

Resolves: #88248
Releases: master, 9.5
Change-Id: I2a684a0d4225451c3fbfc0021c09935c1224aaca
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60632
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Richard Haeser <richard@maxserv.com>
  • Loading branch information
bmack authored and Richard Haeser committed Apr 30, 2019
1 parent fceffe9 commit 5a3ee8c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 55 deletions.
7 changes: 6 additions & 1 deletion typo3/sysext/core/Classes/DataHandling/DataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4367,14 +4367,19 @@ public function localize($table, $uid, $language)
} else {
// Create new page which needs to contain the same pid as the original page
$overrideValues['pid'] = $row['pid'];
// Take over the hidden state of the original language state, this is done due to legacy reasons where-as
// pages_language_overlay was set to "hidden -> default=0" but pages hidden -> default 1"
if (!empty($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'])) {
$hiddenFieldName = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
$overrideValues[$hiddenFieldName] = $row[$hiddenFieldName] ?? $GLOBALS['TCA'][$table]['columns'][$hiddenFieldName]['config']['default'];
}
$temporaryId = StringUtility::getUniqueId('NEW');
$copyTCE = $this->getLocalTCE();
$copyTCE->start([$table => [$temporaryId => $overrideValues]], [], $this->BE_USER);
$copyTCE->process_datamap();
// Getting the new UID as if it had been copied:
$theNewSQLID = $copyTCE->substNEWwithIDs[$temporaryId];
if ($theNewSQLID) {
// If is by design that $table is used and not $table! See "l10nmgr" extension. Could be debated, but this is what I chose for this "pseudo case"
$this->copyMappingArray[$table][$uid] = $theNewSQLID;
$newId = $theNewSQLID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,19 +326,13 @@ public function modifyParentAndDeleteHotelChild()
public function localizePageWithLocalizationExclude()
{
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$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 localizePageTwiceWithLocalizationExclude()
{
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
$this->recordIds['localizedPageIdFirst'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageIdSecond);
Expand All @@ -348,9 +342,6 @@ public function localizePageTwiceWithLocalizationExclude()
public function localizePageAndAddHotelChildWithLocalizationExclude()
{
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$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->modifyRecords(
Expand All @@ -364,19 +355,13 @@ public function localizePageAndAddHotelChildWithLocalizationExclude()

public function localizePageWithLanguageSynchronization()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['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];
}

public function localizePageAndAddHotelChildWithLanguageSynchronization()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['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];
Expand All @@ -391,9 +376,6 @@ public function localizePageAndAddHotelChildWithLanguageSynchronization()

public function localizePageAndAddMonoglotHotelChildWithLanguageSynchronization()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['languageField']);
unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['transOrigPointerField']);
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
Expand All @@ -410,9 +392,6 @@ public function localizePageAndAddMonoglotHotelChildWithLanguageSynchronization(

public function localizeAndCopyPageWithLanguageSynchronization()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['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];
Expand All @@ -422,9 +401,6 @@ public function localizeAndCopyPageWithLanguageSynchronization()

public function localizePageWithSynchronizationAndCustomLocalizedHotel()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,19 +454,13 @@ public function modifyParentAndDeleteHotelChild()
public function localizePageWithLocalizationExclude()
{
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$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 localizePageTwiceWithLocalizationExclude()
{
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
$this->recordIds['localizedPageIdFirst'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageIdSecond);
Expand All @@ -476,9 +470,6 @@ public function localizePageTwiceWithLocalizationExclude()
public function localizePageAndAddHotelChildWithLocalizationExclude()
{
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$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->modifyRecords(
Expand All @@ -492,19 +483,13 @@ public function localizePageAndAddHotelChildWithLocalizationExclude()

public function localizePageWithLanguageSynchronization()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['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];
}

public function localizePageAndAddHotelChildWithLanguageSynchronization()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['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];
Expand All @@ -519,9 +504,6 @@ public function localizePageAndAddHotelChildWithLanguageSynchronization()

public function localizePageAndAddMonoglotHotelChildWithLanguageSynchronization()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['languageField']);
unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['transOrigPointerField']);
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
Expand All @@ -538,9 +520,6 @@ public function localizePageAndAddMonoglotHotelChildWithLanguageSynchronization(

public function localizeAndCopyPageWithLanguageSynchronization()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['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];
Expand All @@ -550,9 +529,6 @@ public function localizeAndCopyPageWithLanguageSynchronization()

public function localizePageWithSynchronizationAndCustomLocalizedHotel()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,6 @@ public function copyPageFreeMode()
*/
public function localizePage()
{
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
$this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
}
Expand All @@ -359,9 +356,6 @@ public function localizePageWithLanguageSynchronization()
{
unset($GLOBALS['TCA'][self::TABLE_Page]['columns']['title']['l10n_mode']);
$GLOBALS['TCA'][self::TABLE_Page]['columns']['title']['config']['behaviour']['allowLanguageSynchronization'] = true;
// in these test cases we expect new pages not to be hidden in order to
// verify proper overlaying behavior during the frontend render process
$GLOBALS['TCA'][self::TABLE_Page]['columns']['hidden']['config']['default'] = 0;
$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']);
Expand Down

0 comments on commit 5a3ee8c

Please sign in to comment.