CodersCare / l10nmgr

GNU General Public License v3.0
0 stars 9 forks source link

l10nmgr export doesn't include parent records with no translatable fields but only child records #8

Closed mkarulin closed 1 year ago

mkarulin commented 1 year ago

TYPO3 version 11.5 l10nmgr version: 11.0.0 alpha

Description: When using l10nmgr export on a parent record that has no translatable fields but only child records with translatable fields, the export file only includes the child records and not the parent record. This can result in the child records being attached to the default language record instead of the translated parent record when importing the translation.

Steps to reproduce:

Install the typo3/cms-styleguide extension. Create a new folder with a l10nmgr configuration. Copy the styleguide example page "inline_1n" to that folder. Export the page in a different language using l10nmgr. Check the resulting export file to see if the parent record is included. Expected result: The export file should include both the parent record and the child records.

Actual result: The export file only includes the child records. After importing the file, child records are added to the default language with incorrect language, corruping it, and any further attemt to export/import will result in error: 0 => '[1.6.-1]: Localization failed: there already are localizations (23) for lang uage 1 of the "tx_styleguide_inline_1n_child" record 25!' (132 chars)

schliesser commented 1 year ago

We had the same issue and therefore created #3 You may can test/update the PR for the newer version.

mkarulin commented 1 year ago

@schliesser , the pull request would involve ignoring such elements? What if there is a use case for record that only have one inline field, with translatable child-elements?

Bunnyfield commented 1 year ago

Usually the rule is that records of translatable tables will always get exported, even if all the translatable fields are empty. If this is the case, at least the field configured to be the title field of that table will be used to trigger the export

                if ((
                    GeneralUtility::inList('shortcut,shortcut_mode,urltype,url_scheme', $kFieldName)
                        && $kTableName === 'pages'
                )
                    || (isset($TCEformsCfg['labelField']) && $TCEformsCfg['labelField'] === $kFieldName)
                ) {
                    $this->bypassFilter = true;
                }

So if the parent record is missing in the export, this must have another reason.

Bunnyfield commented 1 year ago

The actual problem with the styleguide extension seems to be a TCA misconfiguration of the children tables though.

Both parentid and parenttable are actually stored in the database but the fields are not configured to give information about those values, since both parentid and parenttable are configured as passthrough

So there is no way for the importer to identify those parent records, therefor recursivelyCheckForRelationParents has to fail.

Bunnyfield commented 1 year ago

And there is another reason for the missing records in the export: The styleguide extension is using a completely dumbed down set of TCA columns and therefor marks the uid field as label field - since this field does not even have a configuration in the columns section, those records will still be ignored due to nothing being available at all.

Still this would not be a problem, since they should be recognized by the importer looking for relation parents - but then again, those can't be found due to the reasons mentioned in the comment before.

Conclusion: If you want to test the L10nmgr export and import functionality - don't use the styleguide extension for it, unless you want to heavily reconfigure its TCA.

schliesser commented 1 year ago

Usually the rule is that records of translatable tables will always get exported, even if all the translatable fields are empty. If this is the case, at least the field configured to be the title field of that table will be used to trigger the export

                if ((
                    GeneralUtility::inList('shortcut,shortcut_mode,urltype,url_scheme', $kFieldName)
                        && $kTableName === 'pages'
                )
                    || (isset($TCEformsCfg['labelField']) && $TCEformsCfg['labelField'] === $kFieldName)
                ) {
                    $this->bypassFilter = true;
                }

So if the parent record is missing in the export, this must have another reason.

Example case:

Content Element is Hidden, but has some IRRE items which are active. If you now tell the exporter to not export hidden elements, it will not export the tt_content record, but the tx_plugin_inline_foo_bar records. During the import, the Datahandler can't find a content element record in the target language and therefore maps those inline elements to the default language record!

And that's the same thing with the styleguide example from @mkarulin . The export needs to make sure, that the data structure is respected. Otherwise we have the well known shit-out -> shit-in problem....

mkarulin commented 1 year ago

As TYPO3 is able to localize the styleguide "inline 1n" record just fine, without causing the missing parent and incorrect assigning to the default parent record, it should be concidered a bug in l10nmgr.

Bunnyfield commented 1 year ago

@schliesser This is not the problem described here. The elements are not hidden or disabled, so the use case is completely different. The styleguide extension does not define the necessary relations for the L10nmgr to take care of, so the export can not work properly unless someone configures the tables accordingly. This is even true for visible and active parent records.

@mkarulin - The point is that you as a user are triggering the translation of the parent record manually, which is exactly what would happen, if the L10nmgr got the information, that it should take care of the parent record during the import. So you just have to define something that will give the L10nmgr the same knowledge that you already have, namely that the missing record actually IS a parent record. If this information is not made available somehow (i.e by defining parentid and parenttable properly and configuring them as inline fields for the L10nmgr), the L10nmgr can not do the same thing, because it does not have that knowledge.

mkarulin commented 1 year ago

Closing because $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['l10nmgr']['inlineTablesConfig'] and replacing passThrough fields with select fields solves the issue.