Problem/Motivation

When accessing a Drupal 8 site on a nonstandard port in a multisite environment (for instance, http://localhost:8888), DrupalKernel fails to suggest some appropriate aliases from sites.php (in this case, 8888.localhost). As a result, this functionality does not work as documented.

Proposed resolution

Use Symfony\Component\HttpFoundation\Request::getHttpHost() instead of Symfony\Component\HttpFoundation\Request::getHost() when determining the hostname.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dstelljes’s picture

Status: Active » Needs review
FileSize
560 bytes
MegaChriz’s picture

Status: Needs review » Reviewed & tested by the community

Patch still applies and I can confirm that it fixes the issue.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
6.99 KB
7.54 KB

This is a nice find. I decided to investigate if we can add unit test coverage using the virtual file system in PHPUnit/VfsStream and we can.

The test only patch is also the interdiff. The patch renames DrupalKernelTrustedHostsTest to be DrupalKernelTest so it can test more stuff that just the trusted hosts methods.

The last submitted patch, 3: 2410019.3.test-only.patch, failed testing.

dawehner’s picture

  1. +++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
    @@ -0,0 +1,152 @@
    +      $valid_host = $method->invoke(null, $request, $trusted_host_patterns);
    ...
    +      $method->invoke(null, $request, []);
    

    You have written to much yaml

  2. +++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
    @@ -0,0 +1,152 @@
    +      $vfs_root = vfsStream::setup('drupal_root');
    ...
    +      define('DRUPAL_ROOT', $vfs_root->url('drupal_root'));
    

    OOH

alexpott’s picture

@dawehner thanks for the review
#5.1 Not from this patch twas part of DrupalKernelTrustedHostsTest - which I renamed to DrupalKernelTest

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

#5.1 Not from this patch twas part of DrupalKernelTrustedHostsTest - which I renamed to DrupalKernelTest

Okay, fair

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: 2410019.3.patch, failed testing.

alexpott’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
653 bytes
7.54 KB

Rerolled - conflicted with #2494319: Follow up to Spellchecking Drupal - Comments. Setting back to rtbc as per #7.

catch’s picture

Status: Reviewed & tested by the community » Fixed
+++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
@@ -0,0 +1,152 @@
+      // Tests the additional paterns from the settings.

paterns. This was a copy/paste issue (typo already in HEAD), and I fixed it on commit.

Committed/pushed to 8.0.x, thanks!

  • catch committed 8357638 on 8.0.x
    Issue #2410019 by alexpott, dstelljes: DrupalKernel::findSitePath()...

Status: Fixed » Closed (fixed)

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