Issue Bug Closed

#103025Undefined array index for TCA without ctrl

Simon Schaufelberger 02/02/24, 18:39 updated 07/09/24, 15:12

Description

I have an extension that uses a TCA configuration without the ctrl part because I don’t need it. In my specific case I created a TCA configuration for the table “sys_registry”:

<?php

declare(strict_types=1);

return [
    'columns' => [
        'entry_namespace' => [
            'label' => 'LLL:EXT:registry_editor/Resources/Private/Language/locallang_tca.xlf:sys_registry.entry_namespace',
            'config' => [
                'type' => 'input',
                'size' => 50,
                'max' => 128,
            ],
        ],
        'entry_key' => [
            'label' => 'LLL:EXT:registry_editor/Resources/Private/Language/locallang_tca.xlf:sys_registry.entry_key',
            'config' => [
                'type' => 'input',
                'size' => 50,
                'max' => 128,
            ],
        ],
        'entry_value' => [
            'label' => 'LLL:EXT:registry_editor/Resources/Private/Language/locallang_tca.xlf:sys_registry.entry_value',
            'config' => [
                'type' => 'passthrough',
            ],
        ],
    ],
];

that I need to access the database via extbase but nothing more as the table should not be listed in the backend list view.

If I add:

    'ctrl' => [],

my code breaks because then the core tries to add a “pid” to the query but that table doeesn’t have a “pid”.

Reviews 3

History 722

  1. Simon Schaufelberger changed description 02/02/24, 18:44

  2. Gerrit Code Review pushed patch set 1 for main to change 82771 status New Under Review 02/02/24, 18:44

  3. Stefan Bürk commented 02/02/24, 19:11

    `sys_registry` is not TCA controlled by intention. Adding a TCA definition for it comes with some impact.
    First, a `pid` column would be added through the database analyser / Default TCA Schema logic.

    You are right with the place and that it should be covered, but you are messing around with something
    not intended.

    However, the bugfix is okay.

    TCA controlled tables should have a uid and pid. point. (mm relation tables are a special case). Tables
    not falling into that schema are not suitable to be TCA managed.

    I’d argue that a TCA managed table without a ctrl section is broken anyway.

  4. Simon Schaufelberger commented 02/02/24, 19:29

    My code may not be optimal but I basically do almost the same like the backend user module, just for registry entries for my registry editor extension: https://www.simonschaufelberger.de/de/shop.html

    I could rewrite the “findDemanded” method to use the Doctrine QueryBuilder instead of the extbase one, I just found this more convenient ;) Then I could probably drop the TCA config completely.

  5. Gerrit Code Review pushed patch set 2 for main to change 82771 02/02/24, 23:22

  6. Simon Schaufelberger changed TYPO3 Version 12 11 02/02/24, 23:23

  7. Gerrit Code Review pushed patch set 3 for main to change 82771 02/03/24, 23:35

  8. Gerrit Code Review pushed patch set 4 for main to change 82771 02/04/24, 00:11

  9. Gerrit Code Review pushed patch set 5 for main to change 82771 02/04/24, 00:24

  10. Gerrit Code Review pushed patch set 6 for main to change 82771 02/04/24, 00:27

  11. Gerrit Code Review pushed patch set 7 for main to change 82771 02/04/24, 00:31

  12. Gerrit Code Review pushed patch set 8 for main to change 82771 02/04/24, 00:33

  13. Gerrit Code Review pushed patch set 9 for main to change 82771 02/04/24, 16:46

  14. Gerrit Code Review pushed patch set 10 for main to change 82771 02/04/24, 21:37

  15. Stefan Bürk commented 02/05/24, 12:30

    Simon Schaufelberger wrote in #note-4:
    > My code may not be optimal but I basically do almost the same like the backend user module, just for registry entries for my registry editor extension: https://www.simonschaufelberger.de/de/shop.html
    >
    > I could rewrite the “findDemanded” method to use the Doctrine QueryBuilder instead of the extbase one, I just found this more convenient ;) Then I could probably drop the TCA config completely.

    If you do so add a ctrl section. I’d argue that at least the title configuration should be set, https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Ctrl/Properties/Title.html#title … and in case of sys_registry also https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Ctrl/Properties/HideTable.html#hidetable should be set.

    As already mentioned, the database analyzer will add a `pid` field to the table in case you add a TCA configuration for this field.

    And still, `sys_registry` is not ment to be TCA controlled. Adding it to be used with extbase is here out of the scope and you are messing arround with a TYPO3 core table in a way which is not intented – and open for sideeffects.

  16. Gerrit Code Review pushed patch set 1 for 12.4 to change 82790 02/05/24, 12:37

  17. Gerrit Code Review pushed patch set 2 for 12.4 to change 82790 02/05/24, 12:50

  18. Gerrit Code Review pushed patch set 3 for 12.4 to change 82790 02/05/24, 13:40

  19. Gerrit Code Review pushed patch set 4 for 12.4 to change 82790 02/05/24, 13:48

  20. Gerrit Code Review pushed patch set 1 for 11.5 to change 82792 02/05/24, 14:51

  21. Anonymous commented and changed status Under Review Resolved done 0 % 100 % 02/07/24, 16:25

    Applied in changeset commit:86f637579f663d34e9690f78a6e18dc237b37010.

  22. Benni Mack changed status Resolved Closed 07/09/24, 15:12