Bug #68040

Inline localize and/or synchronize does not respect sorting

Added by Jo Hasenau over 6 years ago. Updated over 1 year ago.

Status:
Under Review
Priority:
Must have
Assignee:
-
Category:
FormEngine aka TCEforms
Start date:
2018-03-14
Due date:
2018-03-14 (over 3 years late)
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
medium
Is Regression:
No
Sprint Focus:

Description

Working with IRRE in multilingual projects you often have the situation, that elements have been translated already but they need to get additional content, which has been added to the default language records.

For this purpose there are two buttons in the editing form of the IRRE parent to either "localize" and/or "synchronize" the elements. While the first will just add new elements, the latter will even remove elements that have been deleted in the original language.

These actions are working quite well with a small exception: The sorting of the default language children is not respected, since new translated elements are just added after existing elements, even when they actually have been added between existing elements in the original language.

This leads to completely broken structures especially with deeper nesting levels of extensions like i.e. Gridelements. We noticed that while preparing the Localization Manager for Gridelements support and first thought it was a bug in either l10nmgr or GE. But while testing the manual localize/synchronize functionality, we found the same buggy behaviour.

IMHO the sorting must be synchronized from the default language after adding/removing elements in the target language.


Files

68040_current.png (42.3 KB) 68040_current.png Oliver Hader, 2015-10-19 20:55

Related issues

Related to TYPO3 Core - Bug #43158: Sorting of parent records also moves inline childsClosed2012-11-20

Actions
Related to TYPO3 Core - Bug #75400: Related child elements don't get correct sys_language_uid during localization of parent recordClosedJo Hasenau2016-04-04

Actions
Related to TYPO3 Core - Bug #83079: wrong sorting of content elements when translating using non-default-language CEs as sourceUnder Review2017-11-24

Actions
Related to TYPO3 Core - Bug #83469: Translation of translations break sorting in tt_contentClosed2018-01-04

Actions
Related to TYPO3 Core - Bug #50310: DataHandler fails to correctly re-sort (content) elements after moving one to topNeeds Feedback2013-07-22

Actions
Has duplicate TYPO3 Core - Bug #82109: Sorting of CEs in translation is wrong when localizing new CEs within gridelementsClosed2017-08-16

Actions
Follows TYPO3 Core - Bug #84228: Output error reasons if Build/Scripts/checkIntegrityCsvFixtures.php failsClosedMarkus Klein2018-03-13

Actions
#1

Updated by Jo Hasenau about 6 years ago

  • Status changed from New to Accepted
  • Complexity changed from easy to medium

It seems line 4588 of typo3/sysext/core/Classes/DataHandling/DataHandler.php just contains a wrong information about what's going to happen in the block below.

// Handle, reorder and store relations:
if ($inlineSubType == 'list') {
    $updateFields = array($field => $value);
} elseif ($inlineSubType == 'field') {
    $dbAnalysisCurrent->writeForeignField($config, $id);
    $updateFields = array($field => $dbAnalysisCurrent->countItems(FALSE));
} elseif ($inlineSubType == 'mm') {
    $dbAnalysisCurrent->writeMM($config['MM'], $id);
    $updateFields = array($field => $dbAnalysisCurrent->countItems(FALSE));
}
// Update field referencing to child records of localized parent record:
if (!empty($updateFields)) {
    $this->updateDB($table, $id, $updateFields);
}

it just updates one field but does not reorder anything.

#2

Updated by Jo Hasenau about 6 years ago

For the inline subtype "list" it works, since the CSV value is written into the field.
For "field" and "mm" there is no sorting at all.

#3

Updated by Oliver Hader almost 6 years ago

Is that the behavior your referring to (see screenshot)?

#4

Updated by Mathias Schreiber almost 6 years ago

  • Target version deleted (next-patchlevel)
#5

Updated by Jo Hasenau almost 6 years ago

Exactly this is the problem

#6

Updated by Jo Hasenau about 4 years ago

  • Has duplicate Bug #82109: Sorting of CEs in translation is wrong when localizing new CEs within gridelements added
#7

Updated by Andreas Wolf about 4 years ago

