Problem/Motivation

For the time being, we are tracking stable Symfony releases. The current release is 2.5.

Proposed resolution

Upgrade Symfony libraries to 2.5.

Known problems with Symfony 2.5 against Drupal 8.0.x:

Remaining tasks

Get RTBC.

User interface changes

API changes

Original report by @andyceo

CommentFileSizeAuthor
#93 update_to_symfony_2_5_0-2278353-93.patch2.09 MBcilefen
#93 interdiff-89-93.txt390.14 KBcilefen
#92 update_to_symfony_2_5_0-2278353-92.patch3.66 MBcilefen
#92 interdiff-89-92.txt1.96 MBcilefen
#92 core-only-do-not-test.patch4.4 KBcilefen
#89 update_to_symfony_2_5_0-2278353-89.patch1.91 MBcilefen
#88 update_to_symfony_2_5_0-2278353-87.patch3.42 MBcilefen
#88 core-lib-composer-only.txt4.4 KBcilefen
#86 update_to_symfony_2_5_0-2278353-86.patch2.62 MBcilefen
#86 interdiff-76-86.txt1.72 MBcilefen
#86 diff-composer-core-lib-only.txt3.43 KBcilefen
#85 diff-core-lib-composer.txt5.73 KBcilefen
#80 update_to_symfony_2_5_0-2278353-80.patch1.92 MBcilefen
#80 interdiff-76-80.txt3.73 KBcilefen
#76 update_to_symfony_2_5_0-2278353-76.patch1.91 MBcilefen
#76 interdiff-60-76.txt1.76 MBcilefen
#60 update_to_symfony_2_5_0-2278353-60.patch1.96 MBhussainweb
#58 interdiff.txt32.58 KBhussainweb
#58 update_to_symfony_2_5_0-2278353-58.patch1.96 MBhussainweb
#57 2278353-57.patch1.9 MBcilefen
#57 interdiff-53-57.txt237.38 KBcilefen
#53 2278353-53.patch1.65 MBcilefen
#49 2278353-48.patch3.38 MBcilefen
#47 2278353-47.patch2.64 MBcilefen
#40 2278353-40.patch1.67 MBjibran
#40 interdiff.txt3.16 KBjibran
#38 2278353-38.patch1.67 MBjibran
#27 symfony-2.5-2278353-27.patch1.31 MBdawehner
#20 core.patch3.16 KBdawehner
#20 interdiff.txt1.45 KBdawehner
#20 symfony_update-2278353-20.patch1.32 MBdawehner
#18 interdiff.txt658 bytesdawehner
#18 full-2278353.patch1.32 MBdawehner
#15 actual-2278353.patch1.71 KBdawehner
#15 full-2278353-15.patch1.32 MBdawehner
#11 interdiff.txt1.72 KBdawehner
#11 2278353-symfony-2__5-11.patch1.36 MBdawehner
#9 interdiff.txt1.07 KBdawehner
#9 2278353-symfony-2__5.patch1.35 MBdawehner
#7 update_symfony.patch1.35 MBandyceo
#1 symfonyandco25.patch2.25 MBandyceo

Comments

andyceo’s picture

Issue tags: +vendor
StatusFileSize
new2.25 MB

Step 1 done:

1. Just run 'composer update' and save result to patch.

andyceo’s picture

Status: Active » Needs review
andypost’s picture

Component: other » base system

There's no cons made in #2161397: Update to Symfony 2.4.1 about stable version, so just following and +1 to rtbc

znerol’s picture

Likely needs a reroll after #2276119: Upgrade Guzzle to version 4.1.0

dawehner’s picture

@andyceo
I guess we want to avoid to update all external dependencies ... let's try to just update the symfony components.

dawehner’s picture

Status: Needs review » Needs work

Based upon my last review.

andyceo’s picture

Status: Needs work » Needs review
StatusFileSize
new1.35 MB

Okey. It's better to be done later then never :)

First, I updated composer.json file for the only "symfony/*" projects: I updated version for all of them to 2.5.*

Second, I add to composer.json missing project "symfony/debug".

