Problem/Motivation

Following up on Try to use is_file() instead of file_exists() in DrupalKernel::findSitePath():

The check for finding a site path in a multisite construction, without the requirement for the existence of settings.php, is broken since #1333940 has been merged.

Change on Gitlab: https://git.drupalcode.org/project/drupal/-/commit/b310d19833c0de5dcd487...

Where file_exists($directory) returns TRUE when a directory exists, is_file($directory) does not. It returns FALSE when the given path is not a file.

Returns true if the filename exists and is a regular file, false otherwise.
- https://www.php.net/manual/en/function.is-file.php

Steps to reproduce

  1. Create the directory web/sites/example.org
  2. Add $sites['example.org'] = 'example.org'; to web/sites/sites.php
  3. To test the site path output you can use Drush: drush --uri=https://example.org php:eval 'echo \Drush\Drush::bootstrapManager()->bootstrap()->confPath(FALSE);'
  4. Instead of the expected output sites/example.org, you'll get sites/default

Proposed resolution

The check (!$require_settings && is_file($app_root . '/sites/' . $site_id)) needs to be replaced with (!$require_settings && is_dir($app_root . '/sites/' . $site_id)).

Remaining tasks

  1. Writing a patch
  2. Testing the patch
  3. Update core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php to test changes
  4. Merging the patch

User interface changes

-

Introduced terminology

-

API changes

-

Data model changes

-

Release notes snippet

-

Issue fork drupal-3571452

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:

Comments

sanderwind created an issue. See original summary.

ishani patel changed the visibility of the branch 3571452-drupalkernel-findsitepath-incorrect-check to hidden.

ishani patel’s picture

Assigned: Unassigned » ishani patel
ishani patel’s picture

Assigned: ishani patel » Unassigned
sanderwind’s picture

Status: Active » Needs review

sanderwind changed the visibility of the branch 3571452-drupalkernel-findsitepath-incorrect-check to active.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Something we probably need is a test case showing the problem.

sanderwind’s picture

Added some tests. Also for other situations, like missing sites.php and requesting a site path for a missing host.

sanderwind’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests

Updated task list after tests have been added too.

smustgrave’s picture

Status: Needs review » Needs work

Left some comments on the test file.

Thanks.

sanderwind’s picture

Thanks for checking out my MR, smustgrave. I did add some comments too :-)