Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove leading slash from pattern theme paths #327

Open
wants to merge 3 commits into
base: 8.x-1.x
Choose a base branch
from

Conversation

omarlopesino
Copy link

Since twig 2.14.5 this is not supported. More info: https://github.com/twigphp/Twig/blob/v2.14.5/CHANGELOG

@donquixote
Copy link

donquixote commented May 21, 2021

Nice!
Btw the PR title is somewhat misleading. Currently the paths are not "absolute", they are just wrong and broken :)

@omarlopesino omarlopesino changed the title Make pattern theme paths relative instead of absolute. Remove leading slash from pattern theme paths May 21, 2021
@dxvargas
Copy link

dxvargas commented Dec 1, 2021

There is a problem that is happening after this change.

We can define a library in a module or theme to be used in a pattern. See here the example pattern_library_one and pattern_library_two.
When doing this, if we remove the leading slash $base_path, there is a problem later in \Drupal\Core\Asset\LibraryDiscoveryParser::buildByExtension() in the section "// Determine the file asset URI.".
After removing the leading slash, we end up having $options['data'] = $path . '/' . $source;. This is not correct, since $path is pointing to the path of ui_patterns module (it shouldn't, because this is a library defined in a custom module or theme) and also the source was already complete, so we end up having a broken path.

I give here an example where we have now a regression:
https://github.com/openeuropa/oe_bootstrap_theme/blob/1.0.0-alpha3/templates/patterns/tooltip/tooltip.ui_patterns.yml#L57
For this case, $options['data'] will get the value modules/contrib/ui_patterns/themes/contrib/oe_bootstrap_theme/templates/patterns/tooltip/tooltip.js which of course will result in an error after visiting patterns page:

Warning: file_get_contents(modules/contrib/ui_patterns/themes/custom/oe_bootstrap_theme/templates/patterns/tooltip/tooltip.js): failed to open stream: No such file or directory in Drupal\Core\Asset\JsOptimizer->optimize() (line 25 of core/lib/Drupal/Core/Asset/JsOptimizer.php).

Before, with the leading slash, this was working, buildByExtension was processing correctly the path and source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants