- Issue created by @wim leers
- First commit to issue fork.
- Merge request !4636Issue #3382581: Add new `EntityBundleExists` constraint β (Closed) created by phenaproxima
- last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,058 pass - last update
about 1 year ago 30,030 pass, 14 fail - last update
about 1 year ago 30,026 pass, 16 fail - last update
about 1 year ago 30,043 pass, 12 fail - last update
about 1 year ago 30,043 pass, 12 fail - last update
about 1 year ago 30,049 pass, 6 fail - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,062 pass, 2 fail - last update
about 1 year ago 30,063 pass - last update
about 1 year ago 30,066 pass - last update
about 1 year ago 30,066 pass - Assigned to wim leers
- Status changed to Needs review
about 1 year ago 2:36am 29 August 2023 - Assigned to phenaproxima
- Status changed to Needs work
about 1 year ago 8:46am 29 August 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Looking great!
AFAICT this is ready once:
FieldConfig
also adopts it π- one more edge case gets test coverage
- a change record exists?
- last update
about 1 year ago 30,029 pass, 18 fail - last update
about 1 year ago 30,058 pass, 6 fail - last update
about 1 year ago 30,071 pass - last update
about 1 year ago 30,071 pass - last update
about 1 year ago 30,059 pass, 2 fail - last update
about 1 year ago 30,072 pass - πΊπΈUnited States phenaproxima Massachusetts
Drafted a change record: https://www.drupal.org/node/3384086 β
- Assigned to wim leers
- Status changed to Needs review
about 1 year ago 4:02pm 29 August 2023 - Assigned to phenaproxima
- Status changed to Needs work
about 1 year ago 9:27am 30 August 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Looking good!
Only one concern: we can't just make
\Drupal\Core\Config\TypedConfigManager::replaceVariable()
public β doing that is a BC break. Posted a proposal on the MR! π - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,143 pass - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,143 pass - last update
about 1 year ago 30,143 pass - last update
about 1 year ago 30,143 pass - last update
about 1 year ago 30,143 pass - Assigned to wim leers
- Status changed to Needs review
about 1 year ago 4:08pm 1 September 2023 - Assigned to phenaproxima
- Status changed to Needs work
about 1 year ago 1:02pm 4 September 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
- I did a review in which I tried to RTBC this. And in doing so, I discovered the existence of
\Drupal\Core\Entity\Plugin\Validation\Constraint\BundleConstraint
(introduced in #1845546: Implement validation for the TypedData API β , with a follow-up that I just pushed forward after >10 years of silence: π Enforce the bundle constraint option to be always an array Needs work ).I think we should document what the difference is between the (existing)
Bundle
and (new)BundleExists
.AFAICT
BundleConstraint
should never have existed β¦ it should just have used theChoice
constraint instead?! It has existed since 2010, so it's not like it wasn't available π - The IS does not mention the introduction of
\Drupal\Core\Config\Schema\TypeResolver
and why we do that. - Most of my remarks on the MR are about exposing the whole
[%parent.something]
syntax including the square brackets to users of validation constraints. We shouldn't do that IMHO β the resulting YAML is very tricky to misread as an array π Also, we just don't need it!
This issue is very close IMHO! π€©
- I did a review in which I tried to RTBC this. And in doing so, I discovered the existence of
- last update
about 1 year ago 30,145 pass - last update
about 1 year ago 30,141 pass, 1 fail - last update
about 1 year ago 30,145 pass - Issue was unassigned.
- Status changed to Needs review
about 1 year ago 2:27pm 5 September 2023 - Status changed to RTBC
about 1 year ago 1:53pm 14 September 2023 - last update
about 1 year ago 28,004 pass, 763 fail - last update
about 1 year ago 30,170 pass - Status changed to Needs work
about 1 year ago 1:29pm 18 September 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
So very close, but this is still missing test coverage for invalid
entityTypeId
option values to ensure a good DX for developers adopting this validation constraint! - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,108 pass, 6 fail - last update
about 1 year ago 30,154 pass, 3 fail - Assigned to wim leers
- Status changed to Needs review
about 1 year ago 6:30pm 25 September 2023 - πΊπΈUnited States phenaproxima Massachusetts
OK, I tried to add the requested test coverage. How's this look?
- last update
about 1 year ago 30,155 pass, 3 fail - last update
about 1 year ago CI aborted - last update
about 1 year ago 30,198 pass, 1 fail - last update
about 1 year ago 30,218 pass - Status changed to RTBC
about 1 year ago 10:41am 10 October 2023 - π§πͺBelgium borisson_ Mechelen, π§πͺ
Back to rtbc, I really love how many of our tests are now more complete/explicit because of this new contraint.
As a sidenote, do we allow % in our schema's for things that are not replaceable? Because if we don't, we could probably throw an error and tell people something like: %paren found in resolved schema, there is a typo in your schema definition..
But that can 100% be a followup to this, what we have in this issue is already an improvement.
- last update
about 1 year ago 30,390 pass, 2 fail - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
#18: WRT that validation: I said the same thing at #16 3 weeks ago. But I agree that can happen in a follow-up, especially because it's A) a pre-existing problem, B) in pre-existing code.
So, created the necessary follow-up: π [PP-1] Validate inputs of config schema's TypeResolver: only allow %parent, %type and %key Postponed .
RTBC++
28:27 26:48 Running- Issue was unassigned.
- last update
about 1 year ago 30,407 pass - last update
about 1 year ago 30,421 pass - last update
about 1 year ago 30,427 pass - last update
about 1 year ago 30,435 pass - last update
about 1 year ago 30,436 pass - last update
about 1 year ago 30,445 pass - last update
about 1 year ago 30,448 pass - last update
about 1 year ago 30,473 pass, 1 fail - last update
about 1 year ago 30,491 pass - last update
about 1 year ago 30,493 pass 58:27 54:01 Running- last update
about 1 year ago 30,496 pass - last update
about 1 year ago 30,503 pass - last update
about 1 year ago 30,526 pass - last update
about 1 year ago 30,529 pass - last update
about 1 year ago 30,540 pass - last update
12 months ago 30,564 pass - last update
12 months ago 30,612 pass - last update
12 months ago 30,614 pass - last update
12 months ago 30,615 pass - last update
12 months ago 30,677 pass - last update
12 months ago 30,685 pass 58:27 54:27 Running- last update
12 months ago 30,694 pass - last update
12 months ago 30,698 pass - π³πΏNew Zealand quietone
I read the issue summary, which was complete and easy to follow, and the comments. I didn't find any unanswered questions or other work to do. There are 2 unresolved comments from @Wim Leers in the MR but they have been addressed and @Wim Leers agreed this is RTBC.
The change record is up to date. Although I do wonder how people, for who English is a second language will interprets "There's a new validation constraint in town".
I did some hunting and found this quote from the Content style guide β
Avoid slang terms. Be sure any English-language idioms you use are common and well-known. This benefits all readers, but especially Drupal users with a first language other than English.
I am not sure how one is supposed to know that an idiom is common and well-know but we should probably remove that from the change record. It would help is someone changed that. I don't think the use of 'in town' makes the change record unintelligible so I am leaving this at RTBC.
- π§πͺBelgium borisson_ Mechelen, π§πͺ
Rewritten the first two lines based on #22:
We have introduced a new Validation Constraint with: EntityBundleExists.
This constraint takes the name of an entity bundle and confirms that it actually exists. It accepts only one (required) argument -- the entity type ID. - last update
12 months ago 30,698 pass - last update
11 months ago 30,706 pass - last update
11 months ago 30,707 pass - last update
11 months ago 30,708 pass - last update
11 months ago 30,722 pass - Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
11 months ago Not currently mergeable. - Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
11 months ago Not currently mergeable. - Status changed to Needs work
11 months ago 10:12am 17 December 2023 - π§πͺBelgium borisson_ Mechelen, π§πͺ
This needs a reroll, it no longer applies.
- Status changed to RTBC
11 months ago 12:38pm 17 December 2023 - π§πͺBelgium borisson_ Mechelen, π§πͺ
Merged 11.x back into this, back to rtbc.
- Status changed to Needs work
11 months ago 1:15pm 17 December 2023 - π§πͺBelgium borisson_ Mechelen, π§πͺ
It looks like I screwed up something with the merge I did. I will try to fix this.
- π§πͺBelgium borisson_ Mechelen, π§πͺ
The typeResolver that was introduced here (in TypedConfigManager), conflicts with other changes that been committed to 11.x in the meanwhile. I'm not sure how to best resolve this.
One of the breaking changes is in π Consistently use "dynamic type name" and "expression" instead of "variable value" in TypedConfigManager's terminology Fixed .
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
@borisson_: π Consistently use "dynamic type name" and "expression" instead of "variable value" in TypedConfigManager's terminology Fixed renamed
TypedConfigManager::replaceName()
and::replaceVariable()
to:: resolveDynamicTypeName()
and::resolveExpression()
, respectively. But it kept themprotected
.This issue was lifting those 2 methods out of that class and making them
public
.I think we can still do the exact same thing: just make them
static
, move them out ofTypedConfigManager
and intoTypeResolver
, and make bothpublic
. That allows not breaking backwards compatibility. - Status changed to RTBC
11 months ago 3:48pm 18 December 2023 - πΊπΈUnited States phenaproxima Massachusetts
Did the stuff Wim explained in #28. Since this was basically just fixing merge conflicts, I'm restoring RTBC on the assumption that tests will pass.
- π§πͺBelgium borisson_ Mechelen, π§πͺ
Thanks for fixing that @phenaproxima!
- Status changed to Needs work
11 months ago 5:08pm 18 December 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
phpcs
andphpstan
violations.TypeResolve
andTypedConfigManager
look solid in the MR though! - π§πͺBelgium borisson_ Mechelen, π§πͺ
Actually, it's not a simple phpstan violation, it's because this entire else branch doesn't return anything, I think this means we are missing test coverage?
else { // Get nested value and continue processing. if ($name == '%parent') { /** @var \Drupal\Core\Config\Schema\ArrayElement $parent */ // Switch replacement values with values from the parent. $parent = $data['%parent']; $data = $parent->getValue(); $data['%type'] = $parent->getDataDefinition()->getDataType(); // The special %parent and %key values now need to point one level up. if ($new_parent = $parent->getParent()) { $data['%parent'] = $new_parent; $data['%key'] = $new_parent->getName(); } } else { $data = $data[$name]; }
I fixed the phpcs failures.
- πΊπΈUnited States phenaproxima Massachusetts
That code is moved directly from the pre-existing methods
\Drupal\Core\Config\TypedConfigManager::resolveDynamicTypeName()
and\Drupal\Core\Config\TypedConfigManager::resolveExpression()
. I don't think any action is needed; this issue is only exposing those methods in a new class, but not changing them in any other way.IMHO, if PHPStan is complaining about this, the correct approach is probably to shut it up here.
- π§πͺBelgium borisson_ Mechelen, π§πͺ
I agree with @phenaproxima, we can change the phpstan configuration later, or help it figure out what is going in here later, but I think this should just be the move.
I will try to pick this up after work
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
AFAICT this means we must update the PHPStan baseline?
- πΊπΈUnited States phenaproxima Massachusetts
I would adjust the baseline but I don't know how to do it. I tried editing the file manually but it doesn't seem to work properly. What am I missing?
- Status changed to Needs review
11 months ago 3:08pm 3 January 2024 - πΊπΈUnited States phenaproxima Massachusetts
Okay, well, after some wrasslin' I was finally able to get PHPStan to ignore that one error. However, once I got the regex correct, PHPStan had this to say:
Error message "Method Drupal\Core\Config\Schema\TypeResolver::resolveExpression() should return string but return statement is missing." cannot be ignored, use excludePaths instead.
Well...shit. So I ended up just ignoring that one path entirely, and PHPStan worked for me locally with no errors.
- Status changed to Needs work
11 months ago 5:29pm 3 January 2024 - πΊπΈUnited States phenaproxima Massachusetts
Back to work for the test failures.
- Status changed to Needs review
11 months ago 7:10pm 3 January 2024 - Status changed to RTBC
11 months ago 7:22pm 3 January 2024 - π§πͺBelgium borisson_ Mechelen, π§πͺ
- last update
11 months ago 25,917 pass, 1,847 fail - Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
10 months ago Not currently mergeable. - Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
10 months ago Not currently mergeable. - Status changed to Needs work
10 months ago 9:36pm 7 January 2024 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Left some comments on the MR
- Status changed to Needs review
10 months ago 6:59pm 8 January 2024 - Status changed to RTBC
10 months ago 2:21pm 9 January 2024 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
AFAICT everything was thoroughly addressed. I'm not a big fan of changing the decade-old logic that we're just lifting from elsewhere and making accessible, but it sure is more readable, and it was requested by core committer @larowlan so π Two birds one stone!
Clarifying that this blocks π [PP-1] Convert field_storage_config and field_config's form validation logic to validation constraints Postponed , which is . It also blocks π± [meta] Add constraints to all config entity types Active . This priority seems justified IMO.
- Status changed to Needs work
10 months ago 10:38pm 30 January 2024 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Can we get https://www.drupal.org/node/3408266 β updated to reflect the code, the method names haven't been renamed, they've been moved to a new TypeResolver class.
Fine to self RTBC, will keep an eye out for the update.
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Also left a comment about phpstan changes
- Status changed to RTBC
10 months ago 1:15am 31 January 2024 - πΊπΈUnited States phenaproxima Massachusetts
Tried to answer your questions, @larowlan, and updated the change record.
- Status changed to Needs review
10 months ago 4:02am 31 January 2024 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Added a change to fix the missing return type, please put back to RTBC if you're happy
- Status changed to RTBC
10 months ago 6:08am 31 January 2024 - πΊπΈUnited States phenaproxima Massachusetts
Yup, I'm a lot happier without needing to mess with PHPStan's configuration! Thanks @larowlan.
-
larowlan β
committed 89ec081a on 11.x
Issue #3382581 by phenaproxima, borisson_, larowlan, Wim Leers, quietone...
-
larowlan β
committed 89ec081a on 11.x
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Committed to 11.x
Published both change records - Status changed to Fixed
10 months ago 7:53am 31 January 2024 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Thank you, @larowlan!
Unblocked & rerolled:
- #3392903-9: Validate inputs of TypeResolver::resolveExpression(): only allow %parent, %type and %key β
- #3324140-35: Convert field_storage_config and field_config's form validation logic to validation constraints β
- #1905620-23: Enforce the BundleConstraint "bundle" option to be always an array β
Automatically closed - issue fixed for 2 weeks with no activity.