I investigated this and found the culprit: It’s RelationHandler, not DataHandler. The sorting is indeed correct directly after translation, or at least it was in my test case—I cannot tell for sure for every use case.

The sorting is then messed up by RelationHandler::writeForeignField(), which is called by DataHandler::inlineLocalizeSynchronize(). AFAICS, the basic problem here is that the order of elements is already wrong in the data supplied by FormEngine, and this incorrect order is then apparently carried on to RelationHandler (while DataHandler at least in some cases does the sorting correctly, but that might also be by accident here).

I fear this is not easily fixable without potentially breaking other things. The best fix would probably be to get the order right in FormEngine already, but I did not manage to easily fix this (in TcaInline::resolveRelatedRecords()). An additional problem here (in the context of connected mode) is that currently the ordering would be taken from the localized record, except for the non-localized records, and this did not work out in my tests.

#8

Updated by Andreas Wolf about 4 years ago

Andreas Wolf wrote:

The sorting is then messed up by RelationHandler::writeForeignField(), which is called by DataHandler::inlineLocalizeSynchronize().

Further research and tests showed that this is incorrect. writeForeignField() is called by DataHandler::remapListedDBRecords_procInline() when processing the translated Gridelements container.

The value processed in remapListedDBRecords_procInline comes from DataHandler->registerDBList[tt_content][<container UID>]. It looks like this: "4,5,,8,", with the last ID being the new element. That value was in turn fetched from $dbAnalysisCurrent, a RelationHandler instance used in DataHandler::inlineLocalizeSynchronize()

#9

Updated by Gerrit Code Review about 4 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#10

Updated by Gerrit Code Review about 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#11

Updated by Gerrit Code Review almost 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#12

Updated by Gerrit Code Review almost 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#13

Updated by Gerrit Code Review almost 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#14

Updated by Markus Klein over 3 years ago

  • Assignee deleted (Jo Hasenau)
  • Target version set to 8.7.11
#15

Updated by Gerrit Code Review over 3 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#16

Updated by Gerrit Code Review over 3 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#17

Updated by Markus Klein over 3 years ago

  • Due date set to 2018-03-14
  • Start date changed from 2015-07-10 to 2018-03-14
  • Follows Bug #84228: Output error reasons if Build/Scripts/checkIntegrityCsvFixtures.php fails added
#18

Updated by Oliver Hader over 3 years ago

  • Target version changed from 8.7.11 to 8.7.12
#19

Updated by Gerrit Code Review over 3 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#20

Updated by Susanne Moog over 3 years ago

  • Related to Bug #83079: wrong sorting of content elements when translating using non-default-language CEs as source added
#21

Updated by Sybille Peters over 3 years ago

I'm adding a reproduce scenario. I used bootstrap carousel from bootstrap_package for testing.

  1. Create an element of type bootstrap carousel.
  2. Add 2 IRRE elements ("Carousel item")
  3. Translate the element with mode "Translate"
  4. Add another IRRE element in the content element of the original language
  5. Move the new IRRE element from third to second place
  6. Edit the translated element, click on "Synchronize with original language"

Expected: Now, in the translated element the 3 IRRE elements should be in the same order as in the original.

Actual result: In the translated element, the new IRRE element is added as last element (incorrect order)

Also, in the latest master an error message is displayed: "1: Localization failed; There already was a localization for this language of the record!"

#22

Updated by Benni Mack over 3 years ago

  • Target version changed from 8.7.12 to 8.7.19
#23

Updated by Tymoteusz Motylewski about 3 years ago

  • Related to Bug #83469: Translation of translations break sorting in tt_content added
#24

Updated by Susanne Moog about 3 years ago

  • Target version changed from 8.7.19 to Candidate for patchlevel
#25

Updated by Gerrit Code Review almost 3 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#26

Updated by Gerrit Code Review almost 3 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#27

Updated by Gerrit Code Review almost 3 years ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#28

Updated by Gerrit Code Review almost 3 years ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53739

#29

Updated by Gerrit Code Review over 1 year ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/53739

#30

Updated by Benni Mack 11 months ago

  • Related to Bug #50310: DataHandler fails to correctly re-sort (content) elements after moving one to top added

Also available in: Atom PDF