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

  1. 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.
  2. editor.libraries.yml still references editor.css which has been removed via commit b8a6e72.

Proposed resolution

  1. 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.
  2. 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

CommentFileSizeAuthor
#46 interdiff.txt1.01 KBstar-szr
#46 removed_css_files_not-2580049-46.patch7.31 KBstar-szr
#41 interdiff.txt941 bytesstar-szr
#41 removed_css_files_not-2580049-41.patch7.31 KBstar-szr
#39 interdiff.txt1.37 KBstar-szr
#39 removed_css_files_not-2580049-39.patch7.49 KBstar-szr
#32 interdiff.txt744 bytesstar-szr
#32 removed_css_files_not-2580049-32.patch7.38 KBstar-szr
#31 interdiff.txt1.86 KBstar-szr
#31 removed_css_files_not-2580049-31.patch7.4 KBstar-szr
#22 interdiff.txt6.16 KBstar-szr
#22 removed_css_files_not-2580049-22.patch7.13 KBstar-szr
#22 removed_css_files_not-2580049-22-testonly.patch6.02 KBstar-szr
#18 interdiff.txt1.3 KBstar-szr
#18 removed_css_files_not-2580049-18.patch4.44 KBstar-szr
#17 interdiff.txt737 bytesstar-szr
#17 removed_css_files_not-2580049-17.patch4.48 KBstar-szr
#16 removed_css_files_not-2580049-16.patch4.5 KBstar-szr
#16 removed_css_files_not-2580049-16-testonly.patch3.38 KBstar-szr
#9 interdiff.txt408 bytesstar-szr
#9 removed_css_files_not-2587563-9.patch1.11 KBstar-szr
#7 files.png141.97 KBManjit.Singh
#6 interdiff.txt363 bytesstar-szr
#6 file_libraries_yml-2580049-6.patch732 bytesstar-szr
#5 file_libraries_yml-2580049-5.patch732 bytesstar-szr
#2 file_libraries_yml-2580049-2.patch1.3 KBstar-szr
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Cottser created an issue. See original summary.

star-szr’s picture

Status: Active » Needs review
Issue tags: +Needs manual testing
FileSize
1.3 KB

Status: Needs review » Needs work

The last submitted patch, 2: file_libraries_yml-2580049-2.patch, failed testing.

Status: Needs work » Needs review
star-szr’s picture

star-szr’s picture

Specifying the right extension helps though.

Manjit.Singh’s picture

FileSize
141.97 KB

CSS for files are called from classy as it was happening previously. I have not found any visual regression. Please check after screenshots.

After

files

LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs manual testing
Parent issue: #2566771: [Voltron patch] Move all remaining *.theme.css to Classy »

Good stuff, thanks for the screenshots.

star-szr’s picture

Title: file.libraries.yml still references file.theme.css which has been moved to Classy » Removed CSS files not removed from library definitions
Component: file.module » other
Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
Issue tags: +frontend
Related issues: +#2485425: Clean up editor CSS inline with our CSS standards, +#2566771: [Voltron patch] Move all remaining *.theme.css to Classy
FileSize
1.11 KB
408 bytes

Combining forces with the editor.css removal follow-up. The editor.css one just needs vetting, no screenshots or anything.

star-szr’s picture

Priority: Normal » Major
Issue tags: +rc target triage
NickDickinsonWilde’s picture

Status: Needs review » Reviewed & tested by the community

Had 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.

star-szr’s picture

Thank 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 :)

star-szr’s picture

Issue tags: +blocker
NickDickinsonWilde’s picture

no 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 :)

star-szr’s picture

Issue summary: View changes
star-szr’s picture

Here'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.

star-szr’s picture

star-szr’s picture

The last submitted patch, 16: removed_css_files_not-2580049-16-testonly.patch, failed testing.

NickDickinsonWilde’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me

The last submitted patch, 16: removed_css_files_not-2580049-16-testonly.patch, failed testing.

star-szr’s picture

Thanks @NickWilde I was thinking we should probably test all the theme assets as well so this incorporates themes into the test as well.

The last submitted patch, 22: removed_css_files_not-2580049-22-testonly.patch, failed testing.

NickDickinsonWilde’s picture

yeah 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?

star-szr’s picture

@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?

NickDickinsonWilde’s picture

Status: Needs review » Reviewed & tested by the community

Makes 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)

The last submitted patch, 16: removed_css_files_not-2580049-16-testonly.patch, failed testing.

The last submitted patch, 22: removed_css_files_not-2580049-22-testonly.patch, failed testing.

