Generated with the help of an LLM.
Problem/Motivation
While working on Drupack I ran into a windows issue: ComponentMetadata::$path stays absolute instead of relative to the Drupal root. Anything that builds a path or URL from it gets a drive letter in the middle. I hit it with Tome, which copies a component's assets to ../html/C:/... during a static export.
The constructor strips rtrim($app_root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, so it looks for ...\web\. But the path it gets starts with the root followed by /: ModuleHandler::getModuleDirectories() and ThemeHandler::getThemeDirectories() join with /, and ComponentPluginManager::getScanDirectories() adds \components. The prefix never matches.
Steps to reproduce
On Windows, with 11.4.11 (same as main):
drush php:eval "echo \Drupal::service('plugin.manager.sdc')->find('olivero:teaser')->metadata->path";
It prints C:/Users/me/site/web/core/themes/olivero\components\teaser. On Linux it prints core/themes/olivero/components/teaser.
Proposed resolution
Compare with separators normalized, the way ComponentPluginManager::makePathRelativeToLibraryRoot() already does, and store the relative path with /.
Remaining tasks
A merge request with a unit test that passes a mixed-separator path.
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
Issue fork drupal-3638151
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 #2
nod_Comment #3
nod_Comment #5
nod_Comment #6
smustgrave commentedCould we expand one of the unit tests in ComponentMetadataTest to cover this scenario?
Comment #7
nod_Comment #8
smustgrave commentedOlivero has been removed from core shouldn’t we use something else?