Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Commit credit: Please ensure Manjit.Singh, NickWilde are credited
Followup to #2566771: [Voltron patch] Move all remaining *.theme.css to Classy and #2485425: Clean up editor CSS inline with our CSS standards
Problem/Motivation
- file.libraries.yml still references file.theme.css which has been moved to Classy. If you look at your console you can see a 404 when visiting /node/add/article and other pages.
- editor.libraries.yml still references editor.css which has been removed via commit b8a6e72.
Proposed resolution
- Remove the definition from file.libraries.yml and in Classy add the Classy file library to the file module's CSS assets. \Drupal\file\Plugin\Field\FieldType\FileItem::storageSettingsForm() attaches the library in addition to the Twig templates in Classy that currently attach the Classy file library.
- Remove the definition from editor.libraries.yml pointing to editor.css.
Remaining tasks
Review
Manual testing completed in #7
User interface changes
Just fixes if any.
API changes
n/a
Data model changes
n/a
Comment | File | Size | Author |
---|---|---|---|
#46 | interdiff.txt | 1.01 KB | star-szr |
#46 | removed_css_files_not-2580049-46.patch | 7.31 KB | star-szr |
#41 | interdiff.txt | 941 bytes | star-szr |
#41 | removed_css_files_not-2580049-41.patch | 7.31 KB | star-szr |
#39 | interdiff.txt | 1.37 KB | star-szr |
Comments
Comment #2
star-szrComment #5
star-szrYay #2497667: Add libraries-extend to themes' *.info.yml! Now leveraging libraries-extend, no interdiff because classy.theme is gone c/o #2580255: Remove (classy|seven)_library_info_alter() in favor of libraries-extend :)
Comment #6
star-szrSpecifying the right extension helps though.
Comment #7
Manjit.SinghCSS for files are called from classy as it was happening previously. I have not found any visual regression. Please check after screenshots.
After
Comment #8
LewisNymanGood stuff, thanks for the screenshots.
Comment #9
star-szrCombining forces with the editor.css removal follow-up. The editor.css one just needs vetting, no screenshots or anything.
Comment #10
star-szrBumping to major, this blocks #2575737: Copy templates, CSS, and related assets to Stable and override core libraries' CSS.
Comment #11
NickDickinsonWildeHad the same code in a couple other issues (#2586335: CSS file defined in file library but doesn't exist and #2586381: Incorrectly referenced editor.css in editor.libraries.yml) so I had already tested (almost) all this code. Works fine.
Comment #12
star-szrThank you and sorry @NickWilde! I didn't see the editor followup, next time you do that I'd recommend commenting to the issue you are following up on with a link to the followup issue, makes it much easier to find and follow.
Committers - please also credit @NickWilde :)
Comment #13
star-szrComment #14
NickDickinsonWildeno apologies necessary, as long as it gets fixed I'm happy.
ah yes that would have been a good idea - I added the relationship the other direction which adds it to the child issues data but not as a post and hence is not any where near as noticeable (and might have meant you wouldn't have done extra work). thanks for the suggestion :)
Comment #15
star-szrComment #16
star-szrHere's a test to try to ensure this can't happen in the future. Largely copied from the work I did on #2575737: Copy templates, CSS, and related assets to Stable and override core libraries' CSS.
Test only patch == interdiff.
Comment #17
star-szrAnd it shows ;) some cleanup.
Comment #18
star-szrFew more tweaks.
Comment #20
NickDickinsonWildeLooks good to me
Comment #22
star-szrThanks @NickWilde I was thinking we should probably test all the theme assets as well so this incorporates themes into the test as well.
Comment #24
NickDickinsonWildeyeah that makes sense. Well hmm one question; Maybe it is normal but is there a reason to filter out contrib modules/themes? It seems to me it would be better to have the test run on them as well?
Comment #25
star-szr@NickWilde I think it's core's responsibility to test core. What I would maybe suggest is that in a followup we could try to refactor some of this code into a base class or trait to make it more reusable (extendable) by contrib for testing its libraries. What do you think?
Comment #26
NickDickinsonWildeMakes sense to me and much less important than getting the actual problems fixed.
(and I feel like I might beshooting my mouth off and saying bigger things than I really should for my up Drupal hierarchy position... as in none - so feel free to ignore if I say anything out of turn)
Comment #29
Wim Leers<3
<3
Nit: s/extension's/extensions'/
This should not be necessary. It's only necessary when modifying libraries, i.e. when changing some YML files.
Comment #30
Wim LeersI said this because I interpreted this as "libraries-extend and libraries-override are cached once, and whenever we change the theme, we need to clear all caches", which would be wrong.
But my interpretation was wrong. What is actually happening is that
LibraryDiscovery
(library.discovery
) is designed to be used within one request (service lifetime always matches request lifetime). Within a single request, you can't have multiple themes be active. SoLibraryDiscovery
caches thing statically (i.e. request lifetime). Which is correct. However, in this test, we basically simulate multiple requests. So we need to clear the static caches. Which is exactly what this does.Sorry for the distraction!
That leaves only point 3 as a nitpick, which can be fixed on commit.
Comment #31
star-szrFixing nit and renaming test and adding a bit more description based on IRC discussion. Thanks a ton @Wim Leers!
Comment #32
star-szrSorry, looking at it again "defined library files" makes me think of *.libraries.yml files. Minor tweak to docs.
Comment #35
Wim LeersRTBC++
Comment #36
star-szrJust for the record I didn't invent #29.2, that was copied verbatim from some other tests, an amalgamation of code from \Drupal\config\Tests\ConfigImportAllTest and \Drupal\field\Tests\FieldDefinitionIntegrityTest :)
Comment #37
alexpottDiscussed with @effulgentsia - we agreed this is an RC target cause D8 should not be produce 404s whilst loading library assets out of the box.
@Cottser nice looking test :)
Comment #38
alexpottDoes not need to be set in the for each - how about making it a class property.
These tests mean that this test will break if someone has a contrib module lying around. That doens't seem ideal. I think we should assert that the libraries array is not empty. And that should be okay.
This has always been impossible.
Comment #39
star-szrThanks @alexpott!
Fixed 1.
Regarding point 2 the above seems to cover that (only enable/install core modules and themes) but I might be missing something. Happy to change the assertion if we think it's fragile.
Regarding point 3 impossible in what sense? I'm not saying core would do this but it is possible, isn't it? Or put differently what would you suggest to change with that comment or are you just suggesting it be removed?
modules/bartik.info.yml:
modules/bartik.libraries.yml:
Creating those files and enabling the Bartik module breaks the Bartik theme pretty good :(
Comment #40
alexpottFollowup on my points
2. Yes but you are asserting against the output of
$this->themeHandler->listInfo();
and\Drupal::moduleHandler()->getModuleList();
which can include more that core - no? In fact I'm not sure why test modules are not already breaking that assertion.3. What I meant by impossible is that Drupal has never supported modules and themes having the same name. I don;t think that needs documenting here.
Comment #41
star-szrThanks, I removed the comment from point 3.
For point 2:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...
Both methods document returning a list of currently active/installed extensions so I think the results of those calls should only contain respectively the hardcoded list of themes and the reduced list of modules (core, non-testing modules). When I've been testing I've certainly had plenty of contrib/custom modules and themes lying around.
Comment #42
alexpott@Cottser - er point 2. yep you're right - carry on :)
Comment #43
joelpittetThe test is nice (maybe needs a followup to get a list of themes instead of hardcoding)
Nit pick: Might as well move the theme sort to the setup too.
Comment #46
star-szrThanks!
Nit fixed.
Comment #47
alexpottCommitted a1678a2 and pushed to 8.0.x. Thanks!
Comment #49
Wim LeersYay, no more 404s!