Wim Leers’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/system/src/Tests/Asset/LibraryCompletenessTest.php
    @@ -0,0 +1,193 @@
    +/**
    + * Tests that the files for all core libraries actually exist.
    + *
    + * @group Asset
    + */
    +class LibraryCompletenessTest extends KernelTestBase {
    

    <3

  2. +++ b/core/modules/system/src/Tests/Asset/LibraryCompletenessTest.php
    @@ -0,0 +1,193 @@
    +      // Filter contrib, hidden, already enabled modules and modules in the
    +      // Testing package.
    +      if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
    

    <3

  3. +++ b/core/modules/system/src/Tests/Asset/LibraryCompletenessTest.php
    @@ -0,0 +1,193 @@
    +    // overkill but themes can override and extend other extension's libraries
    

    Nit: s/extension's/extensions'/

  4. +++ b/core/modules/system/src/Tests/Asset/LibraryCompletenessTest.php
    @@ -0,0 +1,193 @@
    +      $this->libraryDiscovery->clearCachedDefinitions();
    

    This should not be necessary. It's only necessary when modifying libraries, i.e. when changing some YML files.

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community

This should not be necessary. It's only necessary when modifying libraries, i.e. when changing some YML files.

I 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. So LibraryDiscovery 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.

star-szr’s picture

Fixing nit and renaming test and adding a bit more description based on IRC discussion. Thanks a ton @Wim Leers!

star-szr’s picture

Sorry, looking at it again "defined library files" makes me think of *.libraries.yml files. Minor tweak to docs.

The last submitted patch, 16: removed_css_files_not-2580049-16-testonly.patch, failed testing.

The last submitted patch, 22: removed_css_files_not-2580049-22-testonly.patch, failed testing.

Wim Leers’s picture

RTBC++

star-szr’s picture

Just 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 :)

alexpott’s picture

Issue tags: -rc target triage +rc target

Discussed 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 :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
    @@ -0,0 +1,197 @@
    +        $libraries_to_skip = [
    +          // Locale has a "dummy" library that does not actually exist.
    +          'locale/translations',
    +        ];
    

    Does not need to be set in the for each - how about making it a class property.

  2. +++ b/core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
    @@ -0,0 +1,197 @@
    +    $modules = \Drupal::moduleHandler()->getModuleList();
    +    $extensions = $modules;
    +    $module_list = array_keys($modules);
    +    sort($module_list);
    +    $this->assertEqual($this->allModules, $module_list, 'All core modules are installed.');
    +
    +    $themes = $this->themeHandler->listInfo();
    +    $extensions += $themes;
    +    $theme_list = array_keys($themes);
    +    sort($theme_list);
    +    sort($this->allThemes);
    +    $this->assertEqual($this->allThemes, $theme_list, 'All core themes are installed.');
    

    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.

  3. +++ b/core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
    @@ -0,0 +1,197 @@
    +    // By merging $modules and $themes into $extensions we're assuming that a
    +    // module and theme don't share names. If they did, their libraries would
    +    // conflict anyway.
    

    This has always been impossible.

star-szr’s picture

Status: Needs work » Needs review
FileSize
7.49 KB
1.37 KB

Thanks @alexpott!

Fixed 1.

+++ b/core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
@@ -0,0 +1,197 @@
+  protected $allThemes = [
+    'bartik',
+    'classy',
+    'seven',
+    'stable',
+    'stark',
+  ];
...
+    // Enable all core modules.
+    $all_modules = system_rebuild_module_data();
+    $all_modules = array_filter($all_modules, function ($module) {
+      // Filter contrib, hidden, already enabled modules and modules in the
+      // Testing package.
+      if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
+        return FALSE;
+      }
+      return TRUE;
+    });

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:

name: Bartik
type: module
description: Bartik module
core: 8.x

modules/bartik.libraries.yml:

global-styling:
  css: []

Creating those files and enabling the Bartik module breaks the Bartik theme pretty good :(

alexpott’s picture

Status: Needs review » Needs work

Followup 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.

star-szr’s picture

Status: Needs work » Needs review
FileSize
7.31 KB
941 bytes

Thanks, 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.

alexpott’s picture

@Cottser - er point 2. yep you're right - carry on :)

joelpittet’s picture

Component: other » asset library system
Status: Needs review » Reviewed & tested by the community

The test is nice (maybe needs a followup to get a list of themes instead of hardcoding)

+++ b/core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
@@ -0,0 +1,200 @@
+    sort($this->allModules);
...
+    sort($this->allThemes);

Nit pick: Might as well move the theme sort to the setup too.

The last submitted patch, 16: removed_css_files_not-2580049-16-testonly.patch, failed testing.

The last submitted patch, 22: removed_css_files_not-2580049-22-testonly.patch, failed testing.

star-szr’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed a1678a2 and pushed to 8.0.x. Thanks!

  • alexpott committed a1678a2 on 8.0.x
    Issue #2580049 by Cottser, Manjit.Singh, NickWilde, alexpott, Wim Leers...
Wim Leers’s picture

Yay, no more 404s!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.