Problem/Motivation
#3055180: [META] Symfony 5 compatibility resolved Symfony 4 deprecations in Drupal 9 for Symfony 5. We want to keep resolving deprecations in Symfony 5 towards Symfony 6 compatibility. If it is feasible to move directly from Symfony 4 in Drupal 9 to Symfony 6 in Drupal 10, it would be useful to have that option.
Proposed resolution
Keep surfacing new deprecated APIs affecting Drupal as new Symfony deprecations are added in Symfony 5 versions. This issue is used to update Symfony 4 to Symfony 5 for testing purposes only. This is also a META tracking issue for individual fixes that should go into child issues. Repeat until Symfony 5.4 is available.
Remaining tasks
We have a problem with dev requirement Prophecy. It has to do with "static" return type hinting. See: https://github.com/phpspec/prophecy/issues/527
Must haves
None at this time.
Should have for Drupal 9/10, must have for Drupal 10/11
- #3162981: [Symfony 6] Use Symfony\Component\HttpFoundation\InputBag where appropriate instead of ParameterBag
- #3209723: [Symfony 6] Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST is deprecated, use ::MAIN_REQUEST instead
- #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.
If we are to update to Symfony 6 in Drupal 10, we also need to bridge the gap somehow for deprecation checking and updates. See #3196027: Contrib support solution needed for potential Symfony 4 to 6 upgrade, Symfony 5 only deprecations are not available in Symfony 4.
API changes
Ideally none. See child issues.
Data model changes
None.
Release notes snippet
Drupal has been updated for compatibility with Symfony 5.4. This includes adding return type hints to some methods where we were unable to find any examples or use-cases for subclassing. However, should custom code subclass one of these methods, a return type hint can be added. A list is available in the change record
| Comment | File | Size | Author |
|---|---|---|---|
| #239 | 3161889-239.patch | 83.07 KB | longwave |
| #232 | 3161889-232.patch | 106.47 KB | daffie |
| #230 | 3161889-230.patch | 102.98 KB | longwave |
| #229 | 3161889-229.patch | 97.78 KB | longwave |
| #227 | 3161889-227.patch | 106.36 KB | longwave |
Issue fork drupal-3161889
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:
- 3161889-symfony-5-4
changes, plain diff MR !1158
- 3161889-meta-symfony-6
changes, plain diff MR !569
Comments
Comment #2
catchFirst problem:
https://github.com/minkphp/MinkBrowserKitDriver/issues/139 / https://github.com/minkphp/MinkBrowserKitDriver/pull/151 / https://github.com/minkphp/MinkBrowserKitDriver/pull/142
Comment #3
catchBrute force approach, but see where this gets us:
- remove behat as a dependency
- exclude Functional and FunctionalJavaScript tests from test discovery.
Then we should be able to see what fails with unit and kernel tests.
Comment #4
catchComment #5
catchAdding #3055193: [Symfony 5] The "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\MimeTypes" instead..
Also removing implementation of a removed interface (see interdiff).
Comment #6
catchComment #7
catchComment #8
catchRemoving some of the shims in ContainerAwareEventDispatcher that we just added.
Comment #9
catchUpdating the typehint in AccountProxy::__construct(). We could split off a patch to remove that typehint in Drupal 9 so that there's less to update.
Comment #10
catchComment #11
catchDozens more event dispatcher type hint changes.
Comment #12
catchDrupalCI is not entirely happy, but it is reporting test failures that can be fixed now:
https://dispatcher.drupalci.org/job/drupal_patches/55318/testReport/Big_...
#3161992: Since symfony/http-foundation 5.1: The "Symfony\Component\HttpFoundation\Response::create()" method is deprecated, use "new Drupal\Core\Render\HtmlResponse()" instead.
Comment #13
catchComment #14
catchIncluding some fixes from child issues.
Comment #15
catchComment #16
catchComment #17
catchComment #18
mikelutzI'm struggling to seperate out the recently committed stuff from #16 from some of the other needed changes to get Drupal running on 5.1, so for my own education, I'm going to try a fresh patch and see if I can figure out exactly what is missing. Expect a few broken things thrown against testbot while I work through this.
Comment #19
mikelutzComment #20
mikelutzComment #21
mikelutzComment #22
catchStarted on my own re-roll and crossposting with @mikelutz - this is untested based on #14 with the committed patch hacked out and a new composer update symfony/*
Comment #23
mikelutzbah, Sorry, @catch. I didn't realize you were working on this today. I was trying to get myself up to speed, and go the other way. Start from scratch and work in the needed typehints from your interdiffs.
Comment #24
catch@mikelutz no problem at all, patch here is very messy, once we've got something 'working' should probably split it into different sections so it's easier to re-roll next time.
Comment #25
mikelutzI was going a different way anyway, more like what we did with SF4 and Drupal 8 where I didn't change the lock file, but ran the update in drupalci.yml. I'll let you finish, I know you've been working on it. I didn't mean to jump in, I thought you might be done for the night, and I wanted to play with it a bit.
Comment #26
mikelutzAdding some deprecations to skip for now.
Comment #27
mikelutzFix for the dispatcher that was breaking a lot of kernel tests.
Comment #28
mikelutzGoing to try going back to my method of updating, which also includes a fork of mink browser kit that might work. A number of the kernel tests are failing because they are loading traits from functional tests that aren't making it into the classloader.
Comment #29
mikelutzRemove a broken legacy mime type guesser test class referencing the legacy guesser
Comment #30
mikelutzResponse constructor won't take an array anymore. hacking HtmlResponse to try to get some Functional tests working.
Comment #31
mikelutzAnother deprecation, and a different fix for HtmlResponse.
Comment #32
mikelutzOoops, try this one.
Comment #33
mikelutzComment #34
mikelutzRemoving more legacy code from the mimetype system.
Comment #35
mikelutzOpened #3172410: Make HtmlResponse compatible with Symfony 5 to fix #30
Comment #36
mikelutzOpened #3172425: "Symfony\Component\Lock\Factory" is deprecated since Symfony 4.4 and will be removed in 5.0 use "Symfony\Component\Lock\LockFactory" instead (Technically a SF4 deprecation we missed somehow) to address the missing Lock Factory.
Comment #37
mikelutzOpened #3172537: Passing a command as string when creating a "Symfony\Component\Process\Process" instance is deprecated since Symfony 4.2, pass it as an array of its arguments instead, or use the "Process::fromShellCommandline()" constructor if you need features provided as well, another SF4 deprecation that we missed.
Comment #38
gábor hojtsyUpdated issue summary since the blocking issue was resolved. Did not yet process the children issues in my head so did not do a comprehensive list just pointed to the sidebar.
Comment #39
mikelutzI'm still working through the remaining test failures, I have a few RTBC patches that should address a number of them in D9, so I'm going to give it a day or two to see if they get committed before I re-roll the patch, but I think I can get this green in the next week or so. I'm taking next week off from $work, so I should have more time to dedicate to this.
The current patch is testing against SF5.1 stable, so once it's green, we can push up to 5.2-dev and try to get ahead of the current SF5 dev cycle. After that we can just keep on continual maintenance hopefully. So far, I don't see any SF5 deprecations we can't handle in D9, but they still have 3 more releases in the 5.x cycle to throw curveballs at us, and I feel like they like to put a lot of them in the X.4 release. I'm super happy we are ahead of the game early this time though. Once we are caught up with 5.x-dev, we can take a more active role in the SF6 development cycle, and try and work upstream to make SF6 in D10 happen more easily.
Comment #40
andypostThere's good overview of coming 5.2 https://speakerdeck.com/fabpot/symfony-5-dot-2
Looks we could reconsider current set of console applications and unify it for d10 ref #2242947: Integrate Symfony Console component to natively support command line operations
Comment #41
mikelutzHere's a re-roll with the HtmlResponse changes removed (fixed in #3172410: Make HtmlResponse compatible with Symfony 5), plus a hack fix around the metapackage fail on my temporary mink fork. A couple other issue landed, so altogether a few more failures should be fixed.
@Gábor, did you mean to reset this to active instead of NW? I know it's technically a meta issue, maybe active makes more sense.
Comment #43
mikelutzAnd fixing the bad re-roll of HtmlResponse in #41...
Comment #44
mikelutzcomposer lock issue fix.
Comment #45
andypost@mikelutz it looks great! Thank you
23 remaining failures are straight to fix
Comment #46
mikelutzFixing a few more, going to open more issues. Deleting one MimeType test for now because I can't convert it as is. It uses reflection on the MimeTypeGuesser class, whose equivalant in SF5 is final. We will need to look at how to replace that test.
Comment #47
gábor hojtsy@mikelutz: definitely no intention to change the status.
Comment #49
andypostMain blocker is #3162016: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated
Comment #50
gábor hojtsyUpdated issue summary with individual issues linked and more info about how this issue is used.
Comment #51
gábor hojtsyFixed markup.
Comment #52
gábor hojtsyRerolled the patch manually against 9.2.x. Some things already landed, eg. some places already use the Contracts interface from Symfony.
Comment #53
gábor hojtsySomehow missed a core/composer.json change in my manual fix where the symfony/mime package was added. Adding that in.
Comment #54
gábor hojtsyHm, now we get a bazillion instances of
Fatal error: Trait 'Prophecy\PhpUnit\ProphecyTrait' not found in /var/www/html/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php on line 12. It seems like my patch updates the phpunit version to 9 from 8, so that might have something to do with this. I am not really well versed around the phpunit update magic we have. Also we may not want to update the phpunit version here, but either way it should work with an updated phpunit.Going to pass this to others who know this better :D
Comment #56
gábor hojtsyPer @longwave in slack:
Comment #57
gábor hojtsyWell doing that adds quite a few more dependencies. Let's see.
Comment #59
gábor hojtsyI don't actually understand how I should read these fails :/ There are definitely two of these which are odd, because it says it requires that and it did find it but then it did not use it.
Comment #60
mikelutzHmm, Those composer validation issues are tricky. behat/mink-browserkit-driver dev-SF5 is my fork of browserkit that is compatible with SF5. We are cheating the system to use the fork, just to get tests running, but I'm not certain why it isn't happy, nor what to do long term about actually having a working supported mink browserkit. If I need to change anything in the fork, or if anybody wants access to commit changes to my fork, let me know. I'll try to look into it more when I have time.
Comment #61
gábor hojtsyhttps://symfony.com/blog/symfony-5-2-0-released so this should be updated to 5.2 now, the patch uses 5.1 :) Thanks @andypost for the tip.
Comment #62
longwaveThis is #57 with Symfony 5.2 but with the PHPUnit upgrade removed as it's not needed here.
Comment #63
longwaveLooks like something has changed in the Symfony container between 5.1.8 and 5.2.0, as locally I run out of memory or segfault when compiling the container, and run-tests.sh crashes with
Seems that services are really private by default now, and we are going to have to force public services even more than we do already: https://github.com/symfony/dependency-injection/compare/v5.1.9..v5.2.0
Comment #64
longwaveExplicitly setting services and aliases to public fixes at least some of the container issues, my local site and run-tests.sh both work now.
Comment #65
longwaveTry again without the DrupalCI container command.
Comment #66
longwaveAnd I forgot the deprecation notice.
Comment #67
longwaveSome more fixes, maybe enough to make the tests not blow up entirely.
We pretend that Symfony Constraint plugins are Drupal plugins, but the constructor is no longer compatible so we need to provide a new custom factory. This can probably be committed to Drupal 9/Symfony 4.
We also have to call
setPublic(TRUE)all over the place for services. Not sure if this is the right way to go, or if we should be doing this at a lower level somewhere, but it does help some of the tests pass. Maybe we need to make sure we always use our Container/ContainerBuilder subclasses and handle it there if we are staying with public-by-default services.Comment #68
longwaveOne more setPublic() fix.
Comment #69
longwaveOpened #3185603: [Symfony 5] Symfony Constraint plugins are not strictly Drupal plugins to deal with the Constraint issue described in #67.
Comment #71
longwaveFixed some of the container issues by forcing services to public.
Comment #72
andypostpsr/event-dispatcher | NEW | 1.0.0Interesting how it compatible with pecl psr C extension https://pecl.php.net/package/psr
edit yes, it's https://github.com/jbboehr/php-psr/blob/master/psr_event_dispatcher.c#L23
Comment #74
longwaveA few more little fixes.
Comment #76
longwaveOpened #3187074: [Symfony 5] Services are private by default for the dependency injection changes.
Comment #77
longwaveOpened #3187857: [Symfony 6] Service deprecation messages require more fields for a new deprecation in SF 5.1.
Comment #78
gábor hojtsyComment #79
longwaveIf my local testing is right, this should be green. This is #74 with fixes for all the tests:
Comment #80
longwaveOpened #3188056: [Symfony 5] Symfony\Component\Serializer\Encoder\DecoderInterface::decode() no longer accepts NULL as $format to fix RequestHandlerTest as we can do this now.
Comment #81
gábor hojtsy#3188056: [Symfony 5] Symfony\Component\Serializer\Encoder\DecoderInterface::decode() no longer accepts NULL as $format landed.
Comment #82
gábor hojtsy#3185603: [Symfony 5] Symfony Constraint plugins are not strictly Drupal plugins landed.
Comment #83
daffie commentedI have some problems with releasing D10 with Symfony 6. Symfony 6 is to be released in november 2021. A new minor version is to be released every 6 months, in may and november. Every major and minor version will 8 months of bug- and security fixes, with the exception of the last minor release of every major release. That one will get 3 years of bug fixes and 4 years of security fixes. See: https://symfony.com/doc/current/contributing/community/releases.html.
If everything does according to plan then D10 will be release in june 2022. In the previous month will Symfony 6.1 be released. Every Drupal minor release gets 6 months of bug fixes and 12 months of security fixes. For D10.0 that will result in that in januari 2023 it will be giving 4 more months of security fixes when Symfony has stopped giving any support version 6.1. This does not sound very exceptable to me. We can update the required Symfony version for D10.0 from 6.1 to 6.2 in december 2022 or januari 2023. Only there will a risk in doing that. For instance in Symfony 5.2 they made services fully private by default. See: #3187074: [Symfony 5] Services are private by default. Which would result in a big BC break. If we want to minimize the risk of creating BC breaks we will have to go with a release of Symfony that is a LTS release. Therefore for me releasing D10 with Symfony 6 is not a acceptable option.
Comment #84
catchThis is true, but we have an agreement with Symfony's security team that if we are on a recently-out-of-support minor version, we can help them backport changes to the version we're using, only for components we're using, and they'll make an official security release of that version at the same time. So if they do a security release in that window, we have to do some extra work, but we don't get into a situation where we have to fork or upgrade to a minor release during a patch release.
We will need to go 6.1 -> 6.2, 6.2 -> 6.3 and 6.3 -> 6.4 in the respective minor Drupal releases, but we've done several Symfony minor releases (we even did Symfony 2 to Symfony 3) during the Drupal 8 cycle, and while they weren't problem-free, we have managed OK.
If we release on the Symfony 5.4 LTS, then we only get security support until November 2025, this will force us to release Drupal 11 by November 2024 (or ideally June 2024 - otherwise the Drupal 9 LTS release would not really be an LTS at all), which is about half the time between Drupal 8 and 9. Even if we wanted to move to shorter major release cycles, it would nice to be able to do this by choice instead of being determined entirely by dependency support cycles.
Comment #85
daffie commented@catch Thank you your response and great to hear how the problem is solved. If releasing D10 with Symfony 6 is that important, can we then make all issues for getting there critical?
Comment #86
catch@daffie yes IMO they can all be critical. If it turns out we can't release on Symfony 6 because we're unable to bridge the gap from 4, then we'd have to release on Symfony 5.4, but for me I think Symfony 6 should be the goal - and we have to do all that work at some point anyway.
Comment #87
andypostSession usage will need review as SF deprecated session service finally https://github.com/symfony/symfony/pull/38616
Comment #88
longwave#87: that only looks like it affects FrameworkBundle which we don't use, the changes in HttpFoundation (which we do use) only add a single method.
Comment #89
daffie commentedI was wondering how we are going to add deprecation messages for stuff that gets deprecated in Symfony 5. We would like to use Symfony 6 in D10, only when we do that, we should add deprecation messages for that stuff in D9. And in D9 we use Symfony 4 and in that version in the stuff not jet deprecated. How can we fix this?
In #3162016: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated we are fixing it for core, only we cannot add a deprecation message for contrib and custom modules. The when your D9 website works without getting deprecation messages your site will work in D10, is no longer valid. Is this acceptable or can we add deprecation messages in another way?
Changing the status to critical as we would like to release D10 with Symfony 6. Got the oke from @catch for this (comment #86).
Edit: Would it be possible to create a patch file that from Drupal core would update the method Symfony\Component\HttpFoundation\InputBag::get() and add deprecation message? Just an idea.
Comment #90
daffie commentedAdded #3195533: [Symfony 6] The constant Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_ALL is deprecated. to the list with remaining tasks.
Comment #91
daffie commentedAdded #3195571: [Symfony 6] The constant Symfony\Component\Routing\RouteCompiler::REGEX_DELIMITER is deprecated. to the list with remaining tasks.
Comment #92
daffie commented#3195533: [Symfony 6] The constant Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_ALL is deprecated. and #3195571: [Symfony 6] The constant Symfony\Component\Routing\RouteCompiler::REGEX_DELIMITER is deprecated. have landed. Removing them from the remaining tasks list.
Comment #93
daffie commented#3187074: [Symfony 5] Services are private by default also has landed. Also removed from the remaining tasks list.
Comment #94
daffie commentedAdded #3196027: Contrib support solution needed for potential Symfony 4 to 6 upgrade, Symfony 5 only deprecations are not available in Symfony 4 to the list of remaining tasks.
Comment #95
gábor hojtsyOpened #3197482: Update Drupal 10 to depend on Symfony 5.4 (as a stepping stone to Symfony 6, for deprecation checking support) for the must have update to Symfony 5 and #3197483: Evaluate the potential update of Drupal 10 to Symfony 6 and do it if possible for the potential update to Symfony 6.
Comment #96
longwaveNow many of the compatibility fixes have been committed this is getting smaller. This is #79 rebased then upgraded to Symfony 5.2.3. The composer build tests will fail because I removed the minimum-stability changes, really we need a stable release of behat/mink-browserkit-driver.
Comment #97
longwaveSomething went wrong when merging composer.lock, let's try again.
Comment #99
gábor hojtsy#3161983: [Symfony 6] Update EventDispatcherInterface type hints in constructors landed, removing from issue summary. Great progress :) Looking forward to what new things we are still to find.
Comment #100
longwaveFixed two failing tests by removing MimeTypePass and another legacy test. Also testing out a deprecation fix by applying #3187857: [Symfony 6] Service deprecation messages require more fields.
Comment #102
daffie commented#3187857: [Symfony 6] Service deprecation messages require more fields has landed.
Comment #103
gábor hojtsyQuick reroll of #100, it did not need #3187857: [Symfony 6] Service deprecation messages require more fields anymore, given that it landed.
Comment #105
xjmComment #106
longwaveOpened #3199691: [Symfony 6] Symfony no longer parses octal numbers starting with 0 alone which seems like a seldom used edge case but something we still have to deal with.
Comment #107
catchComment #108
greenreaperSymfony 6 requires PHP 8.0, so #3173787: [policy] Require PHP 8.1 for Drupal 10.0 if a dependency does, otherwise require PHP 8.0. (up from 7.3 in Drupal 9) must be considered, #3109885: [meta] Ensure compatibility of Drupal 9 with PHP 8.0 (as it evolves) seems to indicate compatibility, but I'm unsure if testing with 7.x handles that.
Perhaps it was assumed that 8.x would be a requirement, but I don't see it mentioned. Debian 11 will have 7.4, but 8.x is obtainable.
Comment #109
gábor hojtsy@GreenReaper: Drupal 10 is indeed planned to require PHP 8. See #3118147: [meta] Set Drupal 10 platform and browser requirements six months before the release. Upgrade Status is already checking for this requirement on Drupal 9 (#3202955: Start checking PHP 8 requirement on Drupal 9). PHP 7 end of life (November 2022) is only slightly later than Drupal 10's release date (June 2022 earliest).
Comment #110
gábor hojtsyComment #112
longwaveRerolled #103 into a merge request, updated Symfony components, applied #3162016: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated, and removed all three Symfony 5 deprecations as they should now be fixed.
Comment #113
longwaveOpened #3209239: [Symfony 5] Symfony\Contracts\EventDispatcher\Event subclasses need return types and merged it here as that is the cause of many of the test failures.
Comment #114
catchSymfony 5.3 beta1 tagged yesterday: https://github.com/symfony/symfony/releases/tag/v5.3.0-BETA1
Comment #115
longwaveOpened #3209482: [Symfony 6] Update EventDispatcherInterface type hint in FileUploadResource constructor as that is the cause of most of the rest of the test failures.
Comment #116
longwaveMerged in #3209459: Switch to friends of behat MinkBrowserKitDriver for PHP 8 and Symfony 5 compatibility which should hopefully get us a green test run.
Next step is to try the 5.3 beta.
Comment #117
longwaveLots of failures due to this change in symfony/http-kernel: https://github.com/symfony/symfony/pull/39893/files
Comment #118
longwaveOpened three new issues for SF5.3 deprecations:
#3209617: [Symfony 6] Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() is deprecated, use getMainRequest() instead
#3209618: [Symfony 6] Symfony\Component\HttpKernel\Event\KernelEvent::isMasterRequest() is deprecated, use isMainRequest() instead
#3209619: [Symfony 6] Passing null as $message to Symfony exception constructors is deprecated, pass an empty string instead
Comment #119
longwaveRemaining two fails are a vendor hardening issue for #3209459: Switch to friends of behat MinkBrowserKitDriver for PHP 8 and Symfony 5 compatibility and ComposerProjectTemplatesTest refusing to allow non-stable dependencies which is #3186364: Allow pre-release dependencies in Drupal pre-release milestones.
Comment #120
andypostThere are other deprecations but does no effect, more interesting looks new helpers on request stack to get session https://github.com/symfony/http-foundation/blob/5.x/CHANGELOG.md
Comment #122
longwaveUpdated the MR to Symfony 5.3.0-beta3.
Comment #123
longwavesymfony/dependency-injection appears to have a hard dependency on symfony/config when running on PHP 8, I can reproduce with a minimal test case:
Comment #124
longwaveRaised #124 over at https://github.com/symfony/symfony/issues/41169 to see what Symfony maintainers have to say here.
Comment #125
longwaveThe three fails are all build related, one is #3186364: Allow pre-release dependencies in Drupal pre-release milestones because we are using a Symfony beta and the other two are related to the Symfony patch but will be resolved when the patch lands in a release.
Comment #126
andypostFixed beta is out https://github.com/symfony/symfony/releases/tag/v5.3.0-BETA4
Comment #127
andypostSF 6 branch is open, and https://github.com/symfony/symfony/releases/tag/v5.3.0-RC1 is out
Comment #128
longwaveLooking at the changelog I am not sure it is worth updating here again until 5.3.0 is out or 5.4 opens.
Comment #129
longwaveComment #130
gábor hojtsyRemoving issues from the issue summary that landed:
Fantastic!
Comment #131
gábor hojtsyAlso given #3209459: Switch to friends of behat MinkBrowserKitDriver for PHP 8 and Symfony 5 compatibility landing earlier, removing this section from the issue summary, since it is not relevant anymore as far as I understand:
Comment #132
gábor hojtsyAlso moving #3196027: Contrib support solution needed for potential Symfony 4 to 6 upgrade, Symfony 5 only deprecations are not available in Symfony 4 to its own section since it is not in the same scope as the other core issues.
Comment #133
daffie commentedWe also have #3209723: [Symfony 6] Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST is deprecated, use ::MAIN_REQUEST instead, that needs to be fixed.
Comment #134
longwaveThanks to @effulgentsia for lots of work on #3186364: Allow pre-release dependencies in Drupal pre-release milestones which means we are finally green on this MR with an RC release of Symfony.
Comment #135
catchComment #137
catchSymfony 5.4 is branched, so reviving this one.
Started a new branch since it's a bit easier than rebasing the old one, but only got it to the point where tests will run (various deprecated Symfony classes we have to remove references to, to even be able to run tests).
Comment #138
catchLooks like some new issues:
#3231389: [Symfony 6] Add a string return type hint to Drupal\Tests\DocumentElement::getText()
#3231390: [symfony 6] Add an object return type hint to Drupal\Tests\DrupalTestBrowser::doRequest()
#3231393: [Symfony 6] Symfony\Component\DependencyInjection\Alias::getDeprecationMessage() and Symfony\Component\DependencyInjection\Definition::getDeprecationMessage() method is deprecated, use getDeprecation()
Comment #139
longwaveGood news that Symfony has figured out deprecation notices for return type additions, we can surely borrow this technique ourselves.
Comment #140
daffie commented@longwave: Do you have a link for that?
Comment #141
longwave@daffie: Symfony's DebugClassLoader provides this functionality; there is no documentation yet but https://github.com/symfony/symfony/pull/42623 is the PR where this was added to SF 5.4.
Comment #142
catchQuite a lot of return type hint deprecation messages from Guzzle vs. PSR-7, so incorporating #3104353: Upgrade to Guzzle 7.
Comment #143
catchWe also need #3209619: [Symfony 6] Passing null as $message to Symfony exception constructors is deprecated, pass an empty string instead - added a commit with the diff from that PR too.
Comment #144
daffie commentedA couple more type hint fixes:
Comment #145
daffie commentedYet again couple more type hint fixes:
Comment #146
daffie commentedFixing #3231683: [Symfony 6] A number of methods of the class Drupal\Core\TypedData\Validation\ExecutionContext are considered internal and Drupal should not override them. will be a bit more difficult.
Comment #147
daffie commentedYet again a couple of new return type hint fixes that can be committed to D9:
The ones that have to wait for D10:
@catch: Thank you for updating the MR for Symfony 5.4. It makes it easier to see which ones still need to be done. Could you do it again?
Comment #148
catchSince a lot of the new return type hints require PHP 8, we probably need a Drupal 9 issue to suppress a load of these deprecation messages (could be one issue probably).Edit: no we don't need that, because these are 5.3/5.4 deprecations and we don't need to update to that in Drupal 9. So it's fine to have a load of PHP 8-only PHP 10-only issues. If any of these affect base class methods we might need an issue to pass them down to contrib in Drupal 9 though (although to resolve the deprecation, contrib would have to require PHP 8).
Comment #149
daffie commentedComment #150
daffie commentedComment #151
daffie commentedComment #152
daffie commentedComment #153
catchComment #154
daffie commentedThe following issues have landed:
Comment #155
daffie commentedMoved #3231688: [Symfony 6] Add type hints to Drupal\Core\TypedData\Validation\ExecutionContext to the must be done in the 10.0 branch.
Comment #156
daffie commentedMoved #3232082: [Symfony 6] Add "Response" type hint to methods that implement the method Symfony\Component\HttpKernel\HttpKernelInterface::handle() back to the list that can be done in 9.3.
Comment #157
daffie commentedAdding #3236563: [Symfony 6] Add "static" type hint to the methods overriding Symfony\Component\HttpFoundation\Response::sendContent() to the must wait for the D10.0 branch.
Comment #158
daffie commentedMoved #3232095: [Symfony 6] Refactor the "update.root" service to return an object not a string over to the update module. This issue needs special attention, because it is failing update tests.
Comment #159
daffie commentedComment #160
daffie commentedComment #161
daffie commentedAdded #3238210: The mocked method in Drupal\Tests\Core\Routing\LazyRouteCollectionTest does not return an ArrayIiterator to the todo list.
Comment #162
daffie commentedThe adds Symfony 5.4-dev package and a number of yet to be committed patches:
Comment #163
daffie commented#3238210: The mocked method in Drupal\Tests\Core\Routing\LazyRouteCollectionTest does not return an ArrayIiterator has landed.
Comment #164
daffie commentedThe remaining deprecation warnings for deprecations from Symfony 5.4 are from:
Comment #166
daffie commentedMoved #3233031: [Symfony 6] Add "RequestContext" type hint to methods overridding Symfony\Component\Routing\RequestContextAwareInterface::getContext() and #3232097: [Symfony 6] Add "array" type hint to methods overriding Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents() to the must be done in the 10.0 branch.
Comment #167
daffie commentedMoved #3232074: [Symfony 6] Add "array|string|int|float|bool|\ArrayObject|null" to all Normalizer classes that implement the method ::normalize() back to the list of stuff that must be done in the 9.3 branch.
Comment #168
daffie commentedAdded #3238485: [Symfony 6] Add return type hints to the class methods of Drupal\Component\DependencyInjection\Container to the must be done in 10.0 branch and moved #3232095: [Symfony 6] Refactor the "update.root" service to return an object not a string to be done in the 9.3 branch.
Comment #169
daffie commentedComment #170
andypostGood docs about migration
https://symfony.com/blog/preparing-your-apps-and-bundles-for-symfony-6
Comment #171
daffie commented#3232074: [Symfony 6] Add "array|string|int|float|bool|\ArrayObject|null" to all Normalizer classes that implement the method ::normalize() has landed.
Comment #172
longwaveWhat do we need to do about the non-Symfony deprecations? Is it time to add a regex to skip these?
I am not sure these are guaranteed true about future changes in PHP itself, and even third party packages cannot be trusted here, surely?
Comment #173
catchThose are invented by DebugClassLoader and we didn't get a good response to #3232131: [Symfony 5] Symfony's DebugClassLoader triggers deprecation messages for missing return type hints, where there is no deprecation, so skipping them seems like the only option here.
Comment #175
longwaveRerolled #163 and added a deprecation skip for DebugClassLoader warnings that don't explicitly refer to Symfony classes.
Comment #176
longwaveFix coding standards.
Comment #177
longwaveSkip another set of false positives, things like:
The interface and the implementation match in all cases as far as I can see. This might be a bug that we should report upstream to Symfony, it is misreading our docblocks somehow - looks like it might be triggered by two $variables mentioned in one @param.
edit: raised at https://github.com/symfony/symfony/issues/43936
Comment #179
longwaveThanks @andypost for noticing that Symfony 5.4.0-beta1 is out, rerolled for that.
Comment #180
longwaveAccidentally commented out a line.
Comment #182
longwaveMerged #180 into 3161889-symfony-5-4 and added some more third-party deprecation skips and also a few compatibility fixes.
Comment #183
longwaveNot sure how I marked the MR as draft, nor how I can unmark it again.
Comment #184
longwaveTry again with patch workflow.
Comment #185
daffie commentedI am missing the deprecation warnings for #3232095: [Symfony 6] Refactor the "update.root" service to return an object not a string? Any idea why they are not in the patch from #184. They are in the patch from #180.
Comment #186
longwavePHPUnit didn't even run in #184 because I got my core versions mixed up. I rebuilt composer.lock with the right version and also applied the patch from #3232095: [Symfony 6] Refactor the "update.root" service to return an object not a string.
Comment #188
longwaveThis patch removes the legacy event dispatcher and MIME type guesser support, which are failing because they are gone from Symfony 5.4. Also fixed a few other minor issues along the way.
Drupal\Tests\Core\Routing\RouterTest fails with
Prophecy does not yet support
staticreturn type, this is tracked at https://github.com/phpspec/prophecy/issues/527Comment #190
daffie commentedAdded:
Comment #191
daffie commentedJust 3 fails left with the testbot. One is because we are not using a stable release with Symfony. The other 2 are because we are waiting for a fix with phpspec/prophecy-phpunit. See: https://github.com/phpspec/prophecy/issues/527
Comment #192
daffie commentedAdded the following issues to the list:
Comment #193
daffie commentedLanded:
Comment #194
daffie commented#3248014: [Symfony 6] The Drupal\Tests\media\Kernel\OEmbedIframeControllerTest fails has landed.
Comment #195
andypostFYI SF released beta 3
Comment #196
longwaveReroll for latest changes and Symfony 5.4 beta3
Comment #198
daffie commentedFix for the failures in the patch from comment #196. They are all ckeditor5 related.
Comment #200
daffie commentedAdded #3250299: [Symfony6] A number of CKEditor5 tests fail for Symfony 5.4 to the todo list
Comment #201
daffie commentedAdded the problem with Prophecy with the "static" return type hint. See: https://github.com/phpspec/prophecy/issues/527.
Comment #202
daffie commented#3250299: [Symfony6] A number of CKEditor5 tests fail for Symfony 5.4 has landed.
Comment #203
daffie commentedFix the failures with Prophecy with "static" return type hinting.
Comment #204
daffie commentedFix for the style code violation.
Comment #205
daffie commentedAdded #3250442: [Symfony 6] Symfony 6 adds static return type hinting and Prophecy fails on it. to change the testing from prophecy to mocking.
Comment #206
gábor hojtsyReparenting to #3251854: [META] Requirements for tagging Drupal 10.0.0-alpha1 which is where we plan to solve this now. Issue summary only lists things to do on the Drupal 10 branch which is open for business now :)
Comment #207
gábor hojtsyOpened #3252757: Update Drupal 10 to depend on Symfony 6.0 to do the actual update later. That though will not happen in alpha1 as we plan to update to 5.4 in alpha1 and later update to 6.0, so people can use alpha1 as a deprecation testing target.
Comment #208
catchJust saving the issue summary to see where we are.
Comment #209
gábor hojtsyComment #210
daffie commentedComment #211
daffie commentedComment #212
daffie commentedComment #213
catchComment #214
gábor hojtsyThe two listed must haves were committed.
Comment #215
gábor hojtsyAdding #3255245: [Symfony 6] Revert 3231603 to use our own TranslatorInterface as must-have since the other two must haves also landed.
Comment #216
daffie commentedAdd #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. to the must have list.
Comment #217
catchI've moved #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. to a should-have. It's something that might cause problems in the future, but it's not deprecated for removal, so doesn't actually stop us updating to Symfony 6.
Comment #218
gábor hojtsy#3255245: [Symfony 6] Revert 3231603 to use our own TranslatorInterface was the only remaining must have, removing from issue summary.
Consequently #3197482: Update Drupal 10 to depend on Symfony 5.4 (as a stepping stone to Symfony 6, for deprecation checking support) is RTBC and about to land, woot!
Comment #219
longwaveI tried an experimental update to Symfony 6 but failed because of a dependency clash:
Core uses
stack/builderbut that only currently supports Symfony 2.x through 5.x: https://github.com/stackphp/builder/blob/master/composer.json#L14-L15Comment #220
catchPosted https://github.com/stackphp/builder/pull/29edit: longwave posted https://github.com/stackphp/builder/pull/30
edit again: Added #3258902: [Symfony 6] Bring stackphp/builder into core for Symfony 6 compatibility and remove it as a dependency to track this.
We probably won't actually update to Symfony 6 until we've released an alpha with all/most Drupal deprecations removed. To unblock prep work we can probably point to longwave's fork in patches/MRs for now.
Comment #221
longwaveAs noted in #220 this requires a modified
stack/builderfor the time being.At least one unit, kernel and functional test passed with the attached patch, but I expect a large number of fails here.
It turns out that the Symfony return type checker skips the cases where we provided our own docblock instead of using inheritdoc, so there's a whole bunch more return types to add.
Comment #222
longwaverun-tests.sh still uses the deprecated
app.rootservice, opened #3258995: run-tests.sh uses the deprecated app.root serviceComment #223
longwaveA few more fixes, will spin some of these out to individual issues soon.
Comment #224
longwaveReroll following #3258995: run-tests.sh uses the deprecated app.root service
Comment #225
daffie commentedThis change is missing ")", just before ": array"
Comment #226
longwaveThank you @daffie, fixed here plus another round of fixes.
Not sure what to do about Router::matchCollection(), where we declare:
but the parent return type is now just array and NULL is not allowed. Maybe we have to use exceptions instead?
Comment #227
longwaveComment #229
longwaveReroll plus another batch of fixes, incorporating
#3259169: [Symfony 6] Drupal\Core\Controller\ControllerResolver does not need to extend Symfony
#3259674: [Symfony 6] Drupal\Core\Routing\Router::matchCollection(): Return value must be of type array, null returned
#3259675: [Symfony 6] Drupal\Core\Routing\LazyRouteCollection::all(): Return value must be of type array, ArrayIterator returned
Comment #230
longwaveAnother round. The following still need work:
Comment #231
daffie commentedThe patch updates all Symfony packages to version 6.0, with the exception of "symfony/console". Composer is extending classes from the package "symfony/console" and Composer has not yet added the required return type hints.
Second is that the package "behat/mink" now must use the "dev-master" version. Therefor the test ComposerProjectTemplatesTest needs a couple of temporary fixes.
Comment #232
daffie commentedStyle guide fixes.
Comment #234
longwaveWhile it makes the tests pass I am not sure the fix to PhpArrayDumperTest is correct, we need to understand if service references have changed somehow in Symfony 6.
Comment #235
daffie commentedThe change to the test
core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.phpis necessary, because of the added parameter type hint to the methodSymfony\Component\DependencyInjection\ParameterBag\ParameterBag::set().In Symfony 5.4 it is:
In Symfony 6.0 it has changed to:
In Symfony 6.1 it will changed to:
The parameter
$valuehas the value to an instance ofSymfony\Component\DependencyInjection\Referenceand an object is not part of the added parameter type hint.Comment #236
longwave@daffie thanks for the explanation. So I guess the question is: do we actually need to support service references as container parameters? If not, I think we should just drop this test case from the data provider as it makes no sense:
I went back to the original commit and issue for this and found that this code was added in #2497243-154: Replace Symfony container with a Drupal one, stored in cache. Next step is to figure out if this was a nice-to-have at the time or if this was a Symfony feature that we ported over.
My suspicion is that we don't need to support this any more, as as you found container parameters cannot be objects (as opposed to services which must now be objects, as we found a while back with the
app.rootservice).Comment #237
longwaveDid a bit more research into the Symfony side of things. As far as I can see Symfony has never supported objects in ParameterBags; for example here is their test fixture from Symfony 3.4: https://github.com/symfony/dependency-injection/blob/3.4/Tests/Fixtures/...
As far as I can see we have never had a use for feature that in core either, so to me the correct fix here is to drop that test case from the data provider.
Comment #238
longwaveLooks like this is actually inconsistent in Symfony!
The PHP dumper does not support references here:
https://github.com/symfony/dependency-injection/blob/6c566c7b29e36daa806...
but the YAML dumper does support them:
https://github.com/symfony/dependency-injection/blob/6c566c7b29e36daa806...
Comment #239
longwaveSimilar to the way we switched from
behat/mink-browserkit-drivertofriends-of-behat/mink-browserkit-driver, we can do the same forbehat/minktofriends-of-behat/minkwhere there is a PHP 8/Symfony 6 compatible release already.I also added the patch from #3262853: [Symfony 6] Drop support for services as container parameters which should be the only outstanding blocker.
Note that symfony/console is still on 5.x because there is no stable release of Composer that supports Symfony 6.
Comment #240
daffie commented@longwave: Sounds as a great idea. Do you have an issue for it?
Comment #241
daffie commented#3262853: [Symfony 6] Drop support for services as container parameters has landed.
Comment #242
longwave#3263841: [Symfony 6] Swap behat/mink for friends-of-behat/mink
Comment #243
gábor hojtsyPublished the change record draft, since it was for 9.3.0 already: https://www.drupal.org/node/3236232
Also in #3252757: Update Drupal 10 to depend on Symfony 6.0 @longwave says there is nothing actionable left in this one. I guess that will be proven in part based on the test runs there.
Comment #244
xjmIt's in!
Any followups should be re-parented to #3118149: [meta] Requirements for tagging Drupal 10.0.0-beta1.
Thanks everyone; this is awesome!