Problem/Motivation

The Symfony method Request::setTrustedHosts() is a static method, we use it as non-static in
DrupalKernel::setupTrustedHosts(). The method is static in Symfony 4 and Symfony 6.

Proposed resolution

Change $request->setTrustedHosts($host_patterns); to $request::setTrustedHosts($host_patterns);

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

CommentFileSizeAuthor
#8 3276939-3.patch608 bytesaziza_a
#2 3276939-2.patch614 bytesdaffie

Comments

daffie created an issue. See original summary.

daffie’s picture

StatusFileSize
new614 bytes

The fix.

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.

ameymudras’s picture

Status: Needs work » Needs review

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.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Going to leave the tests tag for the committers to decide.

This seems more like a code cleanup vs a bug though.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -1510,7 +1531,7 @@ public static function validateHostname(Request $request) {
-    $request->setTrustedHosts($host_patterns);
+    $request::setTrustedHosts($host_patterns);

Shouldn't this just be Request::setTrustedHosts then?

aziza_a’s picture

StatusFileSize
new608 bytes

Updated patch as per #7 comment

aziza_a’s picture

Status: Needs work » Needs review
daffie’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

  • larowlan committed dce8ca65 on 10.0.x
    Issue #3276939 by daffie, aziza_a, larowlan: The Symfony method Request...
larowlan’s picture

Version: 10.1.x-dev » 9.5.x-dev
Issue tags: -Needs tests

Committed to 10.1.x and cherry-picked back to 9.5.x as the risk of disruption is low

  • larowlan committed e8cdbb69 on 10.1.x
    Issue #3276939 by daffie, aziza_a, larowlan: The Symfony method Request...

  • larowlan committed 110ea7ce on 9.5.x
    Issue #3276939 by daffie, aziza_a, larowlan: The Symfony method Request...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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