IBX-12192: Added SiteAccess::MATCHING_TYPE_UNINITIALIZED constant - #796
Conversation
Replaces the 'uninitialized' magic string used for the placeholder SiteAccess wired into the container before request matching happens, so consumers (e.g. ibexa/messenger) can detect it without duplicating the literal.
setSiteAccess() accepts and assigns null, but the property was typed as non-nullable SiteAccess, causing a TypeError.
…sRelation() against null SiteAccess Making SiteAccessService::$siteAccess properly nullable exposed a real gap: getSiteAccessesRelation() fell back to $this->siteAccess without checking it could be null, and would then call ->name on it.
|
Points CI at the ibexa/core branch that adds SiteAccess::MATCHING_TYPE_UNINITIALIZED, so this PR's tests can run before that PR merges. Must be removed before merging.
konradoboza
left a comment
There was a problem hiding this comment.
Can we have some test coverage for this?
If the calling code didn't have tests, it would mean introducing a whole out-of-scope test. In general, since I'd prefer to move away from having an "uninitialized" SiteAccess service, I don't find it worthwile. I have a different plan for this. In simple terms, I want to make all services reliant on |
ibexa/core#796 merged, so ibexa/core's ~4.6.x-dev now resolves the SiteAccess::MATCHING_TYPE_UNINITIALIZED constant on its own.




Related PRs:
Description:
SiteAccess::$matchingTypeuses the magic string'uninitialized'in a couple of places (ConfigResolver's scope-change checks, and the service wiring for the placeholderSiteAccessinstance) as the sentinel for "this SiteAccess was never actually matched from a request." AddedSiteAccess::MATCHING_TYPE_UNINITIALIZEDso that check has a name instead of a repeated literal, and so other packages can compare against it without hardcoding the string.Also fixed
SiteAccessService::$siteAccess— it got typed as non-nullableSiteAccessin the same pass, butsetSiteAccess()still accepts and assignsnull, so that threw aTypeError(caught bySiteAccessServiceTest::testGetCurrentSiteAccess). Made it?SiteAccessagain.This unblocks the
ibexa/messengerfix above, which needs to detect an uninitialized SiteAccess to avoid stamping console-dispatched messages with a bogus SiteAccess name.