Issue Bug Closed

#68040Inline localize and/or synchronize does not respect sorting

Jo Hasenau 07/10/15, 12:06 updated 09/08/26, 10:03

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.

Reviews 2

Files 1

History 1947

Show 1422 earlier messages
  1. Jo Hasenau commented and changed status New Accepted Complexity easy medium <span data-processor="relativetime" data-value="2015-07-17T22:05:21+00:00" > 07/17/15, 22:05 </span>

    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. Jo Hasenau commented <span data-processor="relativetime" data-value="2015-07-17T22:13:07+00:00" > 07/17/15, 22:13 </span>

    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. Oliver Hader commented and changed attached 68040_current.png <span data-processor="relativetime" data-value="2015-10-19T20:55:48+00:00" > 10/19/15, 20:55 </span>

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

  4. Andreas Wolf commented <span data-processor="relativetime" data-value="2017-08-18T19:16:14+00:00" > 08/18/17, 19:16 </span>

    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.

  5. Andreas Wolf commented <span data-processor="relativetime" data-value="2017-08-18T21:58:16+00:00" > 08/18/17, 21:58 </span>

    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()

  6. Gerrit Code Review pushed patch set 1 for master to change 53739 status Accepted Under Review <span data-processor="relativetime" data-value="2017-08-19T10:13:08+00:00" > 08/19/17, 10:13 </span>

  7. Sybille Peters commented <span data-processor="relativetime" data-value="2018-03-31T23:42:57+00:00" > 03/31/18, 23:42 </span>

    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!”

  1. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-09-04T15:40:11+00:00" > 09/04/26, 15:40 </span>

    Applied in changeset commit:6e67f9e4ea6fbe8f29b4f41830a92c5c2ee7c4d8.