Problem/Motivation

phpstan (https://git.drupalcode.org/project/image_field_to_media/-/jobs/10988841) reports this problem:

 ------ ----------------------------------------------------------------------- 
  Line   image_field_to_media.module                                            
 ------ ----------------------------------------------------------------------- 
  19     Function image_field_to_media_entity_operation() implements            
         hook_entity_operation but is missing the CacheableMetadata parameter   
         added in Drupal 11.3. Update the signature to:                         
         image_field_to_media_entity_operation(\Drupal\Core\Entity\EntityInter  
         face $entity, \Drupal\Core\Cache\CacheableMetadata $cacheability).     
         🪪  drupal.proceduralHookEntityOperationMissingCacheabilityParameter   
         💡  See https://www.drupal.org/node/3533080                            
 ------ ----------------------------------------------------------------------- 

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

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:

Comments

prudloff created an issue. See original summary.

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

dkmishra’s picture

Status: Active » Needs review

Please review.

  • fe8d6cf2 committed on 3.0.x
    Issue #3613622: Fixed Outdated hook_entity_operation signature
    
wombatbuddy’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

prudloff’s picture

Shouldn't we do something with the $cacheability object to ensure the result is correctly cached? For example add the user.permissions cache context.

dkmishra’s picture

Good catch, thanks @prudloff — you're right, this needs the user.permissions cache context since the result depends on the current user's permission check.

function image_field_to_media_entity_operation(
  EntityInterface $entity,
  CacheableMetadata $cacheability,
): array {
  $cacheability->addCacheContexts(['user.permissions']);

Status: Fixed » Closed (fixed)

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