-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Allow underscore in extended static files in theme #32620
Allow underscore in extended static files in theme #32620
Conversation
Should we allow such case ? Can you add more describe how impact to user with this case scenario ? |
Magento already allows this. It is possible to create a module with an underscore in the name (I have several as a way to provide a basic sub-module system). The only issue is with static theme file collecting, the regex here forbids it. There have been other PRs accepted in the past for this issue in other areas (11765 & 14397) and both were quickly accepted. Magento already allows this and PSR-4 allows this (which Magento claims to support). By user, I meant more developer but the impact is that if a module is installed with an underscore in the module name that has a static file (I tested with view/frontend/web/css/source/_module.less) then this file cannot be extended in a custom theme due to the regex listed in the issue and PR I created for this issue. This is a single character code change that brings the static theme file collecting inline with everywhere else in Magento. |
Thanks you for clarify! Can you cover this change with some automation tests Also update Manual testing scenarios in description section for QA team can reproduce for test |
I have updated the original post with a better manual testing section. I'm not sure how to cover this in unit testing, sorry! |
…amework\App\Utility\Files::accumulateThemeStaticFiles.
@magento run all tests |
@magento run Static Tests, Integration Tests |
Added required Magento copyright text to less file
@magento run Static Tests, Integration Tests |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests B2B |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run WebAPI Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Hi @ihor-sviziev, thank you for the review. |
✔️ QA passed |
Hi @bentideswell, thank you for your contribution! |
Hi just wonder is this issue can happen if theme name with 2 underscores ? |
Theme's aren't part of this issue, as far as I can tell, as the issue relates to PSR-4 autoloading of classes. With a theme name, there is no autoloading tied to the name of the theme as the theme doesn't create it's own PHP classes. There may be some overlap though, especially in some of the regular expressions that are used to collect files that disallowed underscores. As this issue affected modules I created, I only debugged it from that perspective. If you have issues with a theme with underscores, you will need to:
All of this being said, I had no choice but to push to have the issue resolved as it affected modules my business had already sold and people were using. If it's a custom theme you're building, it might be easier to just change the name to something that works (if the underscore truly is your issue) and move on. I don't know enough about your situation but when I went through this, if it was possible for me to just remove the underscores without affecting many live sites, I would have definitely considered it! |
This PR fixes this issue.
Description
Adds the underscore character to the regex to allow for underscore in module name when extending static file in theme. This is inline with PSR-4 and also inline with other areas of Magento (see related pull requests).
Manual Testing
Extend a file in your custom theme (original doesn't need to exist):
app/design/frontend/YourVendor/YourTheme/Module_Third_Party/web/css/source/_module.less
Compile the static assets:
bin/magento setup:static-content:deploy -f
You will now get the error:
Error happened during deploy process: Could not parse theme static file '/path/to/your/install/app/design/frontend/YourVendor/YourTheme/Module_Third_Party/web/css/source/_module.less'
If you then make the single character change in this PR and recompile, it will compile successfully.
Related Pull Requests
11765
14397
Fixed Issues
#32619