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

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

nod_ created an issue. See original summary.

nod_’s picture

nod_’s picture

nod_’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Could we expand one of the unit tests in ComponentMetadataTest to cover this scenario?

nod_’s picture

Status: Needs work » Needs review
smustgrave’s picture

Olivero has been removed from core shouldn’t we use something else?