Project

General

Profile

Actions

Bug #68624

closed

Invalid handling of TCA config "l10n_mode" in the backend for "mergeIfNotBlank"

Added by Radu Mogos over 9 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Language Manager (backend)
Target version:
Start date:
2015-07-29
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.5
Tags:
Complexity:
easy
Is Regression:
No
Sprint Focus:
Stabilization Sprint

Description

I think i might have found a small backend bug for the list module, for records that are localised and their TCA config is set to "l10n_mode" => "mergeIfNotBlank".

For an extbase model we have the following TCA config for the "name" field:

        'name' => array(
            'exclude' => 0,
            'l10n_mode' => 'mergeIfNotBlank',
            'label' => 'LLL:EXT:fhhwebsite/Resources/Private/Language/locallang_db.xml:tx_fhhwebsite_domain_model_timepiece.name',
            'config' => array(
                'type' => 'input',
                'size' => 32,
                'max' => 255,
                'eval' => 'trim,required'
            ),
        ),

Please note the setting "l10n_mode" with the value "mergeIfNotBlank".

This setting gives me the following list view in the backend, which is wrong:

The following is what I should see:

This happens because the call replaceL10nModeFields inside TYPO3\CMS\Backend\Utility\BackendUtility is wrong...

The line concerned is 1956 (in typo3 6.2.13)
Currently this is what the method is doing:

if ($l10n_mode === 'exclude' || ($l10n_mode === 'mergeIfNotBlank' && trim($originalRow[$field]) !== '')) {
  $row[$field] = $originalRow[$field];
}

while it should do the opposite
if ($l10n_mode === 'exclude' || ($l10n_mode === 'mergeIfNotBlank' && trim($row[$field]) == '')) {
  $row[$field] = $originalRow[$field];
}

$originalRow contains the parent data, so the "default" language values, while $row contains the localised version. So if the setting "mergeIfNotBlank" is set, we should check if the localised row $field is empty, if it is then we get the value from the default language, so we compare the localised version, not the original one.

At least this is what I understood from the official docs that should be the behaviour of "mergeIfNotBlank": http://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Index.html#l10n-mode


Files

bad.png (85.5 KB) bad.png Radu Mogos, 2015-07-29 16:45
good.png (89.7 KB) good.png Radu Mogos, 2015-07-29 16:45

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #68592: mergeIfNotBlank does not work for recordTitle and TcaTypeClosed2015-07-28

Actions
Actions #1

Updated by Christian Kuhn over 9 years ago

can be fixed with part of the change that was done for 7:

https://review.typo3.org/#/c/42050/2/typo3/sysext/backend/Classes/Utility/BackendUtility.php

this part of the 7 change should be safe for a 6.2 backport.

be aware that the tests need adaption as well:

https://review.typo3.org/#/c/42065/2/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php

Actions #2

Updated by Christian Kuhn over 9 years ago

btw: thanks for a very well documented and explained issue description!

Actions #3

Updated by Gerrit Code Review over 9 years ago

  • Status changed from New to Under Review

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/42121

Actions #4

Updated by Christian Kuhn over 9 years ago

  • Target version set to 6.2.15
  • Sprint Focus set to Stabilization Sprint
Actions #5

Updated by Christian Kuhn over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #6

Updated by Timo Pfeffer almost 8 years ago

Radu Mogos wrote:

I think i might have found a small backend bug for the list module, for records that are localised and their TCA config is set to "l10n_mode" => "mergeIfNotBlank".

For an extbase model we have the following TCA config for the "name" field:
[...]
Please note the setting "l10n_mode" with the value "mergeIfNotBlank".

This setting gives me the following list view in the backend, which is wrong:

The following is what I should see:

This happens because the call replaceL10nModeFields inside TYPO3\CMS\Backend\Utility\BackendUtility is wrong...

The line concerned is 1956 (in typo3 6.2.13)
Currently this is what the method is doing:
[...]
while it should do the opposite
[...]

$originalRow contains the parent data, so the "default" language values, while $row contains the localised version. So if the setting "mergeIfNotBlank" is set, we should check if the localised row $field is empty, if it is then we get the value from the default language, so we compare the localised version, not the original one.

At least this is what I understood from the official docs that should be the behaviour of "mergeIfNotBlank": http://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Index.html#l10n-mode

The Ticket should be reopened, because the fix does only work for string fields and not for integers. it makes sense to merge a field, if its value is not 0. so please change the === '' check in the code to a == '' to handle it correctly.

Actions #7

Updated by Riccardo De Contardi about 7 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF