Review main Merged

86077[BUGFIX] Unique default value configurations for NewContentElementWizard

Nikita Hovratov CR +2 V +2 Normal +148 −1 updated 11/08/24, 13:48

Commit message

Since wizard items are added automatically from TCA, it might happen
that formerly defined entries in TSConfig will cause the same items
to be shown twice. This happens if they were in different groups and
thus the merge function will not unify them.

This is now fixed by a dedicated merge method, which first removes
duplicated TCA entries and then merges the arrays.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Thomas Hohn +1
    • Anja Leichsenring +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Anja Leichsenring +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 4048

Show 1823 earlier messages
  1. Nikita Hovratov uploaded patch set 1 09/12/24, 22:34

  2. core-ci voted on patch set 1 V +1 09/12/24, 22:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65612

  3. Lina Wolf commented on patch set 1 09/13/24, 10:47

    There are extensions like I think the bootstrap package that add some CEs twice via page TSconfig: Once to default to have it up front and once to a dedicated group like media. Will this still work? Should be tested.
  4. Nikita Hovratov commented on patch set 1 09/13/24, 10:54

    Reply

    Good point, no they will both be dropped. Maybe we need to reverse the logic then: if an exact configuration already exists for tsconfig, remove it from the TCA wizards. This is a little more complicated that's why I did the "lazy" approach.
  5. Nikita Hovratov uploaded patch set 2 V +1 09/13/24, 12:06

  6. Nikita Hovratov commented on patch set 2 09/13/24, 12:09

    Reply

    Fixed with the new approach. Also added a test.
  7. core-ci voted on patch set 2 V +1 09/13/24, 12:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65672

  8. Nikita Hovratov uploaded patch set 3 V +1 09/13/24, 13:34

  9. core-ci voted on patch set 3 V +1 09/13/24, 13:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65683

  10. Lina Wolf commented on patch set 3 V -1 09/14/24, 04:09

    Trying this out with extension t3docs/examples and additional page TSconfig: mod.wizards.newContentElement.wizardItems { common { elements { examples_haiku_list { iconIdentifier = tx_examples-haiku title = LLL:EXT:examples/Resources/Private/Language/PluginHaiku/locallang_db.xlf:list.title description = LLL:EXT:examples/Resources/Private/Language/PluginHaiku/locallang_db.xlf:list.description tt_content_defValues { CType = list list_type = examples_haiku_list } } examples_haiku_detail { iconIdentifier = tx_examples-haiku title = LLL:EXT:examples/Resources/Private/Language/PluginHaiku/locallang_db.xlf:detail.title description = LLL:EXT:examples/Resources/Private/Language/PluginHaiku/locallang_db.xlf:detail.description tt_content_defValues { CType = list list_type = examples_haiku_detail } } } show := addToList(examples_haiku_list,examples_haiku_detail) } plugins { elements { examples_haiku_list { iconIdentifier = tx_examples-haiku title = LLL:EXT:examples/Resources/Private/Language/PluginHaiku/locallang_db.xlf:list.title description = LLL:EXT:examples/Resources/Private/Language/PluginHaiku/locallang_db.xlf:list.description tt_content_defValues { CType = list list_type = examples_haiku_list } } examples_haiku_detail { iconIdentifier = tx_examples-haiku title = LLL:EXT:examples/Resources/Private/Language/PluginHaiku/locallang_db.xlf:detail.title description = LLL:EXT:examples/Resources/Private/Language/PluginHaiku/locallang_db.xlf:detail.description tt_content_defValues { CType = list list_type = examples_haiku_detail } } } show := addToList(examples_haiku_list,examples_haiku_detail) } } I get the error: PHP Warning: Undefined array key "elements." in /var/www/html/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php line 336
  11. Nikita Hovratov uploaded patch set 4 V +1 09/15/24, 10:06

  12. Nikita Hovratov commented on patch set 4 09/15/24, 10:07

    Reply

    fixed
  13. core-ci voted on patch set 4 V +1 09/15/24, 10:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65805

  14. Lina Wolf commented on patch set 4 CR +1 V +1 09/15/24, 13:04

    Works for me, code looks good
  15. Nikita Hovratov commented on patch set 4 09/27/24, 10:21

    bump
  16. Guido Schmechel voted on patch set 4 CR +1 10/02/24, 23:00

  17. Nikita Hovratov commented on patch set 4 10/08/24, 12:59

    bump
  18. Nikita Hovratov uploaded patch set 5 CR +1 V +1 10/08/24, 13:06

  19. core-ci voted on patch set 5 V +1 10/08/24, 13:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67376

  20. Thomas Hohn voted on patch set 5 CR +1 10/10/24, 09:28

  21. Lina Wolf voted on patch set 5 CR +1 V +1 10/10/24, 09:30

  22. Guido Schmechel voted on patch set 5 CR +1 10/10/24, 10:07

  23. Georg Ringer voted on patch set 5 CR +1 V +1 10/10/24, 11:21

  1. Andreas Kienast commented on patch set 5 10/10/24, 12:36

    NewContentElementController.php:346

    May I ask why?
  2. Nikita Hovratov commented on patch set 5 10/10/24, 13:59

    NewContentElementController.php:346 Reply

    The tests reveal it. So that order of items is not checked.
  3. Nikita Hovratov commented on patch set 5 10/10/24, 14:09

    NewContentElementController.php:346 Reply

    ``` ['a' => '1', 'b' => '2'] == ['b' => '2', 'a' => '1'] // true ['a' => '1', 'b' => '2'] === ['b' => '2', 'a' => '1'] // false ```
  4. Andreas Kienast commented on patch set 5 10/10/24, 15:06

    NewContentElementController.php:346 Reply

    Acknowledged
  5. Benjamin Franzke commented on patch set 5 CR -1 10/10/24, 15:20

    NewContentElementController.php:346 Reply

    maybe we should document that then? Or better use `ksort`? Following examples are also true – but would we want that? ``` ['a' => '1', 'b' => '2'] == ['b' => '2', 'a' => true] // true ``` Or this: ``` ['a' => '0', 'b' => '2'] == ['b' => '2', 'a' => '00'] // true ```
  6. Nikita Hovratov uploaded patch set 6 CR +1 V +1 10/10/24, 15:59

  7. Nikita Hovratov commented on patch set 6 10/10/24, 15:59

    NewContentElementController.php:346 Reply

    Added ksort, thanks.
  8. core-ci voted on patch set 6 V +1 10/10/24, 16:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67517

  9. Georg Ringer voted on patch set 6 CR +1 10/16/24, 06:35

  10. Benjamin Franzke uploaded patch set 7 CR +1 V +1 10/19/24, 09:10

  11. Benjamin Franzke commented on patch set 7 10/19/24, 09:10

    NewContentElementController.php:341

    Possible Undefined array key "tt_content_defValues." here (if that config is omitted, which is actually possible…)
  12. core-ci voted on patch set 7 V +1 10/19/24, 09:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68221

  13. Nikita Hovratov uploaded patch set 8 CR +1 V +1 11/05/24, 18:17

  14. core-ci voted on patch set 8 V +1 11/05/24, 18:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69117

  15. Benjamin Franzke voted on patch set 8 CR +1 V +1 11/07/24, 13:11

  16. Thomas Hohn voted on patch set 8 CR +1 11/07/24, 13:18

  17. Simon Schaufelberger voted on patch set 8 CR +1 V +1 11/07/24, 13:39

  18. Ayke Halder commented on patch set 8 11/07/24, 13:40

    NewContentElementController.php:330

    Could this possibly be directly solved in the function `NewContentElementController::prepareWizwardItem()`? There is already code like this implemented: ```php 'defaultValues' => array_replace_recursive( $itemConf['tt_content_defValues'] ?? [], $itemConf['tt_content_defValues.'] ?? [], $itemConf['defaultValues'] ?? [] ), ```
  19. Nikita Hovratov commented on patch set 8 11/07/24, 14:57

    NewContentElementController.php:330 Reply

    This prepare method ensures that TsConfig and TCA config of same wizards in the same group are merged. This bugfix however ensures that duplicate wizard items in different groups are removed. So, no.
  20. Nikita Hovratov commented on patch set 8 11/07/24, 15:01

    NewContentElementController.php:330 Reply

    At further inspection, we could do the opposite: Move the prepare functionality of merging these configs into the new merge method. But I would do this in another dedicated patch. This one is explicitly to address the bug.
  21. Ayke Halder commented on patch set 8 11/07/24, 15:30

    NewContentElementController.php:330 Reply

    Acknowledged. Maybe in another dedicated patch the whole wizard-config-preparation needs some refactoring. ---- About this patch here: Maybe use a reference - please decide what looks better readable for you. ``` foreach ($contentElementWizards as &$wizard) { foreach ($wizard['elements.'] ?? [] as $key => $elementConfig) { … unset($wizard['elements.'][$key]); … } } ```
  22. Nikita Hovratov commented on patch set 8 11/07/24, 16:06

    NewContentElementController.php:330 Reply

    In general I think we should avoid using references if possible as this causes side effects (variable needs to be unset). Imo it's still readable with one array part more.
  23. Anja Leichsenring voted on patch set 8 CR +1 V +1 11/08/24, 09:29

  24. Benjamin Franzke voted on patch set 8 CR +2 V +2 11/08/24, 13:38

  25. Benjamin Franzke merged patch set 9 11/08/24, 13:48