Issue Bug Closed

#91752Recursive Copy: Translation is created before Original Page

Peter Piechota 07/06/20, 13:18 updated 12/02/25, 14:36

Description

TYPO3 v9.5.18/19

After copying a page with subpages (all translated), some pages showed an error in the page-view:

Argument 2 passed to TYPO3\CMS\Core\Imaging\IconFactory::getIconForRecord() must be of the type array, boolean given, called in /var/www/.../private/typo3/sysext/backend/Classes/View/PageLayoutView.php on line 1317

Not all pages where affected though. Some work in column and language mode, some only in column mode if the original/default language is selected.

With the list view activated the error was obvious as the translated pages had lower PIDs than the original.

If only one page is copied, the issue did not occur.

Reviews 4

History 2138

Show 813 earlier messages
  1. Henrik Elsner commented <span data-processor="relativetime" data-value="2020-07-06T13:28:10+00:00" > 07/06/20, 13:28 </span>

    I can confirm this issue for v9.
    This happens when copying pages “recursive” in either way – via drag and drop + copy and via right click and paste after.

    The issue occurs for the same pages each time, meaning if you copy the same page + subpages e.g. 5 times, the error page(s) is always the same in each copied version.

  2. Frank Berger commented <span data-processor="relativetime" data-value="2020-12-01T17:13:21+00:00" > 12/01/20, 17:13 </span>

    We had the same problem today, larger tree copied with several languages, some pages worked in the Page module, some did not, in the Columns view, as in two languages side by side.

    But the Problem is not the order of the created copies, and not the uid of the pages.

    The Problem is, that if this happens, l10n_source and l10n_parent are pointing to different pages.

    On the surface this is the correct behaviour, as l10n_source should hold the historical source where it is copied from – which arguably could be done with t3orig_uid – and l10n_parent holds the logical language parent.

    The problem lies in BackendUtility::getRecordLocalization, called in PageLayoutView::getTable_tt_content for table ‘pages’.

    here l10n_source is preferred over l10n_parent:
    Line 338

    $tcaCtrl['translationSource'] ?? $tcaCtrl['transOrigPointerField'],

    which is checked against the uid of the l10n_parent.

    now, if in l10n_source is the historical uid, it will not find the translated page-record, and the subsequent logic in PageLayoutView::getTable_tt_content will fail with mentioned error.

    A possible solution could be that in case of ‘pages’ BackendUtility::getRecordLocalization always uses $tcaCtrl[‘transOrigPointerField’] / l10n_parent, but I don’t know what other problems this might raise.

    Otherwise the copy of pages should forego referencing the original translation in l10n_source in general.

    For affected pages / setups this query will be a quick fix:

    update pages set l10n_source=l10n_parent where sys_language_uid > 0 and l10n_source > 0 and l10n_source!=l10n_parent;
  3. Gerrit Hübbers commented <span data-processor="relativetime" data-value="2020-12-15T18:35:31+00:00" > 12/15/20, 18:35 </span>

    Thank you Frank, your SQL update statement helped fix this problem for our site.

    Our installation was getting this exception more and more often. 251 pages in our 5000+ page installation were affected.

  4. Peter Murray commented and changed TYPO3 Version 9 10 <span data-processor="relativetime" data-value="2021-01-27T06:26:38+00:00" > 01/27/21, 06:26 </span>

    We are still experiencing this problem in TYPO3 10.4.12, PHP 7.4.3

    We also had page records with l10n_source = 0 and l10n_source!=l10n_parent which also caused the error in the page-view.

    The SQL update statement helped, but preventing the pages records from getting the wrong l10n_source in the first place would be a better solution.

  5. Mordamir commented <span data-processor="relativetime" data-value="2021-07-15T09:47:15+00:00" > 07/15/21, 09:47 </span>

    This Problem still exists in 10.4.17.

    Thanks for the sql statement, it still fixes the issue for now.

    I think there is a partly fix for the problem in place. For one record the order of records for the pages was:

    uid   sys_language_uid   l10n_parent   l10n_source
    100          2               101           90
    101          0                 0            0
    102          1               101          101

    You see, if the creation order of the pages is not translated, translated, origin, the l10n_source for the translations generated after the original page are correct.

  6. Heinrich Pegelow commented <span data-processor="relativetime" data-value="2021-09-29T12:37:51+00:00" > 09/29/21, 12:37 </span>

    One of our clients is affected by this bug as well. The SQL statement works, but doesn’t prevent the error from occuring again in the future. Is there any way to resolve this once and for all?

    A “temporary” fix could look like this:

    \typo3\sysext\backend\Classes\View\PageLayoutView.php on line 757

    -- if (is_array($pageLocalizationRecord)) {
    ++ if (is_array($pageLocalizationRecord) && count($pageLocalizationRecord) > 0) {
  7. Gerrit Code Review pushed patch set 1 for master to change 71372 status New Under Review <span data-processor="relativetime" data-value="2021-09-29T13:05:26+00:00" > 09/29/21, 13:05 </span>

  8. Anja Leichsenring commented and changed status Under Review Needs Feedback <span data-processor="relativetime" data-value="2021-11-05T09:52:34+00:00" > 11/05/21, 09:52 </span>

    I could use a scenario description how to create the situation in the first place.

    So question is not how the failure materializes itself or how to fix it, but I need rather a step by step tutorial how I end up with a sub tree where a translated page would have a l10n_source different from l10n_parent.

  9. Gerrit Code Review pushed patch set 5 for master to change 71372 status Needs Feedback Under Review <span data-processor="relativetime" data-value="2021-11-18T10:45:31+00:00" > 11/18/21, 10:45 </span>

  1. Dominik Dörr commented <span data-processor="relativetime" data-value="2022-06-09T14:17:35+00:00" > 06/09/22, 14:17 </span>

    This is how I can reproduce the issue consistently with 10.4.28:

    • Set “Recursive Copy” for the current user.
    • Create a page (A) and a subpage (B).
    • Translate B into any language (translations of A do not seem to matter).
    • Hide B for the default language, but show the translated record.
    • Copy A anywhere else in the page tree.

    This results in the translation of B(copy) retaining B as l10n_source while having B(copy) as l10n_parent. The translation of B(copy) will have a lower uid than the default language of B(copy), which is odd as well.

    Any other constellation for B did work correctly for me (both default language and translation either shown or hidden, default language enabled and translation hidden). Copying B directly works fine as well.

    Can you reproduce the error this way?

  2. Jens Zscheile commented <span data-processor="relativetime" data-value="2022-06-14T09:10:49+00:00" > 06/14/22, 09:10 </span>

    I can as well reproduce the issue on 10.4.28. After the recursive copy the l10n_parent is set to the UID of the newly created page record, but the l10n_source is set to the origin page. Issue only occurs if you try to open the page in the Web > Page module with mode Languages instead of Columns.

    In my case no page was hidden. I have copied 2 pages with sub pages, one with 5 and the other with 4 subpages. In the newly created tree parts, for the 3rd of the 5 subpages l10n_source wasn’t correct and no page out of the 4 subpages have the right value for l10n_source after copy.

    The issue will be raised in web/typo3/sysext/backend/Classes/View/PageLayoutView.php->generateLanguageView#765 because of the function BackendUtility::getRecordLocalization try to find a language overlay for the page using the column l10n_source which is not set to the newly created page record UID. So the result of BackendUtility::getRecordLocalization is an empty array and the reset of the array return false if the array is empty.

    web/typo3/sysext/backend/Classes/View/PageLayoutView.php->generateLanguageView#759

                    $pageLocalizationRecord = BackendUtility::getRecordLocalization('pages', $this->id, $languageId);
                    if (is_array($pageLocalizationRecord)) {
                        $pageLocalizationRecord = reset($pageLocalizationRecord);
                    }

    How ever, the function BackendUtility::getRecordLocalization can also return false if a record is not translate able and $this->iconFactory->getIconForRecord requires an array as second parameter.

  3. Philipp Kitzberger commented <span data-processor="relativetime" data-value="2024-07-01T09:58:44+00:00" > 07/01/24, 09:58 </span>

    I can still reproduce this in TYPO3 11.5.37. Patch set 8 seems to be working for 11 too.

  4. Riccardo De Contardi commented <span data-processor="relativetime" data-value="2024-08-04T15:53:22+00:00" > 08/04/24, 15:53 </span>

    This is still reproducible on 13.3.0-dev (latest main) with the test at comment 15

  5. Denis Mir commented <span data-processor="relativetime" data-value="2024-12-04T14:47:19+00:00" > 12/04/24, 14:47 </span>

    It would be great if not only the symptom could be fixed but also the root cause for the wrong “l10n_source” in page records during recursive copy.

    I have found the error and described it right here: https://forge.typo3.org/issues/105765

  6. Denis Mir commented <span data-processor="relativetime" data-value="2024-12-05T07:15:00+00:00" > 12/05/24, 07:15 </span>

    Just for the record the root cause for the translation is created before the original page is located in “\TYPO3\CMS\Core\DataHandling\DataHandler::int_pageTreeInfo”.

    The method tries to hand back a sorted list of page uids for a root pid. Sorting is done with the “sorting” field. BUT the problem is that default page records and connected translated page records share the same “sorting” value. This leads to database engines picking the order depending on DB implementation internals. And this leads to the copying process sometimes copying the default record and sometimes copying the translation page record first. And this leads to the “l10n_source” field being filled incorrectly which makes the page module crash. (or show “unused elements” in translation comparison view)

  7. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2024-12-16T13:40:12+00:00" > 12/16/24, 13:40 </span>

    Applied in changeset commit:73b6fdd2d8b6cbe9f78ed89e285e25291c3abe37.

  8. Gerrit Code Review pushed patch set 2 for 12.4 to change 87507 status Resolved Under Review <span data-processor="relativetime" data-value="2024-12-16T13:43:32+00:00" > 12/16/24, 13:43 </span>

  9. Benni Mack commented and changed status Under Review Resolved <span data-processor="relativetime" data-value="2024-12-19T19:20:10+00:00" > 12/19/24, 19:20 </span>

    Applied in changeset commit:1578898640ae3940645c475e4f8d4dfa821528ec.