Problem/Motivation
Following all the work in #3055180: [META] Symfony 5 compatibility, update the Drupal 10 branch to Symfony 5.
Proposed resolution
Update to Symfony 5 on the Drupal 10 branch once its open for development.
Remaining tasks
Do it.
User interface changes
None.
API changes
TBD
Data model changes
TBD
Release notes snippet
Drupal 10 was upadated to Symfony 5.4 as a stepping stone to Symfony 6. The change will be released with alpha1 as an interim step to help contributed projects update to Symfony 6. While direct Symfony API use is not common in Drupal projects, this interim step was introduced to help those who use Symfony APIs directly to be able to check for deprecated APIs in two steps. Since Symfony 4 does not have all deprecated APIs defined for Symfony 6, this interim step could help identify code changes required.
Comment | File | Size | Author |
---|---|---|---|
#68 | interdiff-61-68.patch | 5.73 KB | Taran2L |
| |||
#68 | 3197482-68.patch | 141.19 KB | Taran2L |
|
Issue fork drupal-3197482
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
Gábor HojtsyComment #3
xjmComment #4
catchOne of the issues under discussion in #3197483: Evaluate the potential update of Drupal 10 to Symfony 6 and do it if possible is how to enable contrib testing against Symfony 5 as well as Symfony 6. While there are various ways to do this, one way is to update to Symfony 5.4 (or a beta/rc) as soon as it's available in Drupal 9, so that there is at least a branch available to run tests against.
Comment #5
catchMost things from #3161889: [META] Symfony 6 compatibility can be done before (or in a couple of cases, after) we update to Symfony 5, but the MimeTypes change will have to be part of the same commit - we've already implemented a forwards compatibility layer so it's just switching things around.
Comment #6
catchHere's a patch created from the *MimeType* changes in #3161889: [META] Symfony 6 compatibility so we can start keeping track of necessary simultaneous changes to core here.
Comment #7
longwave10.0.x branch is open, this can be done now.
Comment #8
longwave#6 plus update of all Symfony components to
^5.4
.Comment #9
Gábor HojtsyOpened #3252757: Update Drupal 10 to depend on Symfony 6.0 as well for Symfony 6.0 later on. Parenting to this to the alpha.
Comment #10
longwaveRemove some more compatibility shims and obsolete deprecations.
Comment #11
longwave...and some unused use statements.
Comment #12
Gábor HojtsyMaking the goal of this update super-clear :D
Comment #14
longwaveLet's skip Symfony 6 deprecations for now, and resolve those once Symfony 5.4 is in 10.0.x.
Comment #15
longwaveI thought we had fixed all the InputBag compatibility cases, but apparently not.
Comment #16
longwaveOh, so #3162016: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated fixed these initially, but it was rolled back and a simpler solution put in place - but then we never went back and fixed all the calls, so they are being raised again here.
Comment #17
longwaveAdded deprecation skips for the InputBag changes.
Comment #19
SpokjeComment #20
SpokjeComment #21
SpokjeComment #22
SpokjeComment #23
longwaveThanks for picking this up!
I think this needs to be the class name if not set, e.g.
Pretty sure this whole pass can go and be replaced with a TaggedServicesPass but maybe worth deferring to a followup.
Here I am pretty sure we can just say
GET http://localhost/not-found
as the test will always be on localhost.Let's keep this comment block, bump the version numbers, and move the new deprecation skips back up to here.
Comment #24
SpokjeAddressed #23 number 1., 3. and 4.
Unsure about number 2. so blatantly ignored that for now.
Comment #25
SpokjeComment #26
longwaveOpened #3253048: Replace MimeTypePass with TaggedHandlersPass for #23.2.
If this is committed as-is we will also need followups to remove each of the Symfony 5 deprecations, they are on the critical path to getting to Symfony 6.
To me this is the minimal set of changes required for SF5 compatibility: we are removing SF4-specific code and BC shims mostly around the event dispatcher and MIME type guesser, but skipping new deprecation warnings introduced in the SF5 cycle.
Comment #28
SpokjeReroll after #3252088: Increase Drupal::MINIMUM_PHP to 8.0.0 was committed in MR.
MR displaying on d.o. seems broken, normally a testrun would start and show on the d.o. issue.
Not here :/
Attaching diff from current state of MR for Testbot approval
Comment #29
catchA lot of child issues of #3161889: [META] Symfony 6 compatibility have working patches, I had been assuming we'd get those RTBC and committed first, and then update to Symfony 5.4 here, to minimise the number of new skipped deprecations. When we skip deprecations in core, we also skip them for contrib test runs. The deprecations would still be picked up by static analysis so probably still useful to have the update, but not as useful as if they weren't skipped, and we'll likely want to do all that before 10.0.0-alpha1 anyway.
If we commit this first then remove the skipped deprecations afterwards, we're going to end up dealing with a lot of commit conflicts taking things out of the list, so it feels like it's going to be more work. Not that the list needs to be 100% empty, but if we can clear out the low hanging fruit without ever adding to it, it'll be a shorter list to work down.
Comment #30
longwaveA bunch of the SF6 compatibility patches went in. Rerolled #28 and removed all Symfony 5 deprecation skips, let's see what breaks.
Comment #31
longwave#30 plus:
#3238485: [Symfony 6] Add return type hints to the class methods of Drupal\Component\DependencyInjection\Container
#3232097: [Symfony 6] Add "array" type hint to methods overriding Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()
Comment #33
longwaveOpened
#3254248: [Symfony 6] The "allowEmptyString" option of the "Symfony\Component\Validator\Constraints\Length" constraint is deprecated
#3254250: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated
These plus the two linked in #31 should be all that are required to get SF5.4 compatibility with no warnings.
Comment #34
longwave#30 plus all four child patches.
The allowEmptyString fix can't be committed separately because it triggers a different deprecation. As it's a one liner in a test I think it's fine to commit along with the SF5.4 upgrade patch.
Comment #36
Taran2LI've checked remaining fails and most of them are more or less simple return type/@return statement descralations:
From the list above (in Symfony 6):
Checking the thing I've found that our deprecation catching system has not spotted that:UPDATE: seems like update getMasterRequest() => getMainRequest() has been already committed with a shim, so I think shim needs an update too. Thus deprecation is not being triggered I think.
Comment #37
longwaveThanks for analysing the results and breaking it down, that's really helpful.
#3254331: [Symfony 6] Add "array|string|int|float|bool|\ArrayObject|null" to all Normalizer classes that implement the method ::normalize() should have solved the ::normalize() issue.
I opened #3255245: [Symfony 6] Revert 3231603 to use our own TranslatorInterface to handle DrupalTranslator.
#3233031: [Symfony 6] Add "RequestContext" type hint to methods overridding Symfony\Component\Routing\RequestContextAwareInterface::getContext() should handle RequestContext.
Comment #38
longwaveThe RequestStack shim can be removed entirely as part of this issue I think; it has the comment
Alternatively we can temporarily add the return type to
getMasterRequest()
and then delete the class later.Comment #39
Taran2L@longwave, I guess this shim should be removed within this issue
Comment #40
andypost@Taran2L that's a great question to raise on #d10readiness meeting!
Comment #41
longwaveReroll of #30 with #3254248: [Symfony 6] The "allowEmptyString" option of the "Symfony\Component\Validator\Constraints\Length" constraint is deprecated included - let's see what's left to do here.
Comment #43
daffie CreditAttribution: daffie commentedI see this error 72 times in the testbot result page (https://www.drupal.org/pift-ci-job/2272865). Maybe we should fix #3254250: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated.
Comment #44
longwaveReroll, plus #3254250: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated, plus one line diff to fix RequestStack:
Comment #46
Taran2LI think there is a new thing:
This code is new, added a week ago here: #3253889: `?check_logged_in=1` causes `TrustedRedirectResponse` to fail
Commit: https://git.drupalcode.org/project/drupal/-/commit/f83161f6208e777147d70...
Comment #47
murilohp CreditAttribution: murilohp at CI&T commentedThanks for bringing this new thing @Taran2L, I've reviewed the issue last week, and now the
ResponseEvent
class is final, so we can't mock it, I'm uploading a new patch where I instantiate the class instead.Let's see if this test can pass now.
Thanks!
Comment #48
longwaveThanks! Assuming this passes it looks like we have just two issues remaining:
#3254250: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated
#3255245: [Symfony 6] Revert 3231603 to use our own TranslatorInterface
Comment #49
Taran2LWas about to do the same, @murilohp
btw, running this test locally shows me an extra deprecation, which is not available on DrupalCI:
Comment #50
murilohp CreditAttribution: murilohp at CI&T commentedI'm so sorry @Taran2L, I had no idea you were about to do that, my mistake. And about the deprecation, you're right, I think we just have to add
public function getId(): string
on theSessionManagerTest
class.Comment #51
Taran2LThe aforementioned deprecation is due to running tests like this
./vendor/bin/phpunit --filter UserAuthTest
Running like this
./vendor/bin/phpunit core/modules/user/tests/src/Unit
does not show itOh, there are even two of them:
Comment #52
longwaveWe should figure out why these deprecations don't show up on DrupalCI - are there more that we aren't seeing?
Comment #53
longwaveRerolled #47 and applied #3255245-14: [Symfony 6] Revert 3231603 to use our own TranslatorInterface
Comment #55
longwaveRerolled following #3255245: [Symfony 6] Revert 3231603 to use our own TranslatorInterface
Comment #56
longwaveWe don't use
symfony/translation
, let's see if we can get rid of it.Comment #59
longwaveReopened #3231688: [Symfony 6] Add type hints to Drupal\Core\TypedData\Validation\ExecutionContext to deal with the remaining set of fails. Otherwise MimeTypePassTest needs deleting from the patch, I missed that in the reroll.
Comment #60
catch#3231688: [Symfony 6] Add type hints to Drupal\Core\TypedData\Validation\ExecutionContext landed.
Comment #61
longwaveDeleted MimeTypePassTest.
Comment #63
catchThis looks great. It's a big patch because as well as doing the update, we also have to remove Symfony 4-5 forward compatibility layers we added in Drupal 9.
Comment #64
Taran2LI've just run simple search for "symfony 4" and "symfony 5" within the codebase and I see ~15 more mentions/places where the code must be removed/amended ... setting this too NW fro now
Comment #65
Taran2LComment #66
longwaveMy aim here was to make the minimal set of changes to get core running on Symfony 5 with all tests passing. Did you find anything that must be done in this issue, or can we complete the SF4 cleanup in followup issues?
Comment #67
Taran2LI was digging into it .. it'a bit confusing, I mean the scope.
Existing followups:
#3197729: Remove forward/bc layer for Symfony Definition::setDeprecated() method
#3162981: [Symfony 6] Use Symfony\Component\HttpFoundation\InputBag where appropriate instead of ParameterBag
Not covered:
-missing from the patch
-missing from the patch
-missing from the patch
- cannot find an issue, but I think it can be removed and replaced with Symfony's one
Proposed patch actually removes KernelEvent class alias, so the class itself as well as corresponding tests must be removed.
Comment #68
Taran2LComment #69
Taran2Limho, we can also clean up /core/modules/system/tests/src/Functional/System/TrustedHostsTest.php#L117 here, as most of it is removed anyway.
Patch from this issue reverts parts of the #3162016-84: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated and I think, we should revert what's left as well
Comment #70
daffie CreditAttribution: daffie commentedAll the code changes look good to me.
Not everything is done in this issue to remove all the Symfony 4 stuff, but we have a bunch of followups.
At least the minimum is done and Symfony is upgraded to version 5.4.
The testbot is happy.
For me it is RTBC.
Comment #72
alexpottNice work - it's going to be so much nice step debugging deprecations without all the thousands of deprecations from mime type guessing :D
Committed 7b324dd and pushed to 10.0.x. Thanks!
Comment #74
TR CreditAttribution: TR commentedShouldn't there be a change record for this? It's a pretty big change ...
Comment #75
Gábor HojtsyGood point. Added https://www.drupal.org/node/3259527 and copied the same text to the release notes snippet here. Not tagging for release notes since we are not using a 10.0.0-alpha1 release notes tag apprently.
Comment #77
jibranThis should be converted to
As per the docs https://github.com/symfony/symfony/blob/6.3/src/Symfony/Component/Valida...
Edit: Ignore my comment I missed that
allowEmptyString
wasFALSE
. Sorry for the noise.