Problem/Motivation
Alternative approach to fix #2072945: Remove the $langcode parameter in EntityAccessControllerInterface::access() and friends.
Proposed resolution
@berdir in #2072945-56: Remove the $langcode parameter in EntityAccessControllerInterface::access() and friends:
Aren't there easier ways to prevent that, for example by making sure that $langcode is consistent with $entity, for content entities? If it's default, then replace it with the active langcode of the entity, if not, then make sure the entity is using that translation?
@plach in #2072945-58: Remove the $langcode parameter in EntityAccessControllerInterface::access() and friends:
That would be a possible alternative, but it would still require an API break: we'd need to change the default value of
$langcodetoNULL, becauseLanguageInterface::LANGCODE_DEFAULThas a very precise meaning, which is not active language, but entity default language. Only when$langcodeis not provided, we can safely rely on the active language, otherwise a developer explicitly passingLanguageInterface::LANGCODE_DEFAULTwould get an unexpected behavior. Additionally, ensuring that active language and $langcode match would either require us to make$langcodeprevail, if they don't, or throw an exception. In the first case we'd end-up ignoring the active language most of the time, unless we changed the$langcodedefault to NULL. In both cases we'd have a BC break.
Remaining tasks
- Decide whether we want to do #2072945: Remove the $langcode parameter in EntityAccessControllerInterface::access() and friends instead.
- Reviews
User interface changes
None
API changes
- The default value for the
$langcodeparameter ofEntityAccessControlHandlerInterface:access()isNULL. NodeGrantDatabaseStorageInterface::access()no longer has a$langcodeparameter.NodeInterface::prepareLangcode()is removed.
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | et-fix_access_langcode-2581721-2.patch | 13.15 KB | plach |
Comments
Comment #2
plachNote that this is the same patch posted at #2496337-75: [plach] Testing issue, so it's expected to be green.
Comment #3
wim leersI wrote my rationale in favor of the other solution at #2072945-71: Remove the $langcode parameter in EntityAccessControllerInterface::access() and friends, quoting it in full here:
Comment #4
effulgentsia commentedPer #2072945-73: Remove the $langcode parameter in EntityAccessControllerInterface::access() and friends
Comment #5
gábor hojtsyThanks all!