Review main Abandoned

74507[BUGFIX] Use SiteInterface instead of Site as type declaration

Georg Ringer CR 0 V 0 Hard +177 −97 updated 01/13/23, 19:22

Commit message

Using the SiteInterface instead of the specific Site makes it possible
to use other implementations and avoids errors if NullSite is used.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 35

Show 15 more files

Review log 3241

Show 1216 earlier messages
  1. Georg Ringer uploaded patch set 1 05/03/22, 21:51

  2. Georg Ringer commented on patch set 1 05/03/22, 21:51

    This change is ready for review.
  3. Benni Mack commented on patch set 1 05/03/22, 21:54

    Should this go into 11.5 as well? Can we somehow add a test (I guess functional or acceptance) so this won't happen anymore? Also: I think we have a TSFE->getSite() method which we should check as well.
  4. core-ci voted on patch set 1 V -1 05/03/22, 21:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26777

  5. Georg Ringer commented on patch set 1 05/03/22, 22:05

    not so sure if this can be breaking for sites on 11?
  6. Georg Ringer uploaded patch set 2 05/03/22, 22:09

  7. core-ci voted on patch set 2 V -1 05/03/22, 22:19 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26778

  8. Georg Ringer uploaded patch set 3 05/03/22, 22:23

  9. core-ci voted on patch set 3 V -1 05/03/22, 22:54 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26779

  10. Josef Glatz commented on patch set 3 05/04/22, 05:01

    Reply

    will check if this can happen in v11 too.
  11. Josef Glatz commented on patch set 3 CR -1 05/04/22, 05:33

    not readable. some word is missing
  12. Georg Ringer updated the commit message in patch set 4 05/04/22, 06:33

  13. core-ci voted on patch set 4 V -1 05/04/22, 06:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26785

  14. Georg Ringer uploaded patch set 5 05/04/22, 07:19

  15. Benjamin Franzke commented on patch set 5 05/04/22, 07:41

    If we want to use this consequently, then there are more places to adapt: git grep ": Site$" typo3/sysext/core/Classes/Routing/Aspect/SiteAccessorTrait.php: public function getSite(): Site typo3/sysext/core/Classes/Site/SiteFinder.php: public function getSiteByRootPageId(int $rootPageId): Site typo3/sysext/core/Classes/Site/SiteFinder.php: public function getSiteByIdentifier(string $identifier): Site typo3/sysext/core/Classes/Site/SiteFinder.php: public function getSiteByPageId(int $pageId, array $rootLine = null, string $mountPointParameter = null): Site typo3/sysext/core/Tests/Unit/Localization/LocalesTest.php: private function createSiteWithDefaultLanguage(string $locale): Site typo3/sysext/core/Tests/Unit/Site/Entity/SiteLanguageTest.php: private function createSiteWithLanguage(array $languageConfiguration): Site typo3/sysext/frontend/Classes/Event/FilterMenuItemsEvent.php: public function getSite(): Site typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTestTrait.php: private function createSiteWithLanguage(array $languageConfiguration): Site typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php: private function createSiteWithDefaultLanguage(array $languageConfiguration): Site typo3/sysext/frontend/Tests/Unit/Http/RequestHandlerTest.php: private function createSiteWithLanguage(): Site typo3/sysext/frontend/Tests/Unit/Plugin/AbstractPluginTest.php: private function createSiteWithDefaultLanguage(): Site git grep "Site \\$" typo3/sysext/backend/Tests/Functional/Form/FormDataProvider/TcaCategoryTest.php: public function addDataOverridesDefaultFieldConfigurationBySiteConfig(string $inputStartingPoints, string $expectedStartingPoints, Site $site): void typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectTreeItemsTest.php: public function addDataHandsSiteConfigurationOverToTableConfigurationTree(string $inputStartingPoints, array $expectedStartingPoints, Site $site): void typo3/sysext/core/Classes/Configuration/PageTsConfig.php: public function getWithUserOverride(int $pageId, array $rootLine, ?Site $site, ConditionMatcherInterface $conditionMatcher, BackendUserAuthentication $user = null): array typo3/sysext/core/Classes/Routing/Aspect/AspectFactory.php: * @param Site $site typo3/sysext/core/Classes/Routing/Aspect/AspectFactory.php: public function createAspects(array $aspects, SiteLanguage $language, Site $site): array typo3/sysext/core/Classes/Routing/Aspect/AspectFactory.php: * @param Site $site typo3/sysext/core/Classes/Routing/Aspect/AspectFactory.php: protected function enrich(AspectInterface $aspect, SiteLanguage $language, Site $site): AspectInterface typo3/sysext/core/Classes/Routing/PageRouter.php: * @param Site $site typo3/sysext/core/Classes/Routing/PageRouter.php: public function __construct(Site $site, Context $context = null) typo3/sysext/core/Classes/Routing/PageSlugCandidateProvider.php: public function __construct(Context $context, Site $site, ?EnhancerFactory $enhancerFactory) typo3/sysext/core/Classes/Routing/PageSlugCandidateProvider.php: * @param Site $siteOfMountedPage the site of the target page, which could be different from the current page typo3/sysext/core/Classes/Routing/PageSlugCandidateProvider.php: Site $siteOfMountedPage, typo3/sysext/core/Classes/Site/SiteAwareInterface.php: * @param Entity\Site $site typo3/sysext/core/Classes/Site/SiteAwareInterface.php: public function setSite(Site $site): void; typo3/sysext/core/Documentation/Changelog/9.5.x/Important-88720-RespectSiteForPersistedMappers.rst:requires was extended with mandatory argument `\TYPO3\CMS\Core\Site\Entity\Site $site` typo3/sysext/core/Documentation/Changelog/9.5.x/Important-88720-RespectSiteForPersistedMappers.rst: public function createAspects(array $aspects, SiteLanguage $language, Site $site): array typo3/sysext/core/Tests/Functional/Routing/Aspect/PersistedAliasMapperTest.php: private function writeSiteConfiguration(Site $site): void typo3/sysext/core/Tests/Functional/Routing/Aspect/PersistedPatternMapperTest.php: private function writeSiteConfiguration(Site $site): void typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php: * @param Site $site the current site where the configuration is based on typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php: protected function getApplicableStaticRoute(array $staticRouteConfiguration, Site $site, string $uriPath): ?array typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php: * @param Site $site typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php: protected function getPageUri(ServerRequestInterface $request, Site $site, array $urlParams): string typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php: * @param Site $site typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php: protected function resolveByType(ServerRequestInterface $request, Site $site, string $type, array $routeConfig): array typo3/sysext/frontend/Classes/Middleware/TypoScriptFrontendInitialization.php: /** @var Site $site */ typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php: * @param Site $siteOfTargetPage typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php: protected function getSiteLanguageOfTargetPage(Site $siteOfTargetPage, string $targetLanguageId): SiteLanguage typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php: * @param Site $siteOfTargetPage typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php: protected function generateUrlForPageWithSiteConfiguration(array $page, Site $siteOfTargetPage, array $queryParameters, string $fragment, array $conf): UriInterface typo3/sysext/frontend/Tests/Unit/Middleware/SiteBaseRedirectResolverTest.php: /** @var Site $site */ typo3/sysext/frontend/Tests/Unit/Middleware/SiteBaseRedirectResolverTest.php: * @param Site $site typo3/sysext/frontend/Tests/Unit/Middleware/SiteBaseRedirectResolverTest.php: Site $site, typo3/sysext/frontend/Tests/Unit/Middleware/SiteBaseRedirectResolverTest.php: * @param Site $site typo3/sysext/frontend/Tests/Unit/Middleware/SiteBaseRedirectResolverTest.php: Site $site, typo3/sysext/frontend/Tests/Unit/Middleware/SiteResolverTest.php: /** @var Site $site */ typo3/sysext/redirects/Classes/Service/IntegrityService.php: private function getAllPageUrlsForSite(Site $site): array typo3/sysext/redirects/Classes/Service/IntegrityService.php: private function getSlugsOfSubPages(int $pageId, Site $site): array git grep "Site\[\]" typo3/sysext/backend/Tests/Unit/Configuration/TranslationConfigurationProviderTest.php: * @return Site[] typo3/sysext/core/Classes/Configuration/SiteConfiguration.php: * @return Site[] typo3/sysext/core/Classes/Configuration/SiteConfiguration.php: * @return Site[] typo3/sysext/core/Tests/Functional/Routing/Aspect/PersistedAliasMapperTest.php: * @var Site[] typo3/sysext/core/Tests/Functional/Routing/Aspect/PersistedPatternMapperTest.php: * @var Site[] And then we'd also need to have the following methods as part of the interface: `getRouter(?Context $context): RouterInterface` `getAllLanguages(): array` `getAttribute(string $attributeName): mixed` Maybe we could think about adding a PageRouterFactory, instead of moving getRouter(), Benni? Anyway, I will adapt those cases for now.
  16. Benjamin Franzke uploaded patch set 6 05/04/22, 07:41

  1. core-ci voted on patch set 5 V -1 05/04/22, 07:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26790

  2. core-ci voted on patch set 6 V +1 05/04/22, 07:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26793

  3. Georg Ringer voted on patch set 6 V +1 CR +1 05/04/22, 08:22

  4. Benni Mack commented on patch set 6 05/04/22, 08:56

    Reply

    Done
  5. Josef Glatz commented on patch set 6 V +1 05/04/22, 08:57

    Reply

    Done
  6. Benni Mack commented on patch set 6 CR -1 05/04/22, 09:01

    tbh, there are reasons why there are places where "Site" is used instead of "SiteInterface" - so I think I need to verify each one of them. Changing type hints might have some ugly side-effects as well, I guess... need to check this.
  7. Benjamin Franzke commented on patch set 6 05/04/22, 12:02

    Reply

    Yea, that's true, changing return type declarations might cause issues for extended classes and return type declarations, other than that broader type declarations should be "safe". Would probably still be needed to mark this as BREAKING for the interface change. > "Site" is used instead of "SiteInterface" Yup, for that reasons I didn't change any `instanceof Site` to `instanceof SiteInterface`.
  8. Simon Schaufelberger rebased onto patch set 7 06/10/22, 11:34

  9. core-ci voted on patch set 7 V +1 06/10/22, 11:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27915

  10. Simon Schaufelberger voted on patch set 7 V +1 CR +1 06/19/22, 01:30

  11. Oliver Klee commented on patch set 8 06/19/22, 07:55

    Published edit on patch set 7.
  12. Oliver Klee voted on patch set 8 CR +1 06/19/22, 07:58

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

  14. Oliver Klee commented on patch set 8 06/19/22, 09:02

    This needs to be rebased. (The failure is unrelated and is solved by https://review.typo3.org/c/Packages/TYPO3.CMS/+/74871 .)
  15. Oliver Klee rebased onto patch set 9 06/19/22, 09:56

  16. Oliver Klee voted on patch set 9 CR +1 06/19/22, 09:56

  17. core-ci voted on patch set 9 V +1 06/19/22, 10:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28218

  18. Simon Schaufelberger voted on patch set 9 CR +1 06/19/22, 11:19

  19. Benni Mack commented on patch set 9 CR -1 06/20/22, 10:15

    As mentioned in a comment above, there are certain times where a Site is expected (and if extension authors use it with NullSite it would be wrong).
  20. Oliver Klee commented on patch set 9 06/20/22, 10:24

    Reply

    Do you know which places these are?
  21. Simon Schaufelberger commented on patch set 9 08/19/22, 10:17

    @Benni ping
  22. Benni Mack commented on patch set 9 08/19/22, 15:18

    Reply Unresolved

    Examples are: * TSFE (does not work with NullSite, only with real sites) * Page Link Builder * EXT:seo * Menu cObject * ContentObjectRenderer * EXT:core/Routing
  23. Stefan Froemken commented on patch set 9 CR -1 10/05/22, 08:50

    With the Site to SiteInterface change we allow NullSite to be valid on much more places as expected. Modifying the NullSite object to be compatible somehow it the wrong approach. As Benni wrote: "use (working) with NullSite is wrong". Can we please revert the Site to SiteInterface change and focus to the real problem?
  24. Georg Ringer abandoned the change 01/13/23, 08:26

    change is abandoned because of wrong implementation
  25. Simon Schaufelberger commented on patch set 9 01/13/23, 19:22

    what do you mean by wrong implementation? why don't you make it right then?