Review main Merged

82442[TASK] Reduce hard-coded `tt_content` table in StandardPreviewRenderer

Nikita Hovratov CR +2 V +2 Hard +165 −100 updated 06/13/24, 19:06

Commit message

The goal here is to have a generic PreviewRenderer, which is not
tt_content specific. The StandardContentPreviewRenderer could then
extend this generic renderer. This is a pre-patch to make the
refactoring easier in the next patch.

For this to work, GridColumnItem now exposes methods to retrieve the
table from the context, the type column and the record type.

Additionally, some drive-by refactorings have been done like early
return statements and stricter checks.

The unused variable $infoArr has been removed as well.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Georg Ringer +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Georg Ringer +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 3448

Show 1623 earlier messages
  1. Nikita Hovratov uploaded patch set 1 01/11/24, 23:03

  2. core-ci voted on patch set 1 V +1 01/11/24, 23:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51470

  3. Oli Bartsch uploaded patch set 2 V +1 01/12/24, 09:15

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

  5. Oli Bartsch voted on patch set 2 CR +1 V +1 01/12/24, 09:21

  6. Benni Mack commented on patch set 2 01/12/24, 09:29

    GridColumnItem.php:356

    how to deal with list_type?
  7. Nikita Hovratov commented on patch set 2 01/12/24, 09:38

    GridColumnItem.php:356 Reply

    What do you mean? The type column would still be CType. Sub types are not relevant here.
  8. Daniel Siepmann commented on patch set 2 01/18/24, 09:30

    StandardContentPreviewRenderer.php:83

    This field might not exist on other tables as tt_content. Same for others like header_layout, subheader. Is that planned for a follow up patch?

    StandardContentPreviewRenderer.php:118

    Not sure if we should guard that switch with a check for $table === 'tt_content'. Otherwise it might jump in of some custom record table has matching types and "things" will happen.

    StandardContentPreviewRenderer.php:199

    This will result in issues with tables not providing these fields. E.g. space_before_class is very special to tt_content. starttime, endtime and fe_group could be fetched from TCA.ctrl.enablecolumns to ensure we only fetch existing columns. That also ensurs we use the configured database table columns, as they can be configured and don't need to be named that way.
  9. Oli Bartsch commented on patch set 2 01/18/24, 10:39

    GridColumnItem.php:359

    I think we should name this `getRecordType()`
  10. Oli Bartsch voted on patch set 2 CR 0 V 0 01/18/24, 10:39

  11. Nikita Hovratov uploaded patch set 3 V +1 01/23/24, 19:05

  12. core-ci voted on patch set 3 V -1 01/23/24, 19:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52031

  13. Nikita Hovratov uploaded patch set 4 V -1 01/23/24, 19:48

  14. core-ci voted on patch set 4 V +1 01/23/24, 19:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52033

  15. Nikita Hovratov uploaded patch set 5 V +1 01/23/24, 20:06

  16. Nikita Hovratov commented on patch set 4 01/23/24, 20:07

    StandardContentPreviewRenderer.php:83 Reply

    Done

    StandardContentPreviewRenderer.php:118 Reply

    Done

    StandardContentPreviewRenderer.php:199 Reply

    Done

    GridColumnItem.php:356 Reply

    I'll mark this as done. Custom list_type previews are dealt in StandardContentPreviewRenderer->renderContentElementPreviewFromFluidTemplate

    GridColumnItem.php:359 Reply

    I would like to keep it `getContentType`. Here is why: - we already have a method called `getContentTypeLabel` there. - I think of Content Type == Record Type interchangeably. Are you ok with that?
  17. core-ci voted on patch set 5 V +1 01/23/24, 20:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52036

  18. Nikita Hovratov uploaded patch set 6 V +1 01/23/24, 20:16

  19. Nikita Hovratov uploaded patch set 7 01/23/24, 20:17

  20. core-ci voted on patch set 6 V +1 01/23/24, 20:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52038

  21. core-ci voted on patch set 7 V +1 01/23/24, 20:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52040

  22. Nikita Hovratov uploaded patch set 8 V +1 01/23/24, 21:02

  23. Nikita Hovratov uploaded patch set 9 01/23/24, 21:08

  1. core-ci voted on patch set 8 V +1 01/23/24, 21:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52048

  2. core-ci voted on patch set 9 V +1 01/23/24, 21:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52049

  3. Benni Mack commented on patch set 9 01/23/24, 22:11

    Just a side node while reviewing: I hope we can split out the StandardContentPreviewRenderer, by e.g. moving all menu_* related Ctypes in their own PreviewRenderers.
  4. Daniel Siepmann commented on patch set 9 01/24/24, 06:46

    StandardContentPreviewRenderer.php:295

    Why is the 2nd argument optional? I guess this is done for backwards compatibility if developers extend this class? Than it's fine for me. Otherwise: this method is protected and not public API and we pass the argument. So we could make this argument required?
  5. Nikita Hovratov commented on patch set 9 01/24/24, 07:55

    StandardContentPreviewRenderer.php:295 Reply

    Yes, exactly. I don't want to deliberately break extensions in v12, namely Gridelements: https://github.com/CodersCare/gridelements/blob/e16b95c713665602b75a131805524ce76fc1c1ad/Classes/PageLayoutView/GridelementsPreviewRenderer.php#L143 In v13, we can happily change this to GridColumnItem to be the only parameter.
  6. Daniel Siepmann commented on patch set 9 CR +1 01/24/24, 07:56

    StandardContentPreviewRenderer.php:295 Reply

    Acknowledged
  7. Oli Bartsch commented on patch set 9 01/24/24, 13:04

    GridColumnItem.php:359 Reply

    Actually we are only talking about "content type" in context of `tt_content`, which is exactly what this patch tries to soften in this class. I think "recordType" is more generell and describes exactly what is returned here.
  8. Nikita Hovratov commented on patch set 9 01/24/24, 13:26

    GridColumnItem.php:359 Reply

    This is not set in stone. Actually everything is content one way or another. In Content Blocks we introduced the definition of Content Types as a generic name for Content Element (Types), Page Types and generic Record Types. I would like to streamline this and not introduce new, contradicting naming.
  9. Oli Bartsch commented on patch set 9 01/24/24, 13:31

    GridColumnItem.php:359 Reply

    It's at least already named this way in the docs, see e.g. https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Ctrl/Properties/Type.html#type
  10. Nikita Hovratov uploaded patch set 10 CR +1 V +1 01/24/24, 16:31

  11. core-ci voted on patch set 10 V +1 01/24/24, 16:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52101

  12. Nikita Hovratov commented on patch set 10 01/24/24, 16:45

    GridColumnItem.php:359 Reply

    Fine. Then let's align with what is currently used in Core and documentation. When Content Blocks comes, we can still rename things (also in Content Blocks itself), if necessary.
  13. Nikita Hovratov uploaded patch set 11 V +1 02/17/24, 16:32

  14. core-ci voted on patch set 11 V +1 02/17/24, 16:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53291

  15. Nikita Hovratov uploaded patch set 12 V +1 02/17/24, 17:05

  16. Nikita Hovratov uploaded patch set 13 02/17/24, 17:06

  17. core-ci voted on patch set 12 V +1 02/17/24, 17:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53293

  18. core-ci voted on patch set 13 V +1 02/17/24, 17:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53294

  19. Jörg Bösche voted on patch set 13 CR +1 02/27/24, 08:15

  20. Oli Bartsch uploaded patch set 14 CR +1 V +1 06/13/24, 18:35

  21. core-ci voted on patch set 14 V +1 06/13/24, 18:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59533

  22. Oli Bartsch voted on patch set 14 CR +1 V +1 06/13/24, 18:49

  23. Georg Ringer voted on patch set 14 CR +1 V +1 06/13/24, 18:51

  24. Oli Bartsch voted on patch set 14 CR +2 V +2 06/13/24, 19:03

  25. Oli Bartsch merged patch set 15 06/13/24, 19:06