I'm doing some theming with a color module-enabled theme for the first time, and I'm finding one particular aspect of it very tedious. The color module rewrites a theme's stylesheets, and saves a cached version of the rewrites whenever the theme settings form is saved. So, every time you make a change to your theme's CSS, you have to go to 'admin/build/themes/settings/themename', and click 'save configuration' in order to refresh your rewritten stylesheet cache.

This is a major pain. It got particularly bad when I was theming the user login block, and I had to log in as admin, go to the theme settings page, submit the form, then log out again in order to see each CSS change that I made. I decided that there had to be a Better Way™.

This patch adds a new color_flush_css_cache() function, which submits the theme settings form programatically (if the current default theme is color-module-enabled). This function is called by drupal_flush_all_caches() if color.module is enabled.

The "right way" to do this would probably be to majorly clean up the color module, so that it's possible to do this without needing a drupal_execute() call. But judging by the way color.module currently works, this would be a bigger task. Anyway, submitting the form programatically works for me - so if we'd rather wait for a cleaner patch until this gets committed, people can at least apply this patch right now if they need it.

I originally wrote this code in drush's 'cache clear' function, but then I decided that it really belongs in the core cache clearing system. This is sorely needed for anyone doing theme development with the color module. I also wrote this patch originally for D6 stable - you can use it on latest D6 no problems, it applies with offsets. But I assume that this qualifies as enough of a 'new feature' to be ineligible for getting in as a D6 bugfix.

CommentFileSizeAuthor
color-cache-flush-head.patch1.81 KBJaza
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mr.baileys’s picture

Status: Needs review » Needs work

drupal_execute has been renamed to drupal_form_submit in D7. Personally however, I don't think programmatically submitting the theme settings form is the right approach here...

2noame’s picture

The color module rewrites a theme's stylesheets, and saves a cached version of the rewrites whenever the theme settings form is saved. So, every time you make a change to your theme's CSS, you have to go to 'admin/build/themes/settings/themename', and click 'save configuration' in order to refresh your rewritten stylesheet cache.

Thank you so much for posting this. It's a little thing and probably obvious to many, but I couldn't figure it the hell out myself.

Jody Lynn’s picture

Title: Color module stylesheet flush on cache clear » Programatically rewrite the color module files
Version: 7.x-dev » 8.x-dev
Assigned: Jaza » Unassigned

function color_scheme_form_submit needs to call a new API function to do the real work. I don't see it as related to caching in any way though.

Once we have it moved into a proper function a patch for calling it from drush would be great.

markhalliwell’s picture

Status: Needs work » Closed (duplicate)
pwaterz’s picture

@Jody this is absolutely caching.

You are running some complex logic, generating some data, and then saving to disk so that you don't have to run the computation again. I don't see how that isn't caching.