- Issue created by @poker10
- Status changed to Needs review
over 1 year ago 7:58pm 27 August 2023 - last update
over 1 year ago 30,060 pass - πΈπ°Slovakia poker10
I would say this is caused by β¨ Introduce database driver extensions and autoload database drivers' dependencies Fixed , with the introduction of a new
getModuleInfo()
function.There is a
DIRECTORY_SEPARATOR
used, which is\
on windows, but in theInfoParserDynamic
class there is still/
hardcoded (see/core/
):if (!isset($parsed_info['core_version_requirement'])) { if (str_starts_with($filename, 'core/') || str_starts_with($filename, $this->root . '/core/')) { // Core extensions do not need to specify core compatibility: they are // by definition compatible so a sensible default is used. Core // modules are allowed to provide these for testing purposes. $parsed_info['core_version_requirement'] = \Drupal::VERSION; } }
So the path
D:\htdocs\d10test\core/modules/mysql/mysql.info.yml
does not pass on checkstr_starts_with($filename, $this->root . '/core/')
.Let's try a patch which simply changes the hardcoded slash for
DIRECTORY_SEPARATOR
. - πΈπ°Slovakia poker10
Not sure if we can test this windows-only issue somehow, so will keep this NR for other feedback. Thanks!
Tested the patch also manually and it fixed the error.
- Status changed to Needs work
over 1 year ago 5:22pm 28 August 2023 - πΊπΈUnited States smustgrave
Anyway to get a test case showing the issue added?
@shweta__sharma can I ask what that tag is meant for?
Thanks!
- Status changed to Needs review
over 1 year ago 7:14pm 28 August 2023 - πΈπ°Slovakia poker10
I briefly searched the issue queue for Windows issues from the past, but was unable to figure out if/how to test this windows-only issue in our tests (if it is possible, any help will be appreciated and feel free to re-set the Needs tests tag again). Therefore also upon the discussion with @smustgrave on Slack, I am moving this back to Needs review.
I am also changing the priority to major, as this bug prevents Drupal 10.2.x from being installed on Windows.
- Status changed to RTBC
over 1 year ago 7:26pm 28 August 2023 - πΊπΈUnited States smustgrave
Thanks for digging @poker10. Going to mark then.
- π³π±Netherlands spokje
As a Windows user, I can confirm the problem and the patch solving the problem.
(In fact I came up independently with the exact same one to get core installing and/or running a test. Just wasn't sure it was something that would be eligible for an official patch on here, since Windows only)
- π¬π§United Kingdom catch
+++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -51,7 +51,7 @@ public function parse($filename) { + if (str_starts_with($filename, 'core/') || str_starts_with($filename, $this->root . DIRECTORY_SEPARATOR . 'core/')) {
Possibly silly question - why doesn't the trailing slash also need to use directory separator?
We've got an issue open to drop support for Windows on production, but even if that gets agreed, issues like this would still be valid fwiw.
- πΈπ°Slovakia poker10
Possibly silly question - why doesn't the trailing slash also need to use directory separator?
I would say that this is caused by the fact, that the paths to extensions are build by
ExtensionDiscovery
class. This class hasscanDirectory()
method, which is building the$pathname
for eachExtension
object (this$pathname
is used inInfoParserDynamic::parse()
calls subsequently).And the
scanDirectory()
method is using this code:$absolute_dir = ($dir == '' ? $this->root : $this->root . "/$dir"); // Use Unix paths regardless of platform, skip dot directories, follow // symlinks (to allow extensions to be linked from elsewhere), and return // the RecursiveDirectoryIterator instance to have access to getSubPath(), // since SplFileInfo does not support relative paths. $flags = \FilesystemIterator::UNIX_PATHS; $flags |= \FilesystemIterator::SKIP_DOTS; $flags |= \FilesystemIterator::FOLLOW_SYMLINKS; $flags |= \FilesystemIterator::CURRENT_AS_SELF; $directory_iterator = new \RecursiveDirectoryIterator($absolute_dir, $flags);
See the hardcoded forward slash in
$absolute_dir
. Because of that, you will end up with paths like theseD:\htdocs\d10test/core/modules/action/action.info.yml
from the*SplFileInfo*pathName
.The first part (
D:\htdocs\d10test
) is taken from$this->root
, which is based on\Drupal::root()
, which is computed bydirname()
, which returns a path with backslashes on Windows.The second part (
core/modules/action/action.info.yml
) is taken fromRecursiveDirectoryIterator
, which has forced unix slashes. - πΈπ°Slovakia poker10
And yes, the
ExtensionDiscovery::scanDirectory()
is using only this for$pathname
:$pathname = $dir_prefix . $fileinfo->getSubPathname();
So it will be
core/modules/mysql/mysql.info.yml
.But the new
DatabaseDriver::getModuleInfo()
is adding$this->root
as well:private function getModuleInfo(): void { if (!isset($this->info)) { $infoParser = new InfoParser($this->root); $this->info = $infoParser->parse($this->root . DIRECTORY_SEPARATOR . $this->getModule()->getPathname()); } }
$this->root
isD:\htdocs\d10test
DIRECTORY_SEPARATOR
is\
$this->getModule()->getPathname()
iscore/modules/mysql/mysql.info.yml
(see the previous comment)So it seems to me that this is causing the paths with backwards and forwards slashes.
- last update
over 1 year ago 30,063 pass - last update
over 1 year ago 30,130 pass - last update
over 1 year ago 30,135 pass - last update
over 1 year ago 30,136 pass - last update
over 1 year ago 30,136 pass 49:09 47:58 Running- last update
over 1 year ago 30,146 pass - last update
over 1 year ago 30,150 pass - last update
over 1 year ago 30,154 pass - last update
over 1 year ago 30,161 pass - last update
about 1 year ago 30,156 pass, 2 fail The last submitted patch, 2: 3383616-2.patch, failed testing. View results β
- last update
about 1 year ago 30,168 pass - π³π±Netherlands spokje
Know random test RandomTest failure π Random test fail in Drupal\Tests\Component\Utility\RandomTest::testRandomMachineNamesUniqueness Needs work (and yes, I have been waiting weeks to make that crappy joke), back to RTBC.
- last update
about 1 year ago 30,168 pass - last update
about 1 year ago 30,205 pass - last update
about 1 year ago 30,204 pass, 2 fail The last submitted patch, 2: 3383616-2.patch, failed testing. View results β
- last update
about 1 year ago 30,208 pass - last update
about 1 year ago 30,360 pass - last update
about 1 year ago 30,348 pass, 2 fail The last submitted patch, 2: 3383616-2.patch, failed testing. View results β
- Status changed to Needs work
about 1 year ago 3:21pm 29 September 2023 - π³π±Netherlands spokje
It would be really nice to get this one in, so I don't have to apply it manually every time I want to install core or run a test locally
- Status changed to RTBC
about 1 year ago 3:22pm 29 September 2023 - π¬π§United Kingdom alexpott πͺπΊπ
+++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -51,7 +51,7 @@ public function parse($filename) { - if (str_starts_with($filename, 'core/') || str_starts_with($filename, $this->root . '/core/')) { + if (str_starts_with($filename, 'core/') || str_starts_with($filename, $this->root . DIRECTORY_SEPARATOR . 'core/')) {
The mix of hard coded / and DIRECTORY_SEPARATOR feels really icky here. Really hard to explain. Like If we changed it to
str_starts_with($filename, $this->root . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR
it would break again on windows.I wonder if instead we should be changing
\Drupal\Core\Extension\DatabaseDriver::getModuleInfo()
instead to do:if (!isset($this->info)) { $infoParser = new InfoParser($this->root); $this->info = $infoParser->parse($this->getModule()->getPathname()); }
As that would be inline with other calls to \Drupal\Core\Extension\InfoParserDynamic::parse() for extension listing services.
I wonder why $filename is sometimes an absolute path.
I think it'd be good to see if we could somehow make this look a bit better.
- Status changed to Fixed
about 1 year ago 12:56am 30 September 2023 - πΊπΈUnited States xjm
I had exactly the same question as #10, and @poker10 explained the reasoning quite well. Adding credit for @catch for posing a helpful question, and @Spokje for jokes. (It's actually for the manual testing, but let's pretend it's the joke.)
Committed to 11.x, and cherry-picked to 10.1.x as a patch-eligible, major-borderline-critical bugfix.
Thanks everyone!
- π¬π§United Kingdom alexpott πͺπΊπ
I think this change might cause more problems though. Because maybe some other custom code that is running on windows as worked around the code as it is Drupal 10.0.x. And now it fails. And the mixture of slashes here is likely to cause more bugs in the future. I think the real issue here is that we should have fixed the new code in
\Drupal\Core\Extension\DatabaseDriver::getModuleInfo()
as per #20. I thought I'd set this one to needs work. The only reason we accept a full path in parse() is for testing. Which I might have introduced and now regret. - Status changed to Needs review
about 1 year ago 11:33am 2 October 2023 - last update
about 1 year ago 30,328 pass, 1 fail - π¬π§United Kingdom alexpott πͺπΊπ
I think we should revert this from 10.1.x and commit the following patch to 11.x for the quick fix. And then open a follow-up to discuss how we should improve \Drupal\Core\Extension\InfoParserDynamic::parse() so that the paths are more filesystem agnostic.
- π¬π§United Kingdom alexpott πͺπΊπ
As an example of stuff that would pass on Windows before this change but now will not see
core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
where we do
$file_name = DRUPAL_ROOT . '/core/modules/system/tests/themes/' . $name . '/' . $name . '.info.yml';
- π¬π§United Kingdom catch
If #25 works that looks fine as a quick fix. Definitely we should try to minimise the mix of slashes, it's very confusing just reading it, let alone trying to figure out what the practical effects might be.
The last submitted patch, 25: 3383616-25.patch, failed testing. View results β
- last update
about 1 year ago 30,316 pass, 3 fail - last update
about 1 year ago 30,361 pass - π¬π§United Kingdom alexpott πͺπΊπ
So #25 is failing because PHPUnit tests don't set the working directory to Drupal root but extension discovery including now database driver discovery assumes that you are in Drupal root. There are other unit tests that set the working directory for this reason so UrlConversionTest can do the same. I think we might consider throwing an exception in \Drupal\Core\Extension\DatabaseDriver::getModuleInfo() if
$this->info
is an empty array as that means an info file does not exist which is not really valid. - πΊπΈUnited States xjm
+++ b/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php @@ -27,6 +27,8 @@ class UrlConversionTest extends UnitTestCase { + // This unit relies on reading files relative to Drupal root.
This unit test maybe? Otherwise it sounds like a robot's version of first person.
Is #29 intended for both 11.x and 10.1.x? (And wouldn't it have been better to just revert it first anyway?)
- last update
about 1 year ago 30,362 pass - πΈπ°Slovakia poker10
Thanks all for your effort with this issue! I have tested the patch #29 and it seems to work on Windows as the patch #2. Given the severity of this (unable to install or update 11.x branch on Windows), I think that it would be good to have one of these quick fixes committed (#2 or this new approach). @alexpott raised some concerns about the patch #2 in #24 π "core_version_requirement key must be present" on core modules on Windows Needs review , so in that case it would probably be safer to commit the later one.
Is #29 intended for both 11.x and 10.1.x? (And wouldn't it have been better to just revert it first anyway?)
The issue which caused this was committed to 11.x branch only: β¨ Introduce database driver extensions and autoload database drivers' dependencies Fixed , so I think it should be sufficient to commit the fix to the 11.x. And the cleanest way probably will be to revert both commits and commit the patch I am uploading now - it is the same as #29, but without the code being reverted (as it will be reverted separately).
This unit test maybe? Otherwise it sounds like a robot's version of first person.
I have also updated this comment in the uploaded patch.
I think we might consider throwing an exception in \Drupal\Core\Extension\DatabaseDriver::getModuleInfo() if $this->info is an empty array as that means an info file does not exist which is not really valid.
@alexpott Do you mean here, or in the follow-up?
Thanks!
- π¬π§United Kingdom alexpott πͺπΊπ
-
alexpott β
committed 45a9f14a on 10.1.x
Revert "Issue #3383616 by poker10, Spokje, catch: "...
-
alexpott β
committed 45a9f14a on 10.1.x
-
alexpott β
committed b438bb0d on 11.x
Revert "Issue #3383616 by poker10, Spokje, catch: "...
-
alexpott β
committed b438bb0d on 11.x
- Status changed to RTBC
about 1 year ago 2:36pm 3 October 2023 - Status changed to Fixed
about 1 year ago 2:39pm 3 October 2023 - πΊπΈUnited States xjm
I think this still needs that followup filed?
- π¬π§United Kingdom alexpott πͺπΊπ
Created π InfoParser returns an empty array if passed a non-existing file Fixed and π InfoParserDynamic::parse() looks for strings in a file path without normalising Active as followups.
Automatically closed - issue fixed for 2 weeks with no activity.