Problem/Motivation
#3193131: $context in hook_entity_view_mode_alter is always empty removed some stale documentation for the $context parameter to hook_entity_view_mode_alter(), which is always empty.
However, to avoid errors on modules implementing the hook, we still pass the empty parameter. We can stop passing this in Drupal 10, since modules can remove the parameter from their hook signature at any time.
Proposed resolution
Stop passing empty $context
array.
Remaining tasks
Review / commit.
Release notes snippet
hook_entity_view_mode_alter()
no longer receives the $context
argument, which was always empty arra. Existing implementations of hook_entity_view_mode_alter()
should remove the $context
argument. See the hook_entity_view_mode_alter()
change record for more details.
Comment | File | Size | Author |
---|---|---|---|
#4 | 3194165-4.patch | 742 bytes | Matroskeen |
Issue fork drupal-3194165
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
catchComment #4
MatroskeenThanks for creating a follow-up issue, @catch!
It's probably way too early to publish a patch, but let it be.
Comment #5
Kristen PolThanks for the issue and the patch.
1) Confirmed that the $context was removed in #3193131: $context in hook_entity_view_mode_alter is always empty.
2) Confirmed that the only place it is still used is in EntityViewBuilder.
3) Patch applies cleanly to 9.2.
4) Code changes look good and addresses issue summary.
5) Not sure if tests should be run yet.
Looks RTBC to me if tests pass but not sure it can be changed yet.
Comment #6
Kristen PolPer @Gábor Hojtsy, since this looks good but has to wait until the D10 branch is available, marking postponed for now. It's RTBC if tests pass once it can be tested on D10 branch.
Comment #7
MatroskeenComment #8
alexpottI linked up the old CR.
Committed 8997ab6 and pushed to 10.0.x. Thanks!
Comment #11
xjmThis is tagged for the 10.0.0 release notes, but no release note is provided. Release notes should be added to the IS before commit. Thanks!
Comment #12
xjmThe attached CR is also still in a draft state.
Comment #13
MatroskeenAdded release notes and published a change record: https://www.drupal.org/node/3193299. I also set change record branch to 10.0.x and version to 10.0.0-alpha1 - hopefully it's correct.
Comment #14
FeuerwagenCR and Release Notes snipped look good to me. At least as a developer previously unaware of this change I feel well informed and got a clear instruction what to do with my hook implementation :)
Comment #15
catchYep, back to fixed.
Comment #16
xjm