Problem/Motivation

In #3209617: [Symfony 6] Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() is deprecated, use getMainRequest() instead we added a BC shim that supports RequestStack that could have either getMainRequest() or getMasterRequest() methods.

Now Drupal 10 has moved to Symfony 6 we can deprecate the code that handles the getMasterRequest() method, so we can use the Symfony class directly again in D10 and remove the shim in #3265121: Remove Symfony 4 RequestStack BC shim in 11.0.x.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3265356

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Spokje created an issue. See original summary.

andypost’s picture

Status: Active » Needs work
--- Errors ---
PHP Fatal error:  Uncaught Error: Call to undefined method Symfony\Component\HttpFoundation\RequestStack::getMainRequest() in /var/www/html/core/lib/Drupal/Core/DrupalKernel.php:935
Stack trace:
#0 /var/www/html/core/lib/Drupal/Core/DrupalKernel.php(472): Drupal\Core\DrupalKernel->initializeContainer()
#1 /var/www/html/core/lib/Drupal/Core/Test/TestRunnerKernel.php(75): Drupal\Core\DrupalKernel->boot()
#2 /var/www/html/core/scripts/run-tests.sh(561): Drupal\Core\Test\TestRunnerKernel->boot()
#3 /var/www/html/core/scripts/run-tests.sh(51): simpletest_script_init()
#4 {main}
  thrown in /var/www/html/core/lib/Drupal/Core/DrupalKernel.php on line 935
Spokje’s picture

Title: Deprecate Symfony 4 RequestStack BC shim for removal in D10 » Deprecate Symfony 4 RequestStack BC shim for removal in D10.x
Version: 9.4.x-dev » 10.0.x-dev
Status: Needs work » Active

Don't think deprecation in D9.4 can happen, since we're on Symfony 4, so we need the shim there.

Let's see if we can deprecate in D10.0 and remove in D10.1.

Spokje’s picture

Title: Deprecate Symfony 4 RequestStack BC shim for removal in D10.x » Deprecate Symfony 4 RequestStack BC shim for removal in D10.1.x
Spokje’s picture

Priority: Normal » Major

Since the is blocking #3227033: Remove Quick Edit from core which has priority Major, I think this issue should also have that priority.

Spokje’s picture

Status: Active » Needs review

Ok, at least the appeases the PHPStan/PHPCS/Spellcheck and Testbot gods...

Undoubtedly there can be improvements of wording in CR and thus the deprecation messages, may somebody can even find a clever way to deprecate this in D9.4 already, but this is the best I can do and as far as I can take this issue.

BTW: This issue not only blocks #3227033: Remove Quick Edit from core but in fact _any_ patch/MR that includes changes in the PHPStan baseline (core/phpstan-baseline.neon).

Spokje’s picture

Assigned: Spokje » Unassigned
Spokje’s picture

Version: 10.0.x-dev » 9.4.x-dev
Assigned: Unassigned » Spokje
Status: Needs review » Needs work

Right, the age-old rule C-before-C (Coffee-before-Commit) proven once again.

I think we can deprecate in 9.4.x-dev after all.

Spokje’s picture

Title: Deprecate Symfony 4 RequestStack BC shim for removal in D10.1.x » Deprecate Symfony 4 RequestStack BC shim for removal in D11

According to @catch here #3209617-21: [Symfony 6] Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() is deprecated, use getMainRequest() instead we can only deprecate for removal in D11, so let's roll with that.

Which would mean changes in 10.0.x-dev and another MR for 9.4.x-dev.

Spokje’s picture

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

Sorry for the noise and the MR graveyard this is turned into :/

catch’s picture

fwiw I think #3209617-21: [Symfony 6] Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() is deprecated, use getMainRequest() instead is still right, it lets 9.4.x-compatible modules start using the Symfony 5/6 API in 9.4, but then once they're using in 9.4, we don't want to break them in 10.x if they use the shim directly, so deprecating for removal 11.x works.

Agree with removing the support for getMasterRequest() from 10.x, which is already in the MR.

Spokje’s picture

Status: Needs work » Needs review

Thanks @catch, so deprecating for removal in 11.x is the way to go (is this the first one? Do we get a prize?)

So do/can we deprecate in 9.4.x already, or should we do that in 10.0.x?

The current MRs/CR is based on that assumption, if we get onboard of the 10.0.x-deprecation-train, we need to close the 9.4.x MR, change the deprecation error in the 10.0.x and the CR and we should be good to go.

andypost’s picture

Priority: Major » Normal
Status: Needs review » Needs work

As I got catch we should just deprecate in D10 for removal in D11, so you need to revert change to masterRequest and just update its deprecation message to include a link to https://www.drupal.org/node/3253744

andypost’s picture

Status: Needs work » Needs review
FileSize
4 KB
6.03 KB

I mean the already deprecated getMasterRequest() should be removed in D10 sametime as the shim deprecated

Here's my vision

Spokje’s picture

Thanks @andypost.

If you're vision is the correct one (which is probably is), I think it should mention remove in Drupal 11 in the @todos instead of the currently mentioned 10. I think there are 2 of them. To late down here to do a full review, and I can't RTBC it anyway.

+ * @todo Remove this in Drupal 10 https://www.drupal.org/node/3265121

andypost’s picture

Thank you! nice catch!

andypost’s picture

btw there's only 2 references explaining how to provide link to removal https://www.drupal.org/about/core/policies/core-change-policies/drupal-d...

neclimdul’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/lib/Drupal/Core/Http/RequestStack.php
@@ -19,20 +26,8 @@ class RequestStack extends SymfonyRequestStack {
+    @trigger_error('The ' . __NAMESPACE__ . '\RequestStack is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3265357', E_USER_DEPRECATED);
+    return parent::getMainRequest();

I wonder if we really need to deprecate this method or if we can just have an empty class. Its seems likely to trigger in correct code that's having the wrong class injected.

Anyways, that's not a critical change. With the @todo fixed to 11 I think this is an easy RTBC.

andypost’s picture

andypost’s picture

andypost’s picture

Assigned: Spokje » Unassigned
Related issues: +#3265121: Remove Symfony 4 RequestStack BC shim in 11.0.x
andypost’s picture

@neclimdul Re#26 the reason to provide this message is to catch unit-tests which used to call the method, no idea if class load is enough

Spokje’s picture

Changed CR to deprecation in D10.0.0.
Buried outdated CRs

  • catch committed bc964dc on 10.0.x
    Issue #3265356 by Spokje, andypost, neclimdul: Deprecate Symfony 4...
catch’s picture

Status: Reviewed & tested by the community » Fixed

So I think the other option here just to make phpstan quiet would have been to remove the ::getMasterRequest() method without deprecating.

That would mean we'd need a follow-up to deprecate in 10.1.x to remove in 11.x, but ::getMasterRequest() is only used by a handful of modules in contrib: http://grep.xnddx.ru/search?text=getMasterRequest&filename= - and a similarly small number that directly use Symfony's RequestStack. Only the intersection of the two (which I did not check, but must be lower) would be affected by the deprecation here.

So I think the number of contrib modules that will need to actually use the shim in 9.4.x will be very low, meaning the number affected by it being deprecated in Drupal 10.0.x will also be very low.

We can't deprecated it in 9.4.x for removal in 11.x because we don't have the new RequestStack object available yet, and also because core uses it.

Committed bc964dc and pushed to 10.0.x. Thanks!

Status: Fixed » Closed (fixed)

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