Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
base system
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 Jan 2019 at 16:54 UTC
Updated:
13 Feb 2019 at 12:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
gábor hojtsyComment #3
berdirNote from slack discussion:
This is a symfony 4 deprecation, we might not be able to do anything about that if we want to remain compatible with Symfony 3 but would have to add that to the excluded deprecation message list instead.
Comment #4
catchSo..
Drupal\Core\Validation\Plugin\Validation\Constraint\Email
does
static $strict = TRUE;Symfony's EmailValidator constructor looks for the static property on the constraint, and if it's there triggers the deprecation error. Symfony 3 doesn't support
static $mode = 'strict';which is the Symfony 4.1 way to do it.However, it's not a problem if we set $mode there for Symfony 4 compatibility too, so we can add that to the existing class for forwards compatibility.
This leaves two options:
1. Override Symfony's EmailValidator to not trigger the deprecation when $strict is set, so that we can support both Symfony 3 and Symfony 4 without a deprecation message.
2. What Berdir says in #1
However I also want to check that we have test coverage that enforces we're actually using the 'strict' option, so here's a couple of patches that simply do the upgrade for Symfony 4 without taking into account the Symfony 3 API.
Comment #5
catchIgnore half the comment above, somehow convinced myself it was a static property for no reason...
Since it's not, we can just override the constraint constructor and conditionally define it I think. Quick patch for that to see how it goes.
Comment #9
alexpottI think we need to call the parent constructor so that \Symfony\Component\Validator\Constraint::__construct is called. We need to navigate https://github.com/symfony/validator/blob/master/Constraints/Email.php to not trigger a deprecation but that should be possible.
Comment #10
alexpottFor #9
Comment #11
catchOK two versions (edit: actually three because I cross-posted before seeing the review and already had new patch written, but ignore the -9 patch):
1. Puts the constructor call up top then hard-codes the property as in the above patch.
2. Just uses the $options array to set the method via Constraint::__construct() which is further from our current code but closer to what I think Symfony actually wants us to do.
Comment #12
alexpottI agree that 3027871-11-constructor.patch is closer to what Symfony envisages as there is specific code in the constructor to set object properties. Looks good to me. Let's see what the bot says.
One thought:
strictly I think we should only be setting this if it is not already set since atm if you passed
['strict' => FALSE] to the constructor is would override our <code>public $strict = TRUE;and we probably want to maintain that behaviour.Comment #15
catch#12 is a good point, was going out of my way to do the opposite but you're right.
Comment #16
alexpott#15 looks great.
Comment #17
catchtypo: s/later/layer/g - no time to re-roll now but could be fixed on commit.
Comment #18
alexpottFixed #17 to make life simple.
Comment #19
jibranPatch looks good. Nice work!
Let's add the issue ID.
Comment #20
catchDo you mean this issue ID? If so I think git blame is enough. If not do you mean requiring Symfony 4? I don't think we have a specific issue for that yet but we could open one against 9.x maybe?
Comment #21
jibranYes, let's create one.
Comment #22
catchTook a look and we do actually have one #3009219: Update Symfony to 4.4 in Drupal 9.0. CNW to add a link to that in the comment, it'll make it easier to grep for some of these things when the time comes.
Comment #23
jibranHere you go.
Comment #24
volegerYep, link to #3009219: Update Symfony to 4.4 in Drupal 9.0 added.
Comment #25
gábor hojtsyLooks wonderful :)
Comment #26
gábor hojtsyHad this problem, fixed on commit:
Comment #28
gábor hojtsyThis is actually Symfony 5 compatibility :)