extension_builder icon indicating copy to clipboard operation
extension_builder copied to clipboard

Incorrect TCA with extension.supportLocalization=false

Open vitalik1700 opened this issue 4 years ago • 3 comments

Hello, I have recently updated my extension_builder and now struggling with the new version.

I'm getting invalid TCA which looks like this:

'types' => [
        '1' => ['showitem' => 'name, type, static_works--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, hidden, '],
    ],

Here last property name lacks comma after it and fuses with ---div---, effectively excluding both field and tab from displaying in form editor.

After checking the source code I saw: https://github.com/FriendsOfTYPO3/extension_builder/blob/90a4461ac971151079ca5479ae067a21a4725b1c/Resources/Private/CodeTemplates/Extbase/Configuration/TCA/tableName.phpt#L24

There is:

['showitem' => '<f:for each="{domainObject.properties}" as="property" iteration="i">{property.fieldName}{f:if(condition: i.isLast, else: ', ')}</f:for>

<f:if condition="{extension.supportLocalization}">, --div--;LLL:EXT:core/Resources[.....], l10n_diffsource, </f:if>

<f:if condition="{domainObject.addStarttimeEndtimeFields} || {domainObject.addHiddenField}">--div--;LLL:EXT:core/Resources[......]starttime, endtime</f:if>'],

So extension.supportLocalization condition has two commas - one in the beginning and one in the end, while access tab's condition lacks comma in the beginning, meaning that if localization is disabled for some reason, the described above unexpected behaviour occurs.

Also, domainObject.properties iteration has condition to exclude last comma, which is not very helpful since access tab has no such condition and will generate stray comma if addStarttimeEndtimeFields is disabled

I have extension_builder 10.0.2, but I checked master branch and seems that the problematic code is there too.

vitalik1700 avatar Dec 03 '21 18:12 vitalik1700

Thank you for your research where the bug comes from. Now it would even be more fun if you would also provide a pull request which would make my life a little easier as I just have to click that merge button :smile:

simonschaufi avatar Dec 03 '21 19:12 simonschaufi

To be honest, I'm not that great with all this Git stuff. But I tried to do my best.

vitalik1700 avatar Dec 03 '21 20:12 vitalik1700

@vitalik1700 well done! Nothing to complain!

simonschaufi avatar Dec 04 '21 23:12 simonschaufi