Problem/Motivation

Symfony 4 does not contain hard breaking changes compared to Symfony 3 - at least for the components that Drupal core uses and in the way that we use them. Therefore, once the issues that do affect us are fixed (mainly the removal of Symfony's classloader), it should be possible to allow sites to run Symfony 4.

We'll still want to package core with Symfony 3, Symfony 4 would only be available installing with composer.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

catch created an issue. See original summary.

catch’s picture

Status: Active » Needs review
StatusFileSize
new34.49 KB
new34.49 KB
new33.95 KB

Took a look at the other issues in some more depth and this is the absolute theoretical minimum of what we might need afaict:

Did the following:

1. Kept symfony class-loader pinned to 3.4 - while it's removed in Symfony 4, it's also compatible with Symfony 4, so we can kick that down the road a bit.

2. Set Symfony constraints to be like "~3.4.0||~4.2.0" - this lets composer update symfony/* bring them up to the latest stable versions.

3. Including a version with the one-line patch from #3020301: Remove composer integration PHP version test (rely on DrupalCI PHP version runs instead).

This might not be enough, but see what DrupalCI comes back with.

catch’s picture

StatusFileSize
new39.27 KB

Too minimal - needs to update symfony/cmf too.

Still some things stuck on 3.4 - probably other stuff with Symfony dependencies, but seeing if this one's green.

The last submitted patch, 2: 3020303-composer-json.patch, failed testing. View results

catch’s picture

StatusFileSize
new2.1 KB
new43.72 KB

OK we need to do 4.0~ to get everything to update to 4 something or higher it looks like - can refine to more specific constraints from there.

The last submitted patch, 2: 302030-composer-json-lock.patch, failed testing. View results

The last submitted patch, 2: 302030-composer-json-lock-w-test-change.patch, failed testing. View results

The last submitted patch, 3: 3020303-combined.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 5: 3020303-combined-4.patch, failed testing. View results

catch’s picture

Most of the test failures are due to a newly introduced deprecation in 4.2, opened #3020385: Symfony 3 and Symfony ^4.2 JsonEncode constructors are incompatible.

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new107.45 KB
catch’s picture

StatusFileSize
new107.53 KB

The last submitted patch, 11: 3020303-combined-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 12: 3020303-combined-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

catch’s picture

Title: [PP-2] Relax composer.json requirements to allow Drupal 8 to be installed with Symfony 4 » [PP-1] Relax composer.json requirements to allow Drupal 8 to be installed with Symfony 4
catch’s picture

Status: Needs work » Needs review

...

catch’s picture

StatusFileSize
new1.64 KB

Re-rolled. Still postponed on #3020301: Remove composer integration PHP version test (rely on DrupalCI PHP version runs instead) but that's RTBC.

If we commit this, we'd need to be extra careful updating dependencies in composer.lock above and beyond PHP version support (i.e. once we require PHP 7.1 we'll still want to not move to Symfony 4).

catch’s picture

StatusFileSize
new1.64 KB

Restoring the typo3 library..

effulgentsia’s picture

Title: [PP-1] Relax composer.json requirements to allow Drupal 8 to be installed with Symfony 4 » Relax composer.json requirements to allow Drupal 8 to be installed with Symfony 4

I committed #3020301: Remove composer integration PHP version test (rely on DrupalCI PHP version runs instead), so this is no longer postponed.

If we commit this, we'd need to be extra careful updating dependencies in composer.lock

I don't suppose Composer has any support for indicating preferred version, does it? E.g., "prefer lowest major, but highest minor"? Or "prefer the first version range in a list that is separated by |"?

effulgentsia’s picture

StatusFileSize
new2.92 KB
new1.24 KB

How about this as a way of addressing #19?

catch’s picture

I don't suppose Composer has any support for indicating preferred version, does it? E.g., "prefer lowest major, but highest minor"? Or "prefer the first version range in a list that is separated by |"?

You can do composer require vendor/package:version to update to a specific version instead of using composer update. There's also --prefer-lowest which is fine for our Symfony range because 3.4 is the lowest minor we specify, although we'd need to start specifying patch updates then for things we rely on.

The PHP version trick will force us to stay on Symfony 3 for now, but it seems a bit fragile if another dependency raises its PHP dependency to 7.1.3 and we want to update to that in a minor (once we require PHP 7.1 of course). Also while our PHP requirements are lower, composer will fail to install on all the < 7.1.3 environments anyway if we update to something requiring that.

effulgentsia’s picture

If we commit this

If we don't know yet if we want to commit this once it's ready, why is this issue prioritized as Critical?

gábor hojtsy’s picture

I think we want to commit this and release with 8.7 if at all possible so people can turn up more problems that we can fix in 8.8 and then release 8.8 with optional support for Symfony 5 so people can turn up more problems that we can fix in 8.9 and release Drupal 9 at the same time with 8.9 requiring Symfony 4 or 5 based on how far we get.

berdir’s picture

I'm a bit worried about the impact this will have on all the drupal-project sites out there if we commit it. Even if we add it, the php version thing won't do anything for them, because they don't use the root-level composer.json. And I'm actually kinda surprised that passed, because shouldn't that prevent the new php7-only phpunit version from being installed on testbot?

Unfortunately it is quite hard to test what would happen because you can't change composer dependencies with patches. If we do decide to commit it then I'll try the dev branch on our install profile, to check how well it is going to work.

catch’s picture

@effulgentsia we want to commit this so that we can eventually test contributed projects (and core patches) with minimum and maximum versions of dependencies, and also to make Symfony 4.3, 4.4, 5.0 and 5.1 compatibility easier to track. This is the only way to allow contributed branches to test for Symfony 4 compatibility issues prior to the 9.x branch opening.

Whether we can commit this exact patch in its current form or not is a different question.

effulgentsia’s picture

The PHP version trick will force us to stay on Symfony 3 for now, but it seems a bit fragile if another dependency raises its PHP dependency to 7.1.3 and we want to update to that in a minor (once we require PHP 7.1 of course)

I think we should keep Drupal 8 on PHP 7.0 for the rest of its life. Ubuntu 16.04 has PHP 7.0 and is supported until April 2021. Debian 9 has PHP 7.0 and has LTS until June 2022. Drupal 9.0, of course, can require a higher PHP version.

I'm actually kinda surprised that passed, because shouldn't that prevent the new php7-only phpunit version from being installed on testbot?

The patch adds --ignore-platform-reqs to the drupal-phpunit-upgrade command.

I'm a bit worried about the impact this will have on all the drupal-project sites out there if we commit it. Even if we add it, the php version thing won't do anything for them, because they don't use the root-level composer.json.

Aren't those exactly the projects that we want updating to Symfony 4 and reporting issues to us? If the project uses modules/packages that are not compatible with Symfony 4, then isn't it the responsibility of those incompatible modules/packages to specify their requirements in their composer.json file? And per #21, a drupal-project site can add those requirements to their root composer.json too. But you're right that it's a potential BC break for sites that are incompatible with Symfony 4 but don't have that reflected in any composer.json file.

effulgentsia’s picture

There's also --prefer-lowest which is fine for our Symfony range because 3.4 is the lowest minor we specify, although we'd need to start specifying patch updates then for things we rely on.

Would that require us to update the minimum patch number every time any vendor library has a security update? Maybe that's fine, since if we're updating our composer.lock file anyway, then why not update composer.json at the same time?

derrabus’s picture

Projects that depend on a Symfony-4-compatible drupal/core package could add "symfony/lts": "^3" to their dependencies if they don't want to upgrade to Symfony 4 just yet. That package simply adds a conflict for version 4 of each Symfony package. It is marked as abandoned at Packagist though. However, since the list of Symfony 3 packages won't change anymore, it should be save to use it for this purpose.

catch’s picture

But you're right that it's a potential BC break for sites that are incompatible with Symfony 4 but don't have that reflected in any composer.json file.

This might be OK with a pre-announcement and prominent mention in the release notes.

bojanz’s picture

Echoing berdir's #24. This feels extremely unwise.

The documented starting point for every Drupal Commerce site is "composer create-project".
This will silently switch a large portion of our users to Symfony 4. That makes it the equivalent of Drupal core switching the tarball to Symfony 4.

It is worse to have some people on Symfony 4 (and experiencing contrib incompatibilities) and some on Symfony 3, than to just move everyone to Symfony 4.

alexpott’s picture

I agree with @Berdir and @bojanz - this feels very risky.

Also,

+++ b/composer.json
@@ -14,7 +14,10 @@
+            "php": "5.5.9"

This is tricky. We've tried similar stuff like this before. But this risks breaking tar installed / git installed sites that are on PHP 7 and have other non-drupal dependencies that are PHP 7 only.

gábor hojtsy’s picture

Let's return to what @catch said in #25:

we want to commit this so that we can eventually test contributed projects (and core patches) with minimum and maximum versions of dependencies, and also to make Symfony 4.3, 4.4, 5.0 and 5.1 compatibility easier to track. This is the only way to allow contributed branches to test for Symfony 4 compatibility issues prior to the 9.x branch opening.

Whether we can commit this exact patch in its current form or not is a different question.

(Emphasis mine). Can we make a different change that would not have the same side effects of forcing anyone to Symfony 4, yet would still allow us to gather feedback on Symfony 4 support as well as let contribs adopt optional Symfony 4 support?

catch’s picture

I think a small change like expecting composer built projects that aren't already using drupal-core-strict to add "symfony/lts": "^3" from @derrabus in #28 is acceptable in a minor release.

We can also have a hook_requirements() that warns you you're running Symfony 4 (with maybe a settings.php killswitch).

xjm’s picture

Today we discussed when and whether to commit this change so that people can test it. Options discussed:

  1. Commit to 8.7.x in time for beta.
  2. Create an 8.7.x-symfony4 feature branch (which would not be updated by committers after branching or tested on infrastructure)
  3. Branch 9.x within the next month and commit it there
  4. Commit this to 8.8.x when it opens and get feedback/testing there, with the possibility of reverting it if it's too disruptive.

The committer team discussed this and we mostly think option #1 is too risky. Option #4 is what we agreed on. So we can commit this to 8.8.x when we branch it, which will be in a month or so, and then do a communication push around testing it and giving feedback.

Edit: The above isn't signoff on the current implementation, just what we would do if we were to commit the current implementation or something like it.

effulgentsia’s picture

StatusFileSize
new4.67 KB
new2.93 KB

Re #28 / #33, https://github.com/symfony/lts says that it's abandoned and recommends using symfony/flex instead. Here's a patch that does that. It therefore removes the #31 hunk as well.

Symfony/flex has a composer.json dependency on PHP 7.0, but if we're not planning to commit this until the Drupal 8.8.x branch per #34, then that's not a problem per the proposed resolution of #2842431: [policy] Remove PHP 5.5, 5.6 support in Drupal 8.7:

The 8.8.x branch will not be tested against PHP 5.

This patch adds the "symfony": { "require": "^3" } configuration (used by symfony/flex) to the root composer.json (not core/composer.json). This would set the default for sites that use Drupal's root composer.json. Sites that use their own root composer.json could change that requirement to allow for Symfony 4 if they want to help us test it. How does that sound?

effulgentsia’s picture

StatusFileSize
new4.11 KB

Sorry, the interdiff in #35 is incorrect. The patch is correct (but badly named, because it's in no way the same as the one in #20).

Here is the correct interdiff between the patch in #20 and the patch in #35.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

gábor hojtsy’s picture

#2976394: Allow Symfony 4.4 to be installed in Drupal 8 reached a point where 8.8-dev is now Symfony 4 compatible (other than test fails for deprecations for Symfony 5). So we are back here to figure out how to support this.

pasqualle’s picture

Can you be more specific what needs to be figured out?

Reading through the comments it seems the decision was made already.

4. Commit this to 8.8.x when it opens and get feedback/testing there, with the possibility of reverting it if it's too disruptive.

If it will have to be reverted, then it should be before 8.8 alpha, so 4 months left for testing SF4 on D8.

Or do you think

3. Branch 9.x within the next month and commit it there

is a much more logical/cleaner way forward now?

catch’s picture

Status: Needs review » Needs work

#35 needs a re-roll but seems like a good approach to me, it could use some manual testing with different composer approaches.

alexpott’s picture

Sites that use their own root composer.json could change that requirement to allow for Symfony 4 if they want to help us test it. How does that sound?

So that means any site that has been built using the recommended way to build Drupal sites will use Symfony 4 the next time they run composer update - the official user guide docs are here https://www.drupal.org/docs/user_guide/en/install-composer.html and drupal-composer/drupal-project uses drupal/core not drupal/drupal.

effulgentsia’s picture

So that means any site that has been built using the recommended way to build Drupal sites will use Symfony 4 the next time they run composer update

In general, how do composer project templates release bug fixes or other improvements to their existing users? For example, if we also added something like #35 to drupal-composer/drupal-project, is there anything within existing conventions of how people use composer after creating a project from a template that would notify them that an update to the template exists?

alexpott’s picture

I think the project template is exactly that - a template that is used once to template your project - there's no link back to the template as far as I know.

aspilicious’s picture

Yeah if you want new things from the template you need to copy them.
Doesn't happen automagically.

But that's fine.

alexpott’s picture

But that's fine.

@aspilicious in this case I'm not sure it is. If I have a drupal project created site and I suddenly get Symfony 4 because drupal/core has relaxed it's version requirements I'm going to be mightly surprised because uptil this point the version of Symfony I'm on has been controlled by drupal/core - I've not had to make this consideration myself. This especially problematic for contrib and custom modules because at the moment they make assumptions about inherited dependencies. And to compound this we don't do deprecation testing by default for contrib so if they are using deprecated code in Symfony 3 they have to do work to find this out.

heddn’s picture

I, for one, am OK with this potential issue with drupal-composer/drupal-project. Post a CR about symfony 4. Add it to release notes. Then let folks test their sites and possibly add a pin on symfony 3 in their composer.json. All another day in the moving target of being a drupal developer. If it breaks, usually things break spectacularly. Which is easy to catch in even rudimentary testing.

catch’s picture

Here's an idea that might be lower risk but get us most of what we want:

1. Do #35, except put the configuration in core/composer.json so every install stays on Symfony 3, but we still relax our actual requirements.

2. Add a composer script which rewrites that configuration in core/composer.json to be Symfony 4 instead - (prior to install? or like the phpunit updater). Because it's just one line in core/composer.json that hopefully won't be too bad?

3. Contrib projects can then add that composer script to drupalci.yml to test against Symfony 4.

moshe weitzman’s picture

I, for one, am OK with this potential issue with drupal-composer/drupal-project.

I'm OK with this too. All my projects have pinned to Symfony ^3 for some reason or another. Folks who dont do that will see a failure from Contrib/Custom and can take appropriate action. Minor core upgrades always require some work.

catch’s picture

Issue tags: +Drupal 9
aiphes’s picture

I, for one, am OK with this potential issue with drupal-composer/drupal-project.

So can I do the Symfony update to 4 if I don't use this components because I converted my websites this way ?

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

gábor hojtsy’s picture

Status: Needs work » Closed (won't fix)

This is not going to happen due to various concerns raised here. Also we could only do this now in Drupal 8.9 and that is supposed to release alongside Drupal 9, so no point anymore. See you in #3088369: Update Drupal 9 to Symfony 4.4-dev though!

catch’s picture

Title: Relax composer.json requirements to allow Drupal 8 to be installed with Symfony 4 » Consider using Symfony flex to allow switching between major Symfony versions
Version: 8.9.x-dev » 9.0.x-dev
Status: Closed (won't fix) » Needs work

Re-opening this for 9.0.x - we could still do the composer.json refactoring prior to the release of Drupal 9, to allow sites to upgrade to Symfony 5 via composer.

alexpott’s picture

We still have the same problem the fact we ship a lock file and don't test against our minimum and maximum dependencies. It feels' like all that has to be fixed before we do this. Also we know we're not compatible with SF5 because we're currently skipping some SF4 deprecations.

catch’s picture

Priority: Critical » Major
Issue tags: +Needs release manager review, +Needs framework manager review

Based on previous discussion here, people were not keen to do this in a minor release, so it is probably beta/rc deadline for either 9.0.x or 10.0.x

xjm’s picture

Version: 9.0.x-dev » 10.0.x-dev

The beta clock has just about run out (and honestly I think it was beta deadline anyway).

We might want to revisit this during D10 development, since there's a chance we'll be trying to bridge our way from SF4 to SF6.

catch’s picture

Here's a possible approach for Drupal 10.

1. Have all Drupal 10 components declare compatibility with Symfony >= 5.4
2. Use symfony flex and configure it to use Symfony 6.

That way all installs get Symfony 6 by default. If you're having trouble bridging Symfony 4 to 6, you can specify Symfony 5.4 yourself while you sort those issues out, then specify Symfony 6 after that.

For the actual stable Drupal 10 release we might want to remove the ability to install on Symfony 5.4 and raise requirements to Symfony > 6.0 for everything, but flex would then be in place for Symfony 7 and onwards too.

catch’s picture

Version: 10.0.x-dev » 9.2.x-dev
Status: Needs work » Needs review
StatusFileSize
new18.62 KB

Thought about this some more, and I think we could probably add the symfony/flex dependency in Drupal 9, without loosening the constraints. We could then in Drupal 10 loosen the constraints and configure symfony/flex differently. Bit of a re-roll.

catch’s picture

StatusFileSize
new15.04 KB

cspell is failing on the config directory.

We could cspell-ignore those files, but really they're completely irrelevant to us because they're for using the framework rather than components. Either need to add them to clean-up or stop symfony-flex creating them in the first place. For now removing to get a test run.

Status: Needs review » Needs work

The last submitted patch, 59: 3020303.patch, failed testing. View results

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

@catch linked to this issue in Slack and asked for reviews, so here are some thoughts:

As I understand it this will effectively require downstream users (both contrib and end user sites) to declare which version(s) of Symfony they support, instead of relying on Drupal core's major version to infer this. To me this brings us back to the old question of is Drupal a product, or a framework? If it's a product, then I think we should lock to a Symfony version and be done with it; but if it's a framework then I see the advantages of allowing flexible Symfony versions. But in many ways Drupal is both, and I believe some (product) users will not like the additional load here of having to select a Symfony version to use.

Also, does this risk further fragmentation in contrib? We already have the issue that when we release a new major, contrib has to catch up. But now if we're also asking contrib to support multiple Symfony versions, we risk further incompatibility issues - Drupal core might support two versions of Symfony, but if module A only supports SF5 and module B only supports SF6, that means they can no longer be used together.

Finally I think this was already alluded to above, but we surely need test infrastructure improvements to be able to do this. Once we declare that we support more than one Symfony version, all patches will have to be tested on both versions prior to commit - at least the latest version of each major, if not full min/max testing across all supported majors - to ensure that we haven't broken anything.

longwave’s picture

Also, do we even need Symfony Flex? Can we ship Drupal 10 with ^5.4|^6.0 dependencies on Symfony, with the lockfile set to Symfony 6? This means people get SF6 by default but can downgrade if they want to.

We've shown in #3161889: [META] Symfony 6 compatibility that we can already support ^4.4|^5.4 in 9.3.x - albeit with some deprecations for Symfony 6.x, but nothing actually broken. Could we support ^5.4|^6.4 to Drupal 10 EOL, and then go to ^7.0 in Drupal 11.0?

andypost’s picture

@longwave versions still makes sense as core provides independent components (each provides own constraints)

andypost’s picture

andypost’s picture

As Symfony 5.3 there's https://symfony.com/doc/current/components/runtime.html which is now moving to separate project

It could help to manage core's variations (IIRC there's 3 Kernels already)

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

Priority: Major » Normal
Status: Needs work » Postponed (maintainer needs more info)

Now that we've done #3361260: [policy, no patch] Adopt a regular two year release cadence for major releases this is no longer necessary I think. Moving to 'needs more info' in case there's a use-case I've missed. I guess potentially it would still be possible to update the 10.x branch to newer Symfony versions using this, but any sites wanting to do that would be better off updating to 11.x anyway.

smustgrave’s picture

Wanted to bump 1 more time as there are a lot of people on this one.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.