Asset injector files are deleted on every cache rebuild

Created on 29 August 2019, over 5 years ago
Updated 5 October 2024, 3 months ago

Problem/Motivation

The asset_injector directory in the public files in emptied on every cache rebuild in hook_cache_flush().

/**
 * Implements hook_cache_flush().
 *
 * Delete all asset files.
 */
function asset_injector_cache_flush() {
  AssetFileStorage::deleteAllFiles();
}

This leads to a state where (when the cache is rebuilt with drush) the files can take on the user ownership of the user who rebuilt the cache. This will cause issues when a user attempts to rebuild the cache with the UI.

Proposed resolution

Do not empty the asset_injector directory on every cache rebuild. Instead use an EventListener for ConfigEvents::SAVE and then update the necessary files. This was suggested in #4 in the issue this hook was introduced, see #2869562-4: Deployment does not change asset files

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇳🇱Netherlands idebr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin

    Does this have been merged into the latest release? It seems that this issue still persist. It causes on backup and restore for local stage that tht css styles are listed in config UI but not loaded on page load.

Production build 0.71.5 2024