Canvas' hook_storage_prop_shape_alter() must allow passing cache tags β€” to know when to re-evaluate

Created on 19 September 2025, 4 months ago

Overview

Identified at https://git.drupalcode.org/project/canvas/-/merge_requests/23#note_590788 on πŸ› Calculating dependencies not including the intermediate dependencies Active .

hook_storage_prop_shape_alter() is basically the only PHP API that Canvas offers.

However, the results of this method may need to be re-evaluated based on external changes that Canvas is unaware of.

Example

\Drupal\canvas\Hook\ShapeMatchingHooks::mediaLibraryStoragePropShapeAlter() implements this hook on behalf of the media_library module.

  1. βœ… A module getting installed in Drupal automatically rebuilds caches. So the hook is executed automatically. Which means Component config entities are updated automatically with the field type+widget that should be used for "image"-shaped props. If there are >=1 MediaTypes using the image MediaSource plugin. If there's zero, Canvas sticks to its default that is guaranteed to work (the image field type+widget).
  2. πŸ› However, if there were 0 such MediaTypes the first time it ran, and then the user creates their first such MediaType, then the site incorrectly stays "stuck" on using the image field type, rather than switching to the media library widget!
  3. πŸ’‘ What's missing is the ability for hook_storage_prop_shape_alter() to convey what cache tags cause its results/conclusions to change. In the case of ShapeMatchingHooks::mediaLibraryStoragePropShapeAlter() that's the config:media_type_list cache tag.

Proposed resolution

Allow hook_storage_prop_shape_alter() to receive cache tags from the hook implementations that should cause it to be called again if those cache tags are invalidated.

User interface changes

See the example above: the πŸ› would disappear.

πŸ› Bug report
Status

Active

Version

1.0

Component

Shape matching

Created by

πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024