Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Split from #3284422: [META] Symfony 6.2 compatibility.
Drupal sets 'strict' mode on the Email constraint via a subclass, but it doesn't do this on the validator. Does this mean we've been validating in loose mode the whole time?
#3284422-30: [META] Symfony 6.2 compatibility contains a working patch, we just need to remove the unrelated hunks and post it here. Then decide between 'strict' and 'html5'.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#11 | 3307736-11.patch | 1.61 KB | catch |
| |||
#11 | 3307736-interdiff.txt | 774 bytes | catch |
Comments
Comment #2
catchComment #3
andypostNo idea how tests could be improved but it's ready
Could use explanation about why we are switching to html5 instead of 4.1(strict) but core already did this switch years ago
Comment #4
catchI think we need a follow-up to figure out why the constraint and validator can go out of sync and maybe also to reconcile the email validator service which uses egulias directly with the Symfony validator.
Comment #5
andypostFiled follow-up #3307810: Figure out how email contraint bound to egulias email validator
Comment #6
Kristen PolTagging
Comment #7
catchComment #8
alexpottThis class override can be removed when we update to SF7.
We'll never use the default mode in Drupal because our constraint is hardcoded to use the strict mode... see \Drupal\Core\Validation\Plugin\Validation\Constraint\EmailConstraint
So I think here we should default to strict too. We should make the class final and add an @internal that documents that this class will be removed when we depend on SF7.
Comment #9
alexpottAlso setting to strict forces the \Symfony\Component\Validator\Constraints\EmailValidator to use the EguliasEmailValidator validator in the same way that Drupal does.
Comment #10
catchI am fine with final/internal and defaulting to strict. But... if we default to strict, we can't remove this in Drupal 11 because Symfony's default is HTML5. Just made the language around removal a bit vague to get around this.
Comment #11
catchDiscussed a bit more with @alexpott. Given we ignore the default anyway in practice, if we go with HTML5, we can remove the sublass in 11.x, so make our lives easier.
Comment #12
andypostBack to RTBC as #8 addresed
Comment #13
alexpottCommitted and pushed c3a7a32c5d to 10.1.x and 4a67a410b0 to 10.0.x. Thanks!
Fixed the @internal indentation on commit.