Problem/Motivation

Currently, the system clears CSS cache every time a theme is installed/enabled(refer: #2109287: Replace list_themes() with a service.).
Since the CSS cache is not theme-specific, so clearing it on every theme installation provides no benefit and may impact performance.

Steps to reproduce

  • Install or enable a theme
  • Observe that CSS cache is cleared via $this->cssCollectionOptimizer->deleteAll()

Proposed resolution

Remove the unnecessary CSS cache clearing from the theme installer by deleting the line:
$this->cssCollectionOptimizer->deleteAll();

Remaining tasks

  • Remove the code from installer and raise a MR.
  • Review the MR and merge.

User interface changes

N/A.

Introduced terminology

N/A.

API changes

N/A.

Data model changes

N/A.

Release notes snippet

Removed unnecessary CSS cache clearing during theme installation.

CommentFileSizeAuthor
#1 2149631-1.patch588 bytesstar-szr

Issue fork drupal-2149631

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

star-szr’s picture

Title: Don't clear the CSS cache when enabling themes » Don't clear the CSS cache when installing themes
Status: Active » Needs review
StatusFileSize
new588 bytes

Tiny patch to see if anything blows up. Manual testing seems to check out.

brianperry’s picture

Spent some time looking at this - the one concern that I had is that while clearing the cache would be unnecessary for install in most cases, it seems like it would have some value when a theme is being installed and set default at the same time. That said, it might make the most sense for that to be happening in setDefaulTheme() but I couldn't really prove that it was happening there either.

It also looks like this patch would need to be re-rolled as the cache clear that we're trying to remove has moved into ThemeInstaller.php

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lauriii’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

It would be nice to see some test coverage for this.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

catch’s picture

Status: Postponed (maintainer needs more info) » Needs work
Issue tags: -Needs tests +Novice
    $this->cssCollectionOptimizer->deleteAll();

This is still in the theme installer.

Needs the patch converted to an MR, or just a fresh MR created removing that line. Not sure we need tests for this, we'd just be testing that we removed the code really - e.g. we'd need to get some CSS aggregates created on disk, install a theme, make sure they're still there. But also with #3505776: Retain asset aggregates for 45 days by default to reduce generation of identical files new aggregates wouldn't get deleted anyway, making this impossible to test. Given that, removing the needs tests tag.

neerajsingh made their first commit to this issue’s fork.

neerajsingh’s picture

I will convert the patch to MR.

smustgrave’s picture

Just an FYI newly tagged novice tickets are typically meant for newer users to try, that have less then 1 page of posts.

After a few weeks if no new user doesn't pick it up it's fair game.

neerajsingh’s picture

Status: Needs work » Needs review

Thank you, for highlighting this @smustgrave.

smustgrave’s picture

Status: Needs review » Needs work

No worries!

For good practice lets update the summary to use the standard template

neerajsingh’s picture

Issue summary: View changes

Updated issue summary.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

slawrence10 made their first commit to this issue’s fork.

slawrence10’s picture

Status: Needs work » Needs review

I have rebased the MR. Needs review.

slawrence10’s picture

Status: Needs review » Needs work

Test failing from removing the line.

May indicate cache clear is needed after all?

catch’s picture

Status: Needs work » Reviewed & tested by the community

Pretty sure that's a random test failure. This looks good to me, there's absolutely no reason to clear this cache. Apart from the CSS aggregates being unnecessarily cleared, it also adds overhead to the process of installing a theme.

slawrence10’s picture

OK thank you @catch. New to contributing, so I'm still learning the process.

smustgrave’s picture

There’s a major bug in gitlab not allowing test reruns but when that’s fixed JavaScript ones have the most random and and can be reran

alexpott’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed d759d555ab4 to main and 53c4b27ed67 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 53c4b27e on 11.x
    perf: #2149631 Don't clear the CSS cache when installing themes
    
    By:...

  • alexpott committed d759d555 on main
    perf: #2149631 Don't clear the CSS cache when installing themes
    
    By:...

Status: Fixed » Closed (fixed)

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