From 0baa731aa45018ae8ae07f8addb73cf1c2b90468 Mon Sep 17 00:00:00 2001
From: Earl Miles <merlin@logrus.com>
Date: Tue, 5 May 2009 23:17:57 +0000
Subject: [PATCH] #426652: Clear CTools CSS cache during a system cache flush.

---
 ctools.module    | 8 ++++++++
 includes/css.inc | 9 ++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ctools.module b/ctools.module
index 6308ca78..efc8001d 100644
--- a/ctools.module
+++ b/ctools.module
@@ -282,3 +282,11 @@ function ctools_preprocess_node(&$vars) {
     $vars['template_files'][] = 'node-panel-' . check_plain($vars['node']->panel_identifier);
   }
 }
+
+/**
+ * Ensure the CTools CSS cache is flushed whenever hook_flush_caches is invoked.
+ */
+function ctools_flush_caches() {
+  ctools_include('css');
+  ctools_css_flush_caches();
+}
diff --git a/includes/css.inc b/includes/css.inc
index 283cc8d7..313188a1 100644
--- a/includes/css.inc
+++ b/includes/css.inc
@@ -154,7 +154,7 @@ function ctools_css_cache($css, $filter = TRUE) {
     file_check_directory($path, FILE_CREATE_DIRECTORY);
   }
 
-  // @todo Is this slow? DOes it matter if it is?
+  // @todo Is this slow? Does it matter if it is?
   $filename = $path . '/' . md5($css) . '.css';
 
   // This will do renames if the file already exists, ensuring we don't
@@ -528,3 +528,10 @@ function ctools_css_filter_default_allowed_values() {
   );
 }
 
+/**
+ * Delegated implementation of hook_flush_caches()
+ */
+function ctools_css_flush_caches() {
+  file_scan_directory(file_create_path('ctools/css'), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE);
+  db_query("TRUNCATE {ctools_css_cache}");
+}
-- 
GitLab