Problem/Motivation
Follow up from #1845546-121: Implement validation for the TypedData API
Maybe also improve how we deal with multiple-bundle metadata here?
Steps to reproduce
N/A
Proposed resolution
See #20 + #23.
Remaining tasks
Determine if this change should be made see #1845546-121: Implement validation for the TypedData API and #35
User interface changes
None.
API changes
Passing a string value to the Bundle constraint's bundle option is no longer allowed; it triggers a deprecation in Drupal 10.3 and will trigger an error in Drupal 11.
Data model changes
None.
Release notes snippet
None.
| Comment | File | Size | Author |
|---|
Issue fork drupal-1905620
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:
- 1905620-bundle-constraint
changes, plain diff MR !6408
Comments
Comment #1
fagotagging
Comment #2
fagoComment #15
smustgrave commentedIf still a valid task wonder if the issue summary could be updated please.
Comment #16
wim leersI stumbled upon this from another issue.
This issue exists to address @effulgentsia's feedback at #1845546-121: Implement validation for the TypedData API and @fago argued at #1845546-122: Implement validation for the TypedData API it should be done in a follow-up. This is that follow-up.
But this issue predates us having solid strategies for making changes like that happen.
So … this must do a deprecation. Although AFAICT nothing in core is even using this anymore, with the exception of
\Drupal\KernelTests\Core\Entity\BundleConstraintValidatorTest::assertValidation(). Not even\Drupal\Tests\Core\Plugin\Context\EntityContextDefinitionIsSatisfiedTest::providerTestIsSatisfiedByPassBundledEntity(). Let's find out!Comment #18
wim leersWe could totally continue with #16 here.
But as I wrote at #3382581-12: Add new `EntityBundleExists` constraint:
… maybe the correct course of action here is to:
Bundlealtogether and switch toChoiceBundlean alias ofChoice.Note that
Choicewas explicitly added to Drupal core in #3373653: Add a `langcode` data type to config schema — lots of things in Drupal core already use it!Comment #19
andypostCurious how it will affect existing code which is using
Bundlein block annotationsComment #20
smustgrave commentedOf the 2 options
1. Deprecate Bundle altogether and switch to Choice
2. Alternatively, make Bundle an alias of Choice.
Think 1 makes the most sense.
Making an alias even though it should cover backwards compatibility, think the idea of having 2 constraints around that do the same could be confusing to some.
Comment #22
wim leers#3382581: Add new `EntityBundleExists` constraint landed!
#20: I agree. Except that the validation error message for
Bundlekinda makes more sense. Still, let's find out how much change it would cause if we actually removed this constraint.Comment #23
wim leersIn trying to do #21, I discovered I was wrong in #18.
Choiceworks at the (property) value level.Bundleworks at the entity object (EntityAdapterto be exact) level.Change record created for just this tiny deprecation.
P.S.: @effulgentsia wrote #1845546-121: Implement validation for the TypedData API.1 (which triggered this issue) exactly 11 years ago today.
Comment #24
smustgrave commentedRan test-only feature and got a failure, see https://git.drupalcode.org/issue/drupal-1905620/-/jobs/723178
Updated the CR slightly to include an example, for visual people like myself.
Code looks good to me.
Comment #25
wim leersThanks! The changes to the change record weren't quite accurate though, so fixed that. Please check it again and see if you like it? :)
Comment #26
catchI think the deprecation here should probably be for 12.0.0 now unless we really need to drop it in 11.x per discussion in #3410492: Defer disruptive 10.3 deprecations for removal until 12.0.
Comment #27
wim leersIs this truly disruptive? It's a trivial change that modules can make today and it'd work fine all the way back to Drupal 8? 🤔
P.S.: following that issue now — very interesting!
Comment #28
borisson_I would like to move this back to RTBC and say this isn't truly disruptive, but I actually think it is, we don't know how custom entities look and for them they it would be a change.
Should be simple enough to just update the number in the deprecation
Comment #29
wim leers👍 Let's do that.
Comment #30
smustgrave commentedProbably fine to self RTBC after that update.
Comment #31
catchThis is very true, but if they're minimally/under-maintained and already have Drupal 11 compatible releases (or if they don't need any other changes other than .info.yml so far), then it's disruptive for sites trying to update to Drupal 11 and finding out modules aren't compatible. You only need one or two modules not ready to delay a site update, and those modules only need one or two small deprecations preventing a fully 11.x-compatible release to be the ones that cause the delay - so lots of small core deprecations can add up.
For internal stuff where the bc we add is 'best effort' anyway like constructor changes, we definitely shouldn't apply this, especially because multiple changes to the same constructor gets cumulatively harder to account for. But public API breaks where the bc layer is easy, I think it's nicer to do this for the few months before the major release - if it's likely to cause pain, we can always decide the other way.
Comment #32
wim leers👍 Thanks for that extra context, @catch!
Comment #34
quietone commentedRebased and updated the deprecation notice.
Comment #35
longwaveI don't get why we need to do this. DX is slightly nicer if developers can pass a string in the simple case or an array of strings otherwise. Given it's been over 10 years since this was proposed are there better things to work on?
Comment #36
smustgrave commentedRegarding #35 believe that should be answered by committer team?
But looking at the MR believe all feedback has been addressed.
Comment #37
quietone commentedThere is one question remaining, which is whether to do this or not. See the remaining tasks in the issue summary.
Comment #38
catchAgreed with #35, I think we should mark this 'by design' and just support a single bundle or an array. There's no justification given in the issue summary or in @effulgentsia's original comment which is just one sentence of a larger review.
Comment #39
quietone commentedThis has been waiting for 7 months for a justification for this change. None has been given, so I am closing this issue.
If there is a reason to do this that has been missed, add an explanatory comment and set the status to 'Active'.