Closed (fixed)
Project:
UI Patterns (SDC in Drupal UI)
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 May 2026 at 19:29 UTC
Updated:
2 Sep 2026 at 09:25 UTC
Jump to comment: Most recent
Comments
Comment #2
pdureau commentedComment #4
pdureau commentedWorks have started with #3590492: Tidy the source plugins tags as a starting point.
Mikael, can you help us document the properties of:
When finished, let's leave it in RTBC without merging, and discuss.
Maybe the change will break ecosystem (like
ui_icons_patterns) and we will keep it for 2.1.0. Maybe it will be OK (because are DTO have ArrayAccess for example) and we can merge in 2.0.xComment #5
pdureau commentedWorking on this subject.
Comment #6
pdureau commentedFixed by introducing a (temporary?)
ArrayAccessTraitto implements<code>ArrayAccessinterface on DTOs.#3590426: Reduce the API scope of our plugin managers and #3590492: Tidy the source plugins tags must be merged first.
Comment #7
pdureau commentedThere is also
SourceInterface::getCustomPluginMetadata()methods, called only twice:$field_name = $this->getCustomPluginMetadata('field_name');inFieldValueSourceBase$property = $this->getCustomPluginMetadata('property');inFieldPropertySourceThey belong to
SourceMetadataI guess, it was forbidden when annotating the properties with comments.Does that mean they are "special" and something specific must be done?
Comment #8
pdureau commentedLet's investigate this before sending to review:
Comment #9
pdureau commentedLet's talk
Comment #10
pdureau commentedThis is the 2nd part of a three steps effort to prepare UI Patterns Next while staying in 2.0.x branch for now: https://docs.google.com/presentation/d/11NsN1c5prlWrB0AlEKOxE4q5MOFHx-N_...
#3590492: Tidy the source plugins tags must be merged first.
Added DTO classes implementing ArrayAccess:
Removed metadata:
Comment #11
pdureau commentedOopsy. The change from array to DTO is breaking Display Builder and probably other modules from ecosytem:
Because we target 2.0.x branch, we need to add a compatibility layer.
Comment #12
pdureau commentedDisplay Builder compatibility fixed:
Adding a DTO is more risky than adding an enum, we may break stuff. Let's be very careful before merging it.
Comment #14
smovs commentedHi @pdureau and @just_like_good_vibes!
I used Claude to double-check for edge cases, and it identified two potential concerns.
I added a NULL guard to getChoices() and SourcePluginBase.
There are also concerns about the metadata annotation using the wrong entity type. We currently use DerivableContextMetadata, while Claude suggested that source plugins should use SourceMetadata instead.
Claude also suggested several more invasive code changes, but I didn’t implement them without discussing them first.
Concerns identified by Claude:
1.
getChoices() — unguarded NULL->provider (DerivableContextSourceBase.php:503-507)The DerivableContext attribute now defaults metadata to NULL. Any derivable-context plugin that doesn't route through EntityFieldSourceDeriverBase (i.e. any contrib one) has metadata === NULL → fatal.
Core's two plugins both inherit a SourceMetadata, which is the only reason it's green.
2.
getCustomPluginMetadata() — unguarded property access (SourcePluginBase.php:397-403)return $plugin_definition['metadata']->{$key}; // was: guarded, returned NULL on missFatals if metadata is NULL (any non-field Source plugin) or a key is absent. Safe today only because the two callers are field sources that always have metadata — but this is a general protected helper any source subclass can call.
Comment #17
just_like_good_vibesThanks Pierre, your work surfaced many improvements to do. Thanks smovs too :)
I pushed another proposal on a separate branch, where metadata stays a plain array: 3591167-bc-harness-array-metadata (MR !537).
As we discussed, this work has several objectives:
1. Derivation backward compatibility: derived plugins must keep working across future refactors, same IDs, working plugins, correct data, proven by tests.
2. simplify and trim metadata: keep only what is strictly necessary in derived plugin definitions, less code, no per-plugin-type diversity.
3. Metadata key discipline: array preferred over object, and the remaining keys named once, not hardcoded everywhere.
4. Smaller API surface if possible
What I pushed:
- Tests first: a recorded fixture of the derived plugin IDs (entity references had no coverage at all), assertions on contexts, tags and metadata values, and a check that a stored source_id still resolves.
- Removed the metadata keys: entity_type_id, entity_bundle, field_formatter, the classification flags.
- SourceMetadataKey string enum as the single source of the key names, with a protected getMetadata() accessor. About #7: field_name and property are not special, just the only keys read at runtime.
- getCustomPluginMetadata() removed
Impact on code: -34 useful lines of codes, 2 public methods removed, more tests, 1 file added (SourceMetadataKey)
Needs review.
Comment #18
pdureau commentedThe DTO proposal was two risky for a commit targeting 2.0.x, so the new proposal is warmly welcomed. Lets' check the scope of both:
How come we have so different scopes? Can we merge the 2 scopes ? Keeping:
Or is it too ambitious/risky?
By the way, what are the classification flags?
Comment #19
just_like_good_vibesHello @pdureau,
sorry i realize my previous comment was probably too short about what !537 actually changes, so let me describe it better.
The metadata stays a plain array, same place, same nesting. Only its content shrinks:
Before:
After:
Every removed key has zero readers, in ui_patterns (and none found in drupal ecosystem).
The enum does not replace the array:
SourceMetadataKeyonly names the keys, once, andgetMetadata()reads them.About your table:
- The classification flags are configurable, editorial, parent_base and base: the same four FieldMetadata flags as in !504 , computed by
getEntityFieldsClassification()(removed in the MR) and read by nobody. So the removals of !537 are a superset of the removals of !504 .- Field metadata: kept, trimmed to type and cardinality, the only keys read at runtime.
- The
DerivableContextMetadataclass only wrapped a value parsed from the plugin ID at runtime, and !537 renames that methodparsePluginId()to say what it really does.So I believe the merge you describe is what !537 already contains: the DTO classes are the only part of !504 left out, and they are the risky part for 2.0.x.
Comment #20
pdureau commentedIndeed, i missed them (and derivable context's) because they were not expressed as enum.
Removed: none
Removed:
Removed:
Removed:
::parsePluginId()So RTBC if my understanding (expressed in the table) is right and you don't want to move field metadata keys to a PHP enum.
Comment #22
just_like_good_vibes