And last, I run:

composer update symfony/class-loader symfony/css-selector symfony/dependency-injection symfony/event-dispatcher symfony/http-foundation symfony/http-kernel symfony/routing symfony/serializer symfony/validator symfony/yaml symfony/debug

from the drupal root.

Let see what testbot says...

Status: Needs review » Needs work

The last submitted patch, 7: update_symfony.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.35 MB
new1.07 KB

Wow symfony 2.5 is indeed not 100% BC compatible.

Status: Needs review » Needs work

The last submitted patch, 9: 2278353-symfony-2__5.patch, failed testing.

dawehner’s picture

StatusFileSize
new1.36 MB
new1.72 KB

This really naive approach lead to not working saving of entities.

Added an issue on https://github.com/symfony/symfony/issues/11393#issuecomment-49033154 but i basically have no fucking clue.

andyceo’s picture

Status: Needs work » Needs review

seems need to change status

Status: Needs review » Needs work

The last submitted patch, 11: 2278353-symfony-2__5-11.patch, failed testing.

dawehner’s picture

Assigned: Unassigned » dawehner

working on it.

dawehner’s picture

Assigned: dawehner » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.32 MB
new1.71 KB

It turns out that there is a BC layer we can use, so I opened a follow up to adapt our code: #2307687: Update the metadata-typedata-validation code to use the 2.5 api

The last submitted patch, 15: full-2278353-15.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 15: actual-2278353.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.32 MB
new658 bytes

Okay, we need to be compatible with 2.4 instead.

Status: Needs review » Needs work

The last submitted patch, 18: full-2278353.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.32 MB
new1.45 KB
new3.16 KB

It seems to be that the TODO is automatically resolved with this update.

Status: Needs review » Needs work

The last submitted patch, 20: core.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

.

jibran’s picture

