Skip to content
Snippets Groups Projects

Issue 3420768: Unrouted Url assember base_url fix

Open Alec Smrekar requested to merge issue/drupal-3420768:3420768 into 11.x
4 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
122 122 * {@inheritdoc}
123 123 */
124 124 public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
125 $url_scheme = 'http';
126 $port = 80;
125 global $base_url;
  • Alec Smrekar added 1 commit

    added 1 commit

    • 9e9fe4a6 - Issue 3420768: Replace global usage with request stack

    Compare with previous version

  • Alec Smrekar added 1 commit

    added 1 commit

    • 46bb2cbe - Issue 3420768: Replace global usage with request stack

    Compare with previous version

  • Alec Smrekar added 1 commit

    added 1 commit

    • e98e5a63 - Issue 3420768: Replace global usage with request stack

    Compare with previous version

  • 124 153 public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
    125 154 $url_scheme = 'http';
    126 155 $port = 80;
    127 if ($request) {
    128 $url_scheme = $request->getScheme();
    129 $port = $request->getPort();
    156 $main_request = $this->requestStack->getMainRequest();
    157 if ($main_request) {
    158 $url_scheme = $main_request->getScheme();
    159 $port = $main_request->getPort();
    • Actually I meant something along these lines, otherwise the $request parameter is completely ignored:

      diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
      index fe9007de58..275659b6d8 100644
      --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
      +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
      @@ -151,13 +151,11 @@ public function processInbound($path, Request $request) {
          * {@inheritdoc}
          */
         public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
      -    $url_scheme = 'http';
      -    $port = 80;
      -    $main_request = $this->requestStack->getMainRequest();
      -    if ($main_request) {
      -      $url_scheme = $main_request->getScheme();
      -      $port = $main_request->getPort();
      +    if (!$request) {
      +      $request = $this->requestStack->getMainRequest();
           }
      +    $url_scheme = $request->getScheme();
      +    $port = $request->getPort();
           $languages = array_flip(array_keys($this->languageManager->getLanguages()));
           // Language can be passed as an option, or we go for current URL language.
           if (!isset($options['language']) || ($options['language'] instanceof LanguageInterface && $options['language']->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED)) {
      
    • Alec Smrekar changed this line in version 8 of the diff

      changed this line in version 8 of the diff

    • Please register or sign in to reply
  • 566 566 // Test HTTPS via current URL scheme.
    567 567 $request = Request::create('', 'GET', [], [], [], ['HTTPS' => 'on']);
    568 568 $request->setSession(new Session(new MockArraySessionStorage()));
    569 $this->container->get('request_stack')->push($request);
    569 // Clear the stack. The newly created request will become the main one,
    570 // which will be checked in LanguageNegotiationUrl::processOutbound.
    571 $request_stack = $this->container->get('request_stack');
    572 $request_stack->pop();
    573 $request_stack->push($request);
  • 139 139 // URLs as well.
    140 140 $index_php = str_contains(Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString(), 'index.php');
    141 141
    142 // Clear the stack. The newly created request will become the main one,
    143 // which will be checked in LanguageNegotiationUrl::processOutbound.
    144 \Drupal::requestStack()->pop();
  • Alec Smrekar added 1 commit

    added 1 commit

    • 28eaf0ce - Issue 3420768: Use main request as fallback

    Compare with previous version

  • Alec Smrekar added 1038 commits

    added 1038 commits

    • 28eaf0ce...b3ad3580 - 1032 commits from branch project:11.x
    • b5526481 - Issue 3420768: Unrouted Url assember base_url fix
    • e7b27a21 - Issue 3420768: Fix outbound lang negotiation scheme detection
    • dcbb4bcd - Issue 3420768: Fix incorrect language test
    • e4fd50b4 - Issue 3420768: Fix base url detection in unit tests
    • f878f0ea - Issue 3420768: Replace global usage with request stack
    • a39277b9 - Issue 3420768: Use main request as fallback

    Compare with previous version

  • Please register or sign in to reply
    Loading