Review main Abandoned

73458[BUGFIX] Unify view page allowed behaviour

Nikita Hovratov CR 0 V 0 Hard +165 −202 updated 07/29/23, 21:09

Commit message

The whole "Can I have a page preview" behaviour was
completely scattered around multiple classes and was
duplicated over and over again, sometimes with
missing conditions.

This led to PHP warnings in various views, when e.g.
a page of doktype "recycler" was currently selected
in the pagetree.

The behaviour is now extracted into the class
PagePreviewAbility. It takes a page record as a
constructor argument or alternatively a page uid for
the factory method createWithPageUid.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 13

Review log 2838

Show 1013 earlier messages
  1. Nikita Hovratov uploaded patch set 1 02/12/22, 18:57

  2. core-ci voted on patch set 1 V +1 02/12/22, 19:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23467

  3. Nikita Hovratov uploaded patch set 2 02/12/22, 19:59

  4. core-ci voted on patch set 2 V +1 02/12/22, 20:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23468

  5. Oli Bartsch commented on patch set 2 02/14/22, 09:37

    PageLayoutController.php:125

    Could we just pass the context ti makeButtons instead of introducing a single use class property?
  6. Christian Kuhn commented on patch set 2 02/14/22, 11:04

    on testing, this fixes crashes for 'recycler' pages already, info->'pagetree overview' still crashes, though.

    PageLayoutController.php:125 Reply

    yes pleas. i removed so many controller properties lately, would be sad adding new ones again ;)
  7. Christian Kuhn voted on patch set 2 CR -1 02/14/22, 11:04

  8. Nikita Hovratov commented on patch set 2 02/14/22, 11:58

    PageLayoutController.php:125 Reply

    This view page thing is there too, oomph. Maybe there are even more modules with view page in the doc module? Then this logic needs to be extracted into another helper class, away from PageLayoutContext.
  9. Nikita Hovratov uploaded patch set 3 02/15/22, 14:13

  10. Nikita Hovratov commented on patch set 3 02/15/22, 14:14

    PageLayoutController.php:125 Reply

    Done
  11. core-ci voted on patch set 3 V -1 02/15/22, 14:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23624

  12. Stefan Bürk uploaded patch set 4 02/15/22, 19:48

  13. Stefan Bürk commented on patch set 3 CR -1 02/15/22, 19:50

    Reply

    Not as complaint, just for reporting: info->'localization overview' still crashes if on recycler or level is set and one recycler in tree/to display. (preview link).

    PageLayoutController.php:125 Reply

    Only added following change: passing pageLayoutContext as 3rd argument to 'makeButtons()'
  1. Stefan Bürk voted on patch set 4 CR -1 02/15/22, 19:51

  2. core-ci voted on patch set 4 V +1 02/15/22, 20:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23656

  3. Nikita Hovratov uploaded patch set 5 02/17/22, 13:15

  4. Nikita Hovratov commented on patch set 5 02/17/22, 13:17

    This needs some thorough review. It was really a mess and there are somehow two different tsconfig options for exactly the same.
  5. Oli Bartsch commented on patch set 5 02/17/22, 13:29

    PagePreviewAbility.php:25

    Shouldn't this be rather a PagePreviewAspect?

    PagePreviewAbility.php:57

    This should IMO only be evaluated in case web_list is requested.
  6. core-ci voted on patch set 5 V -1 02/17/22, 13:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23800

  7. Nikita Hovratov commented on patch set 5 02/17/22, 13:39

    PagePreviewAbility.php:25 Reply

    Naming is hard, yeah.

    PagePreviewAbility.php:57 Reply

    ok, will add that.
  8. Nikita Hovratov uploaded patch set 6 02/17/22, 14:29

  9. Oli Bartsch commented on patch set 6 02/17/22, 14:34

    PagePreviewAbility.php:25 Reply

    What I actually meant is, I think this would suite as new aspect in the context API.
  10. core-ci voted on patch set 6 V -1 02/17/22, 14:39 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23808

  11. Nikita Hovratov commented on patch set 6 02/17/22, 14:43

    PagePreviewAbility.php:25 Reply

    Does it? I thought they are only there for simple properties. Can you help me a bit then, how it could look like?

    PagePreviewAbility.php:57 Reply

    Done
  12. Nikita Hovratov uploaded patch set 7 02/17/22, 14:45

  13. core-ci voted on patch set 7 V +1 02/17/22, 14:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23810

  14. Oli Bartsch commented on patch set 7 02/23/22, 11:30

    PagePreviewAbility.php:25 Reply

    Ok, thought about this again. Comparing with https://review.typo3.org/c/Packages/TYPO3.CMS/+/73638, an aspect might not suite here.
  15. Stefan Bürk commented on patch set 7 02/23/22, 14:29

    PagePreviewAbility.php:25 Reply

    Maybe we should/could change this class. I would avoid the constructor at all and transform it more to an imuttable object. ``` ::createWithPageUid(...) => ::forPage(int $pageId, bool $isListView=false) ``` maybe we can do then an additional method: ``` ::withPage[record](array $page, bool $isListView=false) ``` Regarding naming, "PagePreviewAbility" feels wrong, but no really good suggestion on that yet (naming things are hard). We can eventually extend it if needed - maybe we could have further use cases ? Maybe "PageAbility" .... giving up on that for now. * canPreview() * visible() (if normal page, visible in frontend in normal/non-preview mode) * ... Just suggestions to be discussed. ``` $previewPageAbility = GeneralUtility::makeInstance(PagePreviewAbility::class) ->forPage(10, true); ```
  16. Stefan Bürk commented on patch set 7 02/24/22, 09:41

    PagePreviewAbility.php:25 Reply

    ^ I mean something like that: https://3v4l.org/CjdRo
  17. Benni Mack commented on patch set 7 03/02/22, 11:35

    PagePreviewAbility.php:42

    I'd rather use this as a "canPreview(int|array $page)" and keep the object stateless. There is quite some magic (getRecord, getPagesTSconfig) which should be loaded differently. On top, $excludedDokTypes can be made a static array (private constant)
  18. Nikita Hovratov uploaded patch set 8 03/24/22, 17:06

  19. core-ci voted on patch set 8 V -1 03/24/22, 17:19 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25107

  20. Nikita Hovratov uploaded patch set 9 03/24/22, 18:24

  21. core-ci voted on patch set 9 V +1 03/24/22, 18:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25112

  22. Christian Kuhn commented on patch set 9 03/28/22, 15:38

    PagePreviewAbility.php:42 Reply Unresolved

    I agree. Let's make this stateless and just hand over the uid/array as argument here. Since maybe there might be additional methods in that class later, we may also rename the class to 'PagePreview' - the word 'ability' sounds odd anyways. what do you think?
  23. Benni Mack updated the commit message in patch set 10 V +1 05/03/23, 09:16

  24. core-ci voted on patch set 10 V -1 05/03/23, 09:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41389

  25. Nikita Hovratov abandoned the change 07/29/23, 21:09

    stale. Can be used as inspiration for a new approach.