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.

Issue fork drupal-3194165

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch created an issue. See original summary.

catch’s picture

Matroskeen made their first commit to this issue’s fork.

Matroskeen’s picture

Thanks for creating a follow-up issue, @catch!
It's probably way too early to publish a patch, but let it be.

Kristen Pol’s picture

Thanks 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.

Kristen Pol’s picture

Status: Needs review » Postponed

Per @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.

Matroskeen’s picture

Issue summary: View changes
Status: Postponed » Reviewed & tested by the community
  1. Unpostponing (10.x branch is open);
  2. Moving to RTBC per #6 (tests pass on 10.x);
alexpott’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +10.0.0 release notes

I linked up the old CR.

Committed 8997ab6 and pushed to 10.0.x. Thanks!

  • alexpott committed 8997ab6 on 10.0.x
    Issue #3194165 by Matroskeen, catch, Kristen Pol: Stop passing empty $...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

xjm’s picture

Status: Closed (fixed) » Needs work
Issue tags: +Needs release note

This 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!

xjm’s picture

The attached CR is also still in a draft state.

Matroskeen’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs release note

Added 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.

Feuerwagen’s picture

Status: Needs review » Reviewed & tested by the community

CR 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 :)

catch’s picture

Status: Reviewed & tested by the community » Fixed

Yep, back to fixed.

xjm’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.