Problem/Motivation
Following all the work in #3161889: [META] Symfony 6 compatibility, update the Drupal 10 branch to Symfony 6.0.
Proposed resolution
Update to Symfony 6 on the Drupal 10 branch.
Switch to friends-of-behat/mink
to resolve the lack of Symfony 6 compatible releases from behat/mink
, see #3263841: [Symfony 6] Swap behat/mink for friends-of-behat/mink.
symfony/console
must for now stay on Symfony 5.4, until there is a Symfony 6 compatible release of Composer. See #3264918: Update symfony/console to Symfony 6.
Dependency evaluation for friends-of-behat
Maintainance
friends-of-behat has three active maintainers, one of whom is also a behat maintainer.
The project provides several behat plugins that aren't included in the main package, such as Symfony integration, which we don't use.
Additionally, friends-of-behat maintain 'friendly forks' of behat, which apply PRs for PHP 8/Symfony updates before they're available in the main branch, and also tag releases at a faster rate. They don't make any changes other than upstream compatibility fixes:
No updates other than Symfony compatibility will be provided, but this fork might be synchronised with the original repository in the future.
(from https://github.com/FriendsOfBehat/MinkExtension)
Security policy
None, this is a development dependency, but likely to get any security release that mink does.
Code quality
The same as mink with only minimal changes for upstream compatibility.
Remaining tasks
Do it.
User interface changes
None.
API changes
Drupal can use Symfony 6 APIs, but has broken compatibility with anything that was deprecated in Symfony 4 or 5.
Data model changes
None.
Release notes snippet
Drupal 10 updated all Symfony components to Symfony 6, except symfony/console
which remains on Symfony 5 with forward compatibility with Symfony 6 while we await a new release of Composer.
Comment | File | Size | Author |
---|---|---|---|
#35 | interdiff.3252757.31-35.txt | 4.48 KB | longwave |
#35 | 3252757-35.patch | 82.82 KB | longwave |
|
Comments
Comment #2
longwavePostponed until #3197482: Update Drupal 10 to depend on Symfony 5.4 (as a stepping stone to Symfony 6, for deprecation checking support) lands.
Comment #3
dpiThe blocker has landed.
Comment #4
Gábor HojtsyUnil the pieces land in #3161889: [META] Symfony 6 compatibility this cannot be done though, so postponing on that (the children of that to be more precise).
Comment #5
longwaveThere aren't any blockers left in Drupal core itself. The two outstanding issues we have are with our dependencies:
This patch upgrades all dependencies to Symfony 6, except symfony/console for Composer compatibility, and switches Behat for a forked version as per #3263841: [Symfony 6] Swap behat/mink for friends-of-behat/mink
Comment #6
longwavecomposer.lock was broken somehow, trying again.
Comment #7
Gábor HojtsyHm, I thought at least #3258380: [Symfony 6][Second try] A number of methods of the class Drupal\Core\TypedData\Validation\ExecutionContext are considered internal and Drupal should not override them. was ouststanding? Maybe that would get a solution outside Drupal too?
Comment #8
catch@Gábor Hojtsy #3258380: [Symfony 6][Second try] A number of methods of the class Drupal\Core\TypedData\Validation\ExecutionContext are considered internal and Drupal should not override them. is an annoyance, but it's not a blocker. We reverted the original patch, and are stuck with the solution of suppressing those messages, but since they're @internal rather than @deprecated it's in the 'OK until it's not' category - same problem whether we're on Symfony 5 or Symfony 6. The upstream solutions we proposed stalled, so we might end up doing #3054535: Discuss whether to decouple from Symfony Validator instead, but there's no clear path forward there either.
Comment #9
longwaveAs we are already compatible with Symfony 5, do we want to release with constraints of
^5.4 || ^6.0
? Or is that too dangerous, given that we don't have min-max testing?Comment #10
Gábor HojtsyI think we wanted to release with SF 6 clearly, to make sure everyone can develop against that without the need to double check / extra work of supporting SF 5 setups.
Comment #11
daffie CreditAttribution: daffie commentedLooks good to me.
We need a followup for when "symfony/console" is ready to update to 6.0. Now blocked by composer.
Edit: The patch came from #3161889: [META] Symfony 6 compatibility.
Comment #12
xjmIs there a reference for Symfony 6 not being compatible with Composer 2? That is... alarming.
Comment #13
xjmI was at least able apply the patch locally and run
composer install
andCOMPOSER_ROOT_VERSION=10.0.x-dev composer update drupal/core
on Composer 2.2.6 without any issues. What's the compatibility problem? Edit: Ah, I see the patch keepssmyfony/console
on 5.4. That seems an OK workaround if it's temporary.Comment #14
xjmBefore committing this, I think we need a followup for Upgrading
symfony/console
that references whatever upstream issue will hopefully fix that, and possibly a followup for switching back tobehat/mink
proper if there is an upstream blocker to solve there as well.Meanwhile, we should probably do a dependency evaluation for the forked version of the package.
Comment #15
xjmPatch also no longer applies.
Thanks everyone!
Comment #16
catchIssue for switching back from friends-of-mink #3264903: Switch from friends-of-behat/mink back to behat/mink once it's Symfony 6 compatible.
Composer now allows symfony/console ^6.0, so I've gone ahead and updated it in the patch.
Will look at a quick dependency evaluation for friends-of-mink
Comment #17
catchI've added a dependency evaluation on #3263841: [Symfony 6] Swap behat/mink for friends-of-behat/mink.
IMO we should leave updating https://www.drupal.org/about/core/policies/core-dependency-policies/core... to #3264903: Switch from friends-of-behat/mink back to behat/mink once it's Symfony 6 compatible - i.e. only update the documentation if we have to keep using the fork into beta/rc. I've parented that issue under the beta criteria meta.
Comment #18
catchComment #19
longwave#16 has downgraded Composer to 2.1:
Composer 2.1 technically declares support for
symfony/console
6, but from what I could see it doesn't work properly. I think the issue is that Symfony 6 has added return types and so Composer can't do this in a backward-compatible way (in the same way that we have had issues with this).See https://github.com/composer/composer/issues/10321 and then https://github.com/composer/composer/issues/10322
Comment #20
catchOK that is confusing but I see what's going on. Restoring
symfony/console: ^5.4
brings composer back to 2.2.Follow-up here: #3264918: Update symfony/console to Symfony 6.
Comment #21
longwaveSome minor tweaks to the IS, but it's up to date with the current plan as far as I can see.
Comment #22
longwaveComment #24
longwaveThat's a new one to me.
We have a separate issue to upgrade this as it has a bunch of new dependencies, I think this issue should only update Symfony and leave the other dependencies alone.
Comment #25
catchReverting the coder update, good spot. Instead of trying to re-roll from the composer.lock, removed it and did the composer update again specifying only symfony/*, behat/*, friends-of-behat/*.
Comment #27
catchMaking this hard for myself :(
Another try.
Comment #29
catchComment #31
longwave#29 was missing changes to the dev dependencies metapackage and also downgraded
symfony/service-contracts
:Fixed the metapackage, upgraded
psr/container
which also lets us upgradesymfony/service-contracts
, and removed the reference todealerdirect/phpcodesniffer-composer-installer
as that is for the Coder issue to deal withComment #33
daffie CreditAttribution: daffie commentedYou are missing this change.
Comment #34
daffie CreditAttribution: daffie commentedBack to NW.
Comment #35
longwaveArgh, we will get there in the end! We also need to upgrade
asm89/stack-cors
for Symfony 6 compatibility.Comment #36
dww10.0.x
core (commit ).composer install
. Success.vendor/symfony/http-foundation/CHANGELOG.md
says "6.0"Not sure what else to review. RTBC for me!
Thanks,
-Derek
Comment #37
catchComment #38
dwwhttps://www.drupal.org/node/3252757/revisions/view/12558411/12558412 looks great, thanks for including that. It resolves a point @xjm brought up in Slack about the relationship to #3263841: [Symfony 6] Swap behat/mink for friends-of-behat/mink. I believe that's now going to be marked duplicate with this.
Anyway, even more RTBC now. 😉 Thanks!
Comment #39
andypostIs there follow-up to upgrade it too?
Comment #40
andypostFixed IS for it #3264918: Update symfony/console to Symfony 6
Comment #41
andypostRtbc +1
Comment #43
catchI only contributed (broken) rerolls here so I think I'm still OK to commit.
Committed 2add9d8 and pushed to 10.0.x. Thanks!
Symfony 6.1 next ;)
Comment #44
xjmComment #45
mondrakeDrush cannot be composer required/updated now
Comment #46
mondrakehttps://github.com/drush-ops/drush/issues/5077
Comment #47
greg.1.anderson CreditAttribution: greg.1.anderson at Pantheon commentedDrush 11 work-in-progress on Drupal 10 / Symfony 6 compatibility: https://github.com/drush-ops/drush/pull/5078
Comment #48
TR CreditAttribution: TR commentedAgain, this is another huge change, can we at least get a change notice?
This broke D9 compatibility in my contrib module because of Symfony 6's use of the 'mixed' return type hint, which is only available in PHP 8.
(EDIT: Actually, the bigger issue is Symfony 6's used of the 'mixed' function parameter. The return type hint error can be ignored with #[\ReturnTypeWillChange], but there's no mechanism to do that for a function parameter.)
Comment #49
andypost@TR the CR is https://www.drupal.org/node/3236232 but the issue has release notes snippet (which is more meaningful)
Some messages could be improved, for example #3265419: Improve deprecation message for RequestStack::getMasterRequest()
Comment #50
TR CreditAttribution: TR commented@andypost: No, that's not the same. That CR is for introducing return type hints into D9 in preparation for Symfony 5.4/6. This issue is about doing away with Symfony 5.4 entirely and switching to Symfony 6. And specifically the thing that's causing me a problem here is SessionInterface, which doesn't show up in any CR at all and which had backwards-incompatible changes between Symfony 5.4 and Symfony 6.
My code broke with the change from Symfony 5.4 to Symfony 6. Specifically, because Symfony 6 uses 'mixed' function parameters and return type hints - these are only available in PHP 8. While I can use #[\ReturnTypeWillChange] to deal with the return type hints, there's nothing I can do about the function parameters apparently. I now need different code because something that runs in D9 will not run in D10, and vice versa. This is a big change!
While some breakage is to be expected, it would be nice to have a CR of what this change was, so I can figure out WHY the code broken and what else to expect with the change.
Also, if the expectation is that a module should be able to be compatible with both the latest D9 and with D10.0.0, (like we did with D8.9 and D9.0), then because of this change that is no longer true in general. If this is intentional, then fine, but it should be explicitly noted in a CR.
Comment #51
catch@TR I've added a change record, but it doesn't say any more than the release note. You can add a change record yourself for an issue if you notice one that's missing.
Is this because the API is different, or because you'd need to increase your PHP requirement?
Comment #52
longwaveCan you give an example here? Parameter type contravariance should mean you don't have to add these types until you are ready: https://3v4l.org/LdCsl
(Return types are covariant - the other way around - which is why we are forced to add return types in places)
Comment #53
TR CreditAttribution: TR commentedhttps://3v4l.org/BabgE
Can you make that implementation work in both PHP 7 and PHP 8?
EDIT. Here's the example, for when the link dies:
Comment #54
TR CreditAttribution: TR commentedThank you.
Symfony 6 added some return type hints and parameter type hints. I would have to require PHP 8 in Drupal 9 to get my code to work in both D9 and D10 at the same time. I am unwilling to do that because most D9 sites now and for years into the future will be using PHP 7. See #53 for an example.
Comment #55
catch@TR you have three options:
1. Require PHP 8 - it's entirely valid to require PHP 8, PHP 7.4 will be EOL in nine months.
2. Conditionally define your class depending on the Drupal version, not really suited to 3v4l.org but a rough example here (ignore the PHP 7.4 error, the Drupal 10 code doesn't need to run on 7.4 https://3v4l.org/QnVTu)
3. Two branches
Comment #56
TR CreditAttribution: TR commentedYes, I'm doing 2).
I used conditional code for 2 years to support both D8 and D9, and now that D8 is no longer supported I was happy to get rid of that conditional code ... sadly, that has only lasted about three months, and now I need more :-(
Comment #57
imclean CreditAttribution: imclean at Digital Ink commentedI've seen a few modules use the general approach in point 3. It gets complicated when multiple PHP and Drupal versions need to be supported. SMS Framework is one example.
Recurring Dates Field is another.
Comment #58
imclean CreditAttribution: imclean at Digital Ink commentedWebform takes a similar approach.
Comment #59
PasqualleSupporting two Drupal major versions with 1 contrib module release is not really an option, if the module is using lot of the core apis, or want to use latest core functionalities.
The easy solution is to always create a separate module branch for core majors (D9, D10 ..), otherwise the module versioning will become a mess as the above screenshots show.
Same recommendation as I wrote 3 years ago:
#2807145-27: [policy, no patch] Allow contrib projects to specify multiple major core branches
Comment #60
dpiAs author of one of the screenshot mess' above, supporting two major versions of a dependency will depend on what happens over time (indicated by "Future" / TBD text). At worst I would end up supporting the old core version in a minor, and the newer one in a later minor. Personally I'm aggressive with cutting off support for the older core version so I'm not backporting features, only bugs and sec. But if you intend to support multiple versions of Drupal core for a while then you may think of your own versioning strategy. A new major version of your project is not always required, but it is "The easy solution".