74681[TASK] Use local TypoScriptFrontendController in ContentObjects
Commit message
Review
-
Code review CR +2 Done
- Benni Mack +2
- Oliver Klee +1
- Oliver Hader +1
-
Verified V +2 Done
- Benni Mack +2
- Oliver Hader +1
- core-ci +1 CI
Issues 1
Files 16
- typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php4+13 −6
- typo3/sysext/frontend/Classes/ContentObject/Menu/TextMenuContentObject.php6+4 −2
- typo3/sysext/frontend/Classes/ContentObject/AbstractContentObject.php17+32 −1
- typo3/sysext/frontend/Classes/ContentObject/ContentContentObject.php4+1 −12
- typo3/sysext/frontend/Classes/ContentObject/ContentObjectArrayInternalContentObject.php4+4 −11
- typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php+8 −12
- typo3/sysext/frontend/Classes/ContentObject/HierarchicalMenuContentObject.php2+7 −6
- typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php+4 −10
- typo3/sysext/frontend/Classes/ContentObject/ImageResourceContentObject.php8+8 −9
- typo3/sysext/frontend/Classes/ContentObject/LoadRegisterContentObject.php2+3 −2
- typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php8+13 −20
- typo3/sysext/frontend/Classes/ContentObject/RestoreRegisterContentObject.php5+2 −1
- typo3/sysext/frontend/Classes/ContentObject/UserInternalContentObject.php+0 −8
- typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php2+6 −0
- typo3/sysext/frontend/Tests/Functional/ContentObject/FilesContentObjectTest.php+2 −3
- typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php+4 −0
Review log 6279
Show 4254 earlier messages
-
Markus Friedrich uploaded patch set 1 05/18/22, 14:26
-
Mathias Brodala commented on patch set 1 CR -1 05/18/22, 14:36
RestoreRegisterContentObject.php:33See above. -
core-ci voted on patch set 1 V -1 05/18/22, 14:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27302
-
Simon Schaufelberger commented on patch set 1 05/18/22, 14:42
AbstractContentObject.php:62why not $this->cObj->... -
Mathias Brodala commented on patch set 1 05/18/22, 14:53
AbstractContentObject.php:62ReplyInterestingly both variants do not cope with $cObj being nullable ... -
Tymoteusz Motylewski commented on patch set 1 05/18/22, 18:53
safe -
Markus Friedrich commented on patch set 1 05/19/22, 08:54
AbstractContentObject.php:62ReplyIndeed, unfortunately with ContentObjectRenderer it's similar to TypoScriptFrontendController, it's presumed everywhere and not checked, especially since it became nullable recently. I'm not sure what is planned here, at first sight it doesn't fit that cObj is nullable and the return type of the getter is not. So I used the getter, to be more prepared for upcoming adaptions e.g. in case the getter will be adapted and will ensure itself that the ContentObjectRenderer is returned, similar to getPageRendererAbstractContentObject.php:67ReplyYou're right, that the TypoScriptFrontendController could be null is not sufficiently handled in most content objects, as well as in the places adapted here. Currently it's mostly presumed that it's available and there was and is no check and error handling. I also think that the content objects should be reworked on this point, though I don't see that in the context of this issue. Nevertheless, of course we can adapt the anyway affected parts directly. So far I just tried to keep the adjustments as simple as possible to stay in topic and not to complicate the review, when moving the methods or replacing $GLOBALS['TSFE'] I will integrate the nullsafe operator as proposed. -
Markus Friedrich uploaded patch set 2 05/23/22, 12:10
-
Markus Friedrich commented on patch set 2 05/23/22, 12:16
Reply
DoneAbstractContentObject.php:62ReplyDoneAbstractContentObject.php:67ReplyDone -
core-ci voted on patch set 2 V -1 05/23/22, 12:19 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27399
-
Stefan Bürk commented on patch set 2 05/23/22, 12:38
AbstractContentObject.php:67Reply"?->" has to be changed on backport. So please either remove 11.5 from releases or use code which can be backported more easiely at first if backport is really wanted. (At least if used on multiple parts). Not checked if this is covered by tests. If not, this would not popup on backport and maybe be introducing a bug in v11 if overseen by the backporter. Quite some tests are failing not matching expected results now. So this seems to be a change in behaviour. Not reviewed patch yet .... -
Markus Friedrich commented on patch set 2 05/23/22, 13:44
AbstractContentObject.php:67ReplyOk, unfortunately I'm not very familiar with the usual process. Since TYPO3 12 no longer supports PHP 7.4, from my point of view it makes sense to go the modern way here and adapt it only in the backport. that means I remove 11.5 only from the releases, correct? I have to check the tests anyway, in the process I can adjust the commit. In some functional tests stdClass was used instead of TypoScriptFrontendController, which led to return type issues. I was able to fix this part, but now that the tests are running again, the results show that the order of file collections differs. -
Markus Friedrich uploaded patch set 3 05/24/22, 09:43
-
core-ci voted on patch set 3 V -1 05/24/22, 09:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27430
-
Markus Friedrich commented on patch set 3 05/24/22, 09:51
I have checked the failing tests and the differing file sorting, the cause is in the test environment and the FileRepository. Until now the FilesContentObjectTest didn't initialize TSFE correctly, a backend environment was assumed in the FileRepository and a different sorting was used for the FileReferences, see: - FileRepository->findByRelation - AbstractRepository->getEnvironmentMode So the sorting is now correct and I have adjusted the tests accordingly. Unfortunately I couldn't run the full set of tests locally, but at least the EXT:frontend tests succeeded. The issue in PageTreeFilterCest couldn't be reproduced locally and seems to be unrelated, I guess it was just a performance or delay issue.AbstractContentObject.php:67ReplyI removed 11.5 from the releases list, but I'm also planning to take care of the backport later.RestoreRegisterContentObject.php:33ReplyDone -
Markus Friedrich commented on patch set 3 05/24/22, 09:56
Reply
ok, I've to check the tests again, now there are issues with mariadb and sqllite. Sorry for the inconvenience -
Markus Friedrich uploaded patch set 4 05/24/22, 12:00
-
Markus Friedrich commented on patch set 4 05/24/22, 12:01
Reply
In addition to the mentioned context issue I found erroneous definitions in fixture FilesContentObjectDataSet.csv. Settings of sys_file_reference.sorting_foreign were identical for all files and so no distinct sorting criteria was available and a database specific sorting took place. I've adjusted the sorting settings in the fixture, to match real life values and to ensure consistent sortings. I've choosen values that limit the changes in the FilesContentObjectTest, to keep the changeset simple. -
Oliver Klee commented on patch set 4 05/24/22, 12:03
Reply
Would it make sense to move the fixture fix to a different change that can be backported to 11.5 to make the tests more deterministic? -
core-ci voted on patch set 4 V +1 05/24/22, 12:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27431
-
Markus Friedrich commented on patch set 4 05/24/22, 12:24
Reply
I also think that the environment and fixture fixes are reasonable for 11.5 as well. I am anyway planning to provide a backport, would like to do that in this process and think that we therefore do not need to consider it separately. Except of course there is something that speaks against the adoption of the adjustments for 11.5 in principle. -
Rafael Kähm commented on patch set 4 V +1 CR +1 05/24/22, 12:31
AbstractContentObject.php:67ReplyAck -
Simon Schaufelberger voted on patch set 4 V +1 CR +1 05/24/22, 12:50
-
Markus Friedrich commented on patch set 4 05/25/22, 11:18
Reply
DoneRestoreRegisterContentObject.php:33ReplyDone -
Oli Bartsch commented on patch set 4 CR -1 05/25/22, 22:37
Could we somehow resolve all those possible null pointer exceptions?objectsinstanceContentContentObject.php:143This seems to be unrelatedContentObjectArrayInternalContentObject.php:54This seems to be unrelatedImageResourceContentObject.php:32What is the reason for creating a local variable using the getter instead of accessing the class property directly?ImageResourceContentObject.php:34What is the reason for not writing the result to $tsfe->lastImgResourceInfo? This seems like a change of behaviour.ImageResourceContentObject.php:35Not sure this also seems like a change in behaviour but might be logically correct. Would need to test this in detail.TextMenuContentObject.php:56Could we move this to a local variable (outside of the foreach)?FilesContentObjectDataSet.csv:20Correct to change the fixtures? Usually this would mean that those fixtures were wrong beforehand. Maybe @niktia can have a look here. -
Nikita Hovratov uploaded patch set 5 05/26/22, 06:59
-
Nikita Hovratov commented on patch set 5 CR -1 05/26/22, 07:02
Reply
DoneFilesContentObjectDataSet.csv:20ReplyIt is only used as a basis, not as an assertion. The change in sorting foreign is only cosmetical. -
core-ci voted on patch set 5 V -1 05/26/22, 07:07 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27473
-
Nikita Hovratov uploaded patch set 6 05/26/22, 07:11
-
Nikita Hovratov commented on patch set 6 05/26/22, 07:11
Reply
DoneContentContentObject.php:143ReplyDoneContentObjectArrayInternalContentObject.php:54ReplyDoneFilesContentObjectDataSet.csv:20ReplyDone -
core-ci voted on patch set 6 V +1 05/26/22, 07:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27474
-
Oliver Klee wrote 06/10/22, 21:42
Removed cc Oliver Klee. -
Markus Friedrich uploaded patch set 7 06/14/22, 07:32
-
Markus Friedrich commented on patch set 7 06/14/22, 07:37
Reply
The issue was already addressed in Mathias Brodala's comment, I also think that all content objects should check whether TSFE is available. However, since the problem has always existed and would require major considerations and adjustments, I don't think we should address this within the scope of this issue. Are you okay with addressing it later?ImageResourceContentObject.php:32ReplyThis was initially intended as an approach to deal with the nullable cObj, but since the getter doesn't consider this case either, it doesn't make sense.ImageResourceContentObject.php:34ReplylastImgResourceInfo is not defined in TSFE and causes PHPStan to report an error, see https://git.typo3.org/typo3/CI/cms/-/jobs/1297136. As TSFE->lastImgResourceInfo is not used except in ImageResourceContentObject, it seemed unproblematic to me at first to use a local variable instead. But you're right, I didn't consider that it is quite reasonable to be able to access the image information, e.g. via typoscript. I have adapted this and defined lastImgResourceInfo in TSFE, thanks for the hint.ImageResourceContentObject.php:35ReplyRegarding $tsfe->lastImgResourceInfo I had to make changes anyway, in the course of this I also restored the more general check in order to focus on the topic of this issue and to simplify the review.TextMenuContentObject.php:56ReplyI'm not sure I'm understanding you correctly here. Register "count_HMENU_MENUOBJ" is expected to be set in TSFE, it's e.g. used in the MenuProcessor and moving the whole incrementation out of the foreach would change the behaviour. Anyway, do you see a direct relation to the issue here? Otherwise I would like to propose that we look at this separately. -
core-ci voted on patch set 7 V +1 06/14/22, 07:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28065
-
Oliver Klee updated the commit message in patch set 8 06/14/22, 11:37
-
core-ci voted on patch set 8 V +1 06/14/22, 11:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28071
-
Oli Bartsch commented on patch set 8 06/14/22, 21:40
Reply
Actually most of the content objects do rely on TSFE being available. They do not check and would fail hard. The patch now introduces a nullable method, which therefore leads to a lot of possible null pointers, which first is bad for reading the code (IDE underlines every call) and secondly somehow hides the dependency. So, as you already mentioned, the content objects should implement a check for TSFE being available (if they rely on) and otherwise throw an exception. This would IMO be fine, since this currently would lead to a PHP Error anyways.TextMenuContentObject.php:56ReplyWhat I mean: $tsfe = $this->getTypoScriptFrontendController(); foreach ($this->result as $key => $val) { $tsfe->register['count_HMENU_MENUOBJ']++; -
Simon Schaufelberger wrote 06/14/22, 23:49
Removed reviewer Simon Schaufelberger. -
Markus Friedrich uploaded patch set 9 06/15/22, 13:18
-
Markus Friedrich commented on patch set 9 06/15/22, 13:20
Reply
I agree, checks and handling should be improved. I just hadn't seen this in this context initially, as the problem already existed before and the focus here was on a different issue. I've now added a few basic checks at the entry points, except the content object gets along without TSFE.TextMenuContentObject.php:56ReplyAh, now I got what is meant. Done -
core-ci voted on patch set 9 V +1 06/15/22, 13:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28097
-
Oliver Klee commented on patch set 9 06/15/22, 13:30
RecordsContentObject.php:55Would it make sense to move this check into getTypoScriptFrontendController()? Then we wouldn't have to duplicate the check all the time. -
Markus Friedrich commented on patch set 9 06/15/22, 13:45
RecordsContentObject.php:55ReplyI had also considered this at first, but since there are content objects that use TSFE to provide additional information, but are also working without TSFE, I decided to go this way. I think as soon as an individual error handling is introduced, it could be advantageous to be able to react individually. -
Oliver Klee commented on patch set 9 06/15/22, 13:58
RecordsContentObject.php:55ReplyDo those content objects call the getter even if there is no TSFE? If that is the case, I'd propose to add a separate method hasFrontEnd(): bool (or something along the lines) so we can move the check into the getter and have the return type of getTypoScriptFrontendController non-nullable. What do you think? -
Markus Friedrich uploaded patch set 10 06/20/22, 12:51
-
Markus Friedrich commented on patch set 10 06/20/22, 12:53
RecordsContentObject.php:55ReplyYes, e.g. the FilesContentObject fetches TSFE via the getter and performs own checks internally. FilesContentObject is just setting two variables in TSFE, but should work independently. Parts of ImageContentObject should work too and probably there are some more content objects that could be adapted, but I didn't want to change the behaviour for now. I think adding a separate method to check if TSFE is available is a good idea, the lack of individual error codes shouldn't be a real problem. I introduced a separate method "hasTypoScriptFrontendController()" and adapted the getter, should be cleaner now. I also had to adapt "getPageRepository()", since FilesContentObject calls this getter and due to our initial changes we would get an exception here. -
core-ci voted on patch set 10 V -1 06/20/22, 12:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28263
-
Markus Friedrich uploaded patch set 11 06/20/22, 13:14
-
core-ci voted on patch set 11 V -1 06/20/22, 13:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28265
-
Markus Friedrich uploaded patch set 12 06/20/22, 13:56
-
core-ci voted on patch set 12 V +1 06/20/22, 14:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28268
-
Oliver Klee commented on patch set 12 06/28/22, 11:52
AbstractContentObject.php:68Nice-to-have: Drop the @return as it does not add anything over the existing native type declaration.ContentContentObject.php:38Generally, I'd prefer (and recommend) to not have this renaming for two reasons: 1. This changes lines that are not functionally affected by the change. 2. Abbreviations and acronyms tend to increase the cognitive load when reading code (with some exceptions). -
Oliver Klee commented on patch set 12 06/28/22, 11:56
I have added some comments for some minor things. In general, I think that this change will be a big improvement!ContentObjectArrayInternalContentObject.php:40I'd recommend using the name $frontEndController here (as mentioned in my previous comment).HierarchicalMenuContentObject.php:42I'd recommend using the name $frontEndController here (as mentioned in my previous comment).ImageResourceContentObject.php:34I'd recommend using the name $frontEndController here (as mentioned in my previous comment).LoadRegisterContentObject.php:32I'd recommend using the name $frontEndController here (as mentioned in my previous comment).AbstractMenuContentObject.php:349I'd recommend using the name $frontEndController here (as mentioned in my previous comment).AbstractMenuContentObject.php:1744We can drop the @return as it's redundant with the native type declaration.TextMenuContentObject.php:50I'd recommend using the name $frontEndController here (as mentioned in my previous comment).RecordsContentObject.php:54I'd recommend using the name $frontEndController here (as mentioned in my previous comment).RecordsContentObject.php:141I'd recommend using the name $frontEndController here (as mentioned in my previous comment).RestoreRegisterContentObject.php:32I'd recommend using the name $frontEndController here (as mentioned in my previous comment).TypoScriptFrontendController.php:389We can drop the @var as it's redundant with the native type declaration.
-
Oliver Hader uploaded patch set 13 06/29/22, 12:53
-
Oliver Hader commented on patch set 12 06/29/22, 12:53
AbstractContentObject.php:68ReplyDoneContentContentObject.php:38ReplyDoneContentObjectArrayInternalContentObject.php:40ReplyDoneHierarchicalMenuContentObject.php:42ReplyDoneImageResourceContentObject.php:34ReplyDoneLoadRegisterContentObject.php:32ReplyDoneAbstractMenuContentObject.php:349ReplyDoneAbstractMenuContentObject.php:1744ReplyDoneTextMenuContentObject.php:50ReplyDoneRecordsContentObject.php:54ReplyDoneRecordsContentObject.php:141ReplyDoneRestoreRegisterContentObject.php:32ReplyDoneTypoScriptFrontendController.php:389ReplyDone -
core-ci voted on patch set 13 V -1 06/29/22, 13:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28488
-
Oliver Hader commented on patch set 13 V -1 06/29/22, 13:01
FilesContentObjectDataSet.csv:21This is strange - why had `sorting_foreign` database assertions to be changed? -
Oliver Hader uploaded patch set 14 06/29/22, 13:08
-
Stefan Bürk commented on patch set 13 06/29/22, 13:08
FilesContentObjectDataSet.csv:21ReplySee comment from Nikita - think that answers that (was courious about this too): https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681/4/typo3/sysext/frontend/Tests/Functional/ContentObject/DataSet/FilesContentObjectDataSet.csv#20 Not changed as mantandory, in the end technical correct to fill in correct foreign sorting thou. -
Oliver Hader commented on patch set 14 06/29/22, 13:10
FilesContentObjectDataSet.csv:21ReplyHm, okay... did not spot that earlier... I removed these changes in the test scenario CSV. Changing the sorting values there, probably would be a separate patch. -
Stefan Bürk commented on patch set 14 06/29/22, 13:11
FilesContentObjectDataSet.csv:21ReplyFull ack on that. Let's "fix" the csv in a dedicated patch making it clear. -
core-ci voted on patch set 14 V -1 06/29/22, 13:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28489
-
core-ci commented on patch set 14 06/29/22, 15:45 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28489
-
Oliver Hader commented on patch set 14 06/29/22, 16:03
FilesContentObjectDataSet.csv:21ReplyOk, these failing tests in Postgres drive me crazy... I extracted the test scenario changes to https://review.typo3.org/q/Ie3bbeb75405cc561c27f5ce12d1c70954d79c3b7 - let's see... I just want to know, why tests are suddenly failing in one particular env... -
Oliver Hader rebased onto patch set 15 06/29/22, 16:11
-
core-ci voted on patch set 15 V +1 06/29/22, 16:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28507
-
Oliver Klee commented on patch set 15 CR +1 06/29/22, 16:23
Neat! -
Stefan Bürk commented on patch set 15 06/29/22, 18:09
FilesContentObjectDataSet.csv:21ReplyThese tests not - as they are not "testing" for the foreign sort. (but still providing invalid values are not good). So thanks for the extraction of them. Generally, MySQL/MariaDB and even SQLite "magicly" adds the primary key of a table as "last sort" critera which generate's a deterministic sort order. PostgresSQL does this not. So it's mandatory to ensure "deterministic" sorting orders. If this is not given, it fallbacks to "randamzing" it and sometimes failing, sometimes not etc. But's out of scope for this patch however. Hope quick hint is okay - if you want more insight we may have a call oder talk on the dev days about it. -
Oliver Hader commented on patch set 15 V +1 CR +1 07/01/22, 13:38
FilesContentObjectDataSet.csv:21ReplyThanks for the explanation. I had the similar feeling, now that you mention it, I know it :) -
Christian Kuhn commented on patch set 15 07/01/22, 19:32
AbstractContentObject.php:46i'd expect that a single cObj *always* knows the parent COR. why is that optional now? -
Christian Kuhn commented on patch set 15 07/01/22, 22:02
AbstractContentObject.php:46ReplyDone -
Benni Mack commented on patch set 15 07/04/22, 15:25
AbstractContentObject.php:46ReplyI don't think there is another way currently around it. Had a brief checkout of the patch... main issue is that $this->cObj __could_ be null as well. We could however do a fallback $this->cObj ?? new ContentObjectRenderer() -
Benni Mack uploaded patch set 16 07/05/22, 10:37
-
Oliver Klee commented on patch set 16 CR +1 07/05/22, 10:42
AbstractContentObject.php:46ReplyDone -
core-ci voted on patch set 16 V +1 07/05/22, 10:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28659
-
Oliver Hader voted on patch set 16 V +1 CR +1 07/05/22, 11:52
-
Benni Mack voted on patch set 16 V +2 CR +2 07/05/22, 11:56
-
Benni Mack merged patch set 17 07/05/22, 11:56
AbstractContentObject.php:67