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
trueif the filename exists and is a regular file,falseotherwise.
- https://www.php.net/manual/en/function.is-file.php
Steps to reproduce
- Create the directory
web/sites/example.org - Add
$sites['example.org'] = 'example.org';toweb/sites/sites.php - To test the site path output you can use Drush:
drush --uri=https://example.org php:eval 'echo \Drush\Drush::bootstrapManager()->bootstrap()->confPath(FALSE);' - Instead of the expected output
sites/example.org, you'll getsites/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
Writing a patchTesting the patchUpdatecore/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.phpto test changes- Merging the patch
User interface changes
-
Introduced terminology
-
API changes
-
Data model changes
-
Release notes snippet
-
Issue fork drupal-3571452
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
Comment #4
ishani patel commentedComment #5
ishani patel commentedComment #6
sanderwindComment #8
smustgrave commentedSomething we probably need is a test case showing the problem.
Comment #9
sanderwindAdded some tests. Also for other situations, like missing sites.php and requesting a site path for a missing host.
Comment #10
sanderwindUpdated task list after tests have been added too.
Comment #11
smustgrave commentedLeft some comments on the test file.
Thanks.
Comment #12
sanderwindThanks for checking out my MR, smustgrave. I did add some comments too :-)