+++ b/core/modules/user/src/Tests/UserValidationTest.php
@@ -104,15 +104,9 @@ function testValidation() {
-    //   https://drupal.org/node/2023465.

https://www.drupal.org/node/2023465 is still open
Other then this RTBC.

dawehner’s picture

https://www.drupal.org/node/2023465 is still open
Other then this RTBC.

The other one can just be marked as fixed if this one is in, so RTBC.

I would love to have a review from someone who actually understands the validator.

The last submitted patch, 20: symfony_update-2278353-20.patch, failed testing.

dawehner’s picture

StatusFileSize
new1.31 MB

.

tim.plunkett’s picture

  1. +++ b/core/modules/user/src/Tests/UserValidationTest.php
    @@ -104,15 +104,9 @@ function testValidation() {
    -    // @todo There are two violations because EmailItem::getConstraints()
    -    //   overlaps with the implicit constraint of the 'email' property type used
    -    //   in EmailItem::propertyDefinitions(). Resolve this in
    -    //   https://drupal.org/node/2023465.
    -    $this->assertEqual(count($violations), 2, 'Violations found when email is too long');
    +    $this->assertEqual(count($violations), 1, 'Violations found when email is too long');
         $this->assertEqual($violations[0]->getPropertyPath(), 'mail.0.value');
         $this->assertEqual($violations[0]->getMessage(), t('%name: the email address can not be longer than @max characters.', array('%name' => $user->get('mail')->getFieldDefinition()->getLabel(), '@max' => EMAIL_MAX_LENGTH)));
    -    $this->assertEqual($violations[1]->getPropertyPath(), 'mail.0.value');
    -    $this->assertEqual($violations[1]->getMessage(), t('This value is not a valid email address.'));
    

    These changes I have no understanding of :( Who can RTBC this part?

  2. +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php
    @@ -15,8 +15,8 @@
    -use Symfony\Component\Validator\ValidatorInterface;
     use Symfony\Component\Validator\Validation;
    +use Symfony\Component\Validator\Validator\ValidatorInterface;
    
    @@ -298,7 +298,7 @@ public function getPropertyInstance(TypedDataInterface $object, $property_name,
    -   * @param \Symfony\Component\Validator\ValidatorInterface $validator
    +   * @param \Symfony\Component\Validator\Validator\ValidatorInterface $validator
    
    @@ -308,7 +308,7 @@ public function setValidator(ValidatorInterface $validator) {
    -   * @return \Symfony\Component\Validator\ValidatorInterface
    +   * @return \Symfony\Component\Validator\Validator\ValidatorInterface
    

    This change is not needed until Symfony 3.0, but its fine to maintain parity with 2.5.

  3. +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php
    @@ -316,6 +316,7 @@ public function getValidator() {
    +        ->setApiVersion(Validation::API_VERSION_2_4)
    

    That is a neat trick.

jibran’s picture

I have pinged @fago on twitter for #29.1. https://twitter.com/JibranIjaz/status/494463802180530178

fago’s picture

thanks for pinging me.

These changes I have no understanding of :( Who can RTBC this part?

Looking through this, I was concerned that a violation fail suddenly disappeared. Having a closer look, it turns out that symfony changed e-mail validation: It now either works in strict RDF compliant variant based on https://github.com/egulias/EmailValidator (off by default) or it's based on a simple regex, which does not cover the length check any more as before.

See https://github.com/symfony/symfony/issues/1581 - reading the issue I was not able to determine the reason for moving away from filter_var() :(

So we have three options:
- Go with strict email validation, RFC compliant but slower
- Stay with the simple regex
- Write our own email constraint implemenation staying with filter_var().

Drupal 7 used to validate emails with filter_var(), so migrating to a simpler regex seems not feasible to me. But when we go with strict validation, what happens to some pre-existing mail adresses failing validation after upgrading?

Crell’s picture

We validate email addresses rarely enough that I am not concerned about performance.

Given that the RFC is ridiculously permissive, *are* there email addresses that wouldn't validate but would validate with a simple regex? Normally the problem of not using filter_var() or RFC is that you have lots of false negatives, not false positives.

andypost’s picture

Also please keep in mind that there email in international punycode that better to validate properly

dawehner’s picture

Opened a follow up to bring the external library into core because dries has to decide whether this library should be included: #2313669: Bring in egulias/EmailValidator for RFC compliant email address validation

In general I would also favour standard-compliance over performance improvements for some usecases. I am not sure
but I would argue that people with maximum needed import speed want to validate before or after doing the saving step and there might be a way to disable validation
temporarily for those cases

jibran’s picture

Let's add a @todo with above issue so that we can RTBC this.

dries’s picture

Here is what I posted in #2313669: Bring in egulias/EmailValidator for RFC compliant email address validation: Ideally, this would be fixed in PHP but sadly, that is not a realistic expectation. It seems like a lot of extra code but in general, I prefer to add a library rather than having to subclass Symfony to change its behavior. I'm not thrilled with it but all things considered, I'm ok with adding this library.

jibran’s picture

http://symfony.com/blog/symfony-2-5-3-released

Symfony 2.5.3 has just been released. It fixes a lot of issues regarding the backward compatibility of the Validator component. That should ease the migration from 2.4. If you find any other problems when upgrading from 2.4 to 2.5, please consider opening an issue.

jibran’s picture

StatusFileSize
new1.67 MB

2.5.3 patch

Status: Needs review » Needs work

The last submitted patch, 38: 2278353-38.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new3.16 KB
new1.67 MB

Now with core changes.

Status: Needs review » Needs work

The last submitted patch, 40: 2278353-40.patch, failed testing.

dawehner’s picture

Priority: Normal » Critical

Let's be honest this is a critical issue.

cilefen’s picture

This needs to have composer update run again because today Symfony released several security updates, including http://symfony.com/blog/cve-2014-5244-denial-of-service-with-a-malicious..., which addresses the same host header vulnerability in https://www.drupal.org/SA-CORE-2014-003.

catch’s picture

Issue tags: +beta target
xjm’s picture

Issue tags: +revisit before release candidate

And another "get on the latest thing".

cilefen’s picture

Issue tags: +Needs reroll
cilefen’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.64 MB

A rerolled with the following procedure:

  1. I branched and applied the patch.
  2. I reset composer.lock and the core/vendor directory
  3. I rebased 8.0.x fixing one conflict in UserValidationTest
  4. Then I ran composer update.

Status: Needs review » Needs work

The last submitted patch, 47: 2278353-47.patch, failed testing.

cilefen’s picture

Status: Needs work » Needs review
StatusFileSize
new3.38 MB

Oops - I forgot to include new files in core/vendor and composer.lock.

cilefen’s picture

tim.plunkett’s picture

This is including changes to all vendor libraries (look at core/vendor/doctrine, for example).
It should only update Symfony.

dawehner’s picture

@cilefen
https://www.drupal.org/node/2278353#comment-8968689 describes how to update just the ones we want there.

cilefen’s picture

StatusFileSize
new1.65 MB

As described. Should we not specify exact versions in composer.json?

composer update symfony/class-loader symfony/css-selector symfony/dependency-injection symfony/event-dispatcher symfony/http-foundation symfony/http-kernel symfony/routing symfony/serializer symfony/validator symfony/yaml symfony/debug

cilefen’s picture

There is also symfony/process symfony/property-access symfony/translation. Should those be included? property-access is removed if you update it.

cilefen’s picture

cilefen’s picture

This works: composer update symfony/*.

cilefen’s picture

StatusFileSize
new237.38 KB
new1.9 MB

This patch includes upgrades to symfony/property-access (removed), symfony/process, and symfony/translation.

composer update symfony/*
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing symfony/property-access (v2.4.1)
  - Removing symfony/process (v2.3.4)
  - Installing symfony/process (v2.5.4)
    Loading from cache

  - Removing symfony/translation (v2.3.4)
  - Installing symfony/translation (v2.5.4)
    Loading from cache
hussainweb’s picture

StatusFileSize
new1.96 MB
new32.58 KB

I just noticed that we missed YAML update. The composer.json had it specified as '2.5' instead of '2.5.*', which caused it to load the version 2.5.0. I am attaching the patch and interdiff with it changed to 2.5.* and consequently, symfony/yaml 2.5.4.

Please note that for simplicity's sake, I did not start with the patch in #57. I just modified the composer.json file and ran composer update symfony/*. I applied the patch later for interdiff purposes.

Status: Needs review » Needs work

The last submitted patch, 58: update_to_symfony_2_5_0-2278353-58.patch, failed testing.

hussainweb’s picture

Status: Needs work » Needs review
StatusFileSize
new1.96 MB

Ah, the process failed on me. I didn't realize there were changes in Drupal side of things. Here is the proper patch. The interdiff in #58 is still the correct one.

dawehner’s picture

Issue summary: View changes
cilefen’s picture

Should we be doing this? Please look at the Symfony release cycle if you are not already familiar with it.

If we upgrade to every Symfony release, we will endure this process about every 8 months, forever. 2.6 is due to be released in November and one could argue we should postpone this issue until then. No one has raised any reason for upgrading to 2.5 except for the fact that 2.5 exists.

I am making the case for staying on Long Term Support versions of Symfony. That would mean staying on 2.3 until mid-2015 when 2.7 is released. By staying on 2.3 we would not, for example, need to bring in another library to cover a problem in 2.5. And maybe we can influence getting the validator sorted out on the Symfony side before 2.7 lands.

It is a philosophy question: Should Drupal use foundational library version with long-term-support (currently 2.3) or the latest features (2.5, which is EOL in November 2014)?

cilefen’s picture

Sorry, I was wrong on dates:

  • 2.3 End of Support is May 2016
  • 2.5 End of Support is July 2015

This doesn't change the core of my argument.

Crell’s picture

Given that we are already relying on features in post-2.3 Symfony releases (the RequestStack, in particular) I think tracking stables is a done deal at this point.

A third of the problems we have with this process are due to our misuse of composer. Fix that and those issues go away. For the rest, we can put wrappers around the parts that are known to be problematic to abstract them from the systems that care.

tim.plunkett’s picture

I think we could also decide to stop tracking stables once 2.7 comes out in 8 months, and stick on that.

hussainweb’s picture

I agree with Crell on this. We are already using 2.4 and we should go with the updates. We may or may not decide to update to 2.6 depending on the API breaks and release state of Drupal at that point. If Drupal has entered beta by the time 2.6 is out (Nov 2014), then we only upgrade if we don't break API or can write wrappers around it. This is a likely scenario.

However, given that 2.7 is LTS, we should plan an upgrade and if there are API breaks, we should consider writing wrappers. Drupal 8 would probably be in final release by the time 2.7 is out and it would be much difficult to deal with API breaks then, considering we are using semantic versioning now.

Crell’s picture

I believe catch has previously stated his intent is to track stables until Drupal 8 gets to an LTS release, then freeze on whatever it's on at the time. He may have reconsidered that position but that's what I recall him saying in public last.

hussainweb’s picture

I am all for tracking stables, especially since we are in pre-beta. I am just concerned how do we handle an upgrade to 2.7 if there are API breaks. It breaks the promise of semantic versioning.

Alternatively, we should make it clear that Drupal would be API compatible but if someone is using it's dependencies (Symfony) directly, they may break API compatibility. We should revisit this when Drupal gets close to a release candidate.

andyceo’s picture

Hello guys!

I am a little from context now, but discovered a strange thing and want you to notice: #2335271: Missing Symfony components

catch’s picture

#67 still covers my position. We need to be able to submit upstream bug/performance/docs fixes, and potentially features, to Symfony, and running 2.3 would mean also trying to get those backported through several different branches, or subclassing/forking components ourselves if/when that doesn't happen. All of that is a lot more painful than upgrading every few months, especially at the moment when we don't have a stable release out ourselves.

Additionally, being able to take advantage of 2.4+ changes in Symfony should mean less work to do in Drupal 9 when that opens, for both core and contrib modules.

cilefen’s picture

Issue summary: View changes

Everyone—thank you for the comments. It is good to have these discussions.

I updated the issue with the current consensus. Should we commit this as-is or wait for #2313669: Bring in egulias/EmailValidator for RFC compliant email address validation and the following issue which would actually integrate egulias/EmailValidator to be committed first?

hussainweb’s picture

@cilefen: Is there any reason this should wait. I reviewed the patch and that issue and I think either one can go in first. Sure, the other one might need a reroll. Other than that, am I missing something here?

cilefen’s picture

@hussainweb As far as I am concerned, this is ready to go. We need a follow-up to #2313669: Bring in egulias/EmailValidator for RFC compliant email address validation to implement the new validator.

cilefen’s picture

Issue tags: +Needs reroll
cilefen’s picture

Status: Needs review » Needs work
cilefen’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new1.76 MB
new1.91 MB

Reroll

cilefen’s picture

+++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EmailValidator.php
@@ -36,12 +53,23 @@ public function validate($value, Constraint $constraint)
+        if ($constraint->strict && class_exists('\Egulias\EmailValidator\EmailValidator')) {
+            $strictValidator = new StrictEmailValidator();
+            $valid = $strictValidator->isValid($value, false, true);
+        } elseif ($constraint->strict === true) {
+            throw new \RuntimeException('Strict email validation requires egulias/email-validator');
+        } else {
+            $valid = preg_match('/.+\@.+\..+/', $value);
+        }

This is interesting regarding email validation.

dawehner’s picture

This is interesting regarding email validation.

Well yes, this is the point. Symfony either uses a trivial validation or a 100% proper one using the external package, which is why I filled the additional issue.

cilefen’s picture

Status: Needs review » Needs work

@dawehner @berdir and I discussed the email validation question on IRC and concluded that since valid_email_address() still exists and uses filter_var() then it makes no sense to have the validator class act differently. Because of that, I propose we add a new validator that overrides Symfony's that does filter_var().

#2313669: Bring in egulias/EmailValidator for RFC compliant email address validation will be non-critical.

cilefen’s picture

Status: Needs work » Needs review
StatusFileSize
new3.73 KB
new1.92 MB

This is a try at a filter_var() validator.

cilefen’s picture

Now that #80 is green, and if what I did is acceptable, we could stay with filter_var() and upgrade to Symfony 2.5 now. Then we could go on to #2313669: Bring in egulias/EmailValidator for RFC compliant email address validation as an enhancement.

cilefen’s picture

Issue summary: View changes
cilefen’s picture

Issue summary: View changes
dawehner’s picture

@cilefen
For such issues it helps dramatically if you post an additional patch which just shows the changes in composer.json and core code and leaves out the vendor code changes.

This looks like a perfect way to solve this issue for now!

cilefen’s picture

StatusFileSize
new5.73 KB

This is the changes in #80 for core/lib and composer.json only.

cilefen’s picture

Issue summary: View changes
StatusFileSize
new3.43 KB
new1.72 MB
new2.62 MB

#2313669: Bring in egulias/EmailValidator for RFC compliant email address validation is in so we should go with the new library. This patch attempts to use the new validator library in "strict" mode. I am not sure if I implemented it properly in the ConstraintManager.

Status: Needs review » Needs work

The last submitted patch, 86: update_to_symfony_2_5_0-2278353-86.patch, failed testing.

cilefen’s picture

StatusFileSize
new4.4 KB
new3.42 MB

Oops.

cilefen’s picture

Status: Needs work » Needs review
StatusFileSize
new1.91 MB

I accidentally updated all the vendor libraries. It should be composer update symfony/*.

cilefen’s picture

cilefen’s picture

cilefen’s picture

StatusFileSize
new4.4 KB
new1.96 MB
new3.66 MB

Symfony 2.5.5 just released.

cilefen’s picture

StatusFileSize
new390.14 KB
new2.09 MB

I can't believe I did it again. The prior patch contains every upgrade, which we don't want. This contains symfony only. Say it with me! composer update symfony/* Now I feel better.

cilefen’s picture

Title: Update to Symfony 2.5.0 » Update to Symfony 2.5.5
Issue summary: View changes
cilefen’s picture

Title: Update to Symfony 2.5.5 » Update to Symfony 2.5
Issue summary: View changes
larowlan’s picture

+1 rtbc this blocks a security team follow-up

Crell’s picture

Status: Needs review » Reviewed & tested by the community

Let's get caught up.

webchick’s picture

Assigned: Unassigned » catch

Talked to effulgentsia about this patch and he felt it's probably best for catch to look at this one and decide whether to try and get it in before/after beta.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed a21acb3 on 8.0.x
    Issue #2278353 by cilefen, dawehner, hussainweb, jibran, andyceo: Update...
int’s picture

I think that Drupal 8.x should upgrade Symfony in the future and stay in Symfony 2.7, that will be released in May 2015.
Symfony 2.7 will be a long term support version with security fixes until May 2019.

This will reduce the work needed to mantain Symfony in Drupal 8.x LTS version.

What you think?

dawehner’s picture

There is certainly a problem with the overlap of the potential commit time of symfony 2.7 and Drupal 8. We have to think about that now,
as it might be a huge risk to switch to 2.7 during getting the release out.

anavarre’s picture

@int could you please file a new issue to discuss that?

hussainweb’s picture

@dawehner: It is certainly risky but I am not sure if it is a huge risk. Symfony 2.3 onwards use semver, so there will be a backward compatibility layer. We had a layer here too but we couldn't use that because of email validation concerns.

Of course, we can't say anything for sure right now but we don't have to rule it out just yet.

hussainweb’s picture

@int: See #67 and #70.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

webmozart’s picture

I'm sorry that the changes in the Symfony 2.5 API seemed to have caused troubles. Is there still anything I can do to help?

Feel free to ping me whenever you have problems with the Validator component.

cilefen’s picture

@webmozart Open new issues about the problems and mention them in a comment on this issue.

cilefen’s picture

@webmozart, Oh I think I misunderstood. Yes, we have an issue to improve the validation here: #2343035: Upgrade validator integration for Symfony versions 2.5+

catch’s picture

Issue tags: -revisit before release candidate