? wysiwyg-DRUPAL-6--2.patch.tmp
Index: wysiwyg.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.admin.inc,v
retrieving revision 1.15.2.9
diff -u -p -r1.15.2.9 wysiwyg.admin.inc
--- wysiwyg.admin.inc	13 Feb 2010 23:58:41 -0000	1.15.2.9
+++ wysiwyg.admin.inc	14 Jul 2010 23:18:25 -0000
@@ -107,7 +107,7 @@ function wysiwyg_profile_form($form_stat
     '#theme' => 'wysiwyg_admin_button_table',
   );
 
-  $plugins = wysiwyg_get_plugins($profile->editor);
+  $plugins = wysiwyg_get_plugins($profile->editor, TRUE);
   // Generate the button list.
   foreach ($plugins as $name => $meta) {
     if (isset($meta['buttons']) && is_array($meta['buttons'])) {
@@ -363,7 +363,7 @@ function wysiwyg_profile_overview() {
   include_once './includes/install.inc';
 
   // Check which wysiwyg editors are installed.
-  $editors = wysiwyg_get_all_editors();
+  $editors = wysiwyg_get_all_editors(TRUE);
   $count = count($editors);
   $status = array();
   $options = array('' => t('No editor'));
Index: wysiwyg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.module,v
retrieving revision 1.33.2.11
diff -u -p -r1.33.2.11 wysiwyg.module
--- wysiwyg.module	14 Feb 2010 01:59:47 -0000	1.33.2.11
+++ wysiwyg.module	15 Jul 2010 00:20:53 -0000
@@ -505,11 +505,13 @@ function wysiwyg_get_editor_themes(&$pro
  *
  * @param $editor_name
  *   The internal name of an editor to return plugins for.
+ * @param $reset
+ *   Internal use; reset cached list of plugins.
  *
  * @return
  *   An array for each plugin.
  */
-function wysiwyg_get_plugins($editor_name) {
+function wysiwyg_get_plugins($editor_name, $reset = FALSE) {
   $plugins = array();
   if (!empty($editor_name)) {
     $editor = wysiwyg_get_editor($editor_name);
@@ -524,7 +526,7 @@ function wysiwyg_get_plugins($editor_nam
     if (isset($editor['proxy plugin'])) {
       $plugins += $editor['proxy plugin'];
       $proxy = key($editor['proxy plugin']);
-      foreach (wysiwyg_get_all_plugins() as $plugin_name => $info) {
+      foreach (wysiwyg_get_all_plugins($reset) as $plugin_name => $info) {
         $plugins[$proxy]['buttons'][$plugin_name] = $info['title'];
       }
     }
@@ -682,15 +684,18 @@ function wysiwyg_get_editor($name) {
 
 /**
  * Compile a list holding all supported editors including installed editor version information.
+ *
+ * @param $reset
+ *   Internal use; reset cached list of editors.
  */
-function wysiwyg_get_all_editors() {
+function wysiwyg_get_all_editors($reset = FALSE) {
   static $editors;
 
-  if (isset($editors)) {
+  if (isset($editors) && !$reset) {
     return $editors;
   }
 
-  $editors = wysiwyg_load_includes('editors', 'editor');
+  $editors = wysiwyg_load_includes('editors', 'editor', NULL, $reset);
   foreach ($editors as $editor => $properties) {
     // Fill in required properties.
     $editors[$editor] += array(
@@ -744,15 +749,18 @@ function wysiwyg_get_all_editors() {
 
 /**
  * Invoke hook_wysiwyg_plugin() in all modules.
+ *
+ * @param $reset
+ *   Internal use; reset cached list of plugins.
  */
-function wysiwyg_get_all_plugins() {
+function wysiwyg_get_all_plugins($reset = FALSE) {
   static $plugins;
 
-  if (isset($plugins)) {
+  if (isset($plugins) && !$reset) {
     return $plugins;
   }
 
-  $plugins = wysiwyg_load_includes('plugins', 'plugin');
+  $plugins = wysiwyg_load_includes('plugins', 'plugin', NULL, $reset);
   foreach ($plugins as $name => $properties) {
     $plugin = &$plugins[$name];
     // Fill in required/default properties.
@@ -791,28 +799,42 @@ function wysiwyg_get_all_plugins() {
  *   The hook name to invoke.
  * @param $file
  *   An optional include file name without .inc extension to limit the search to.
+ * @param $reset
+ *   Internal use; reset cached file listings.
  *
  * @see wysiwyg_get_directories(), _wysiwyg_process_include()
  */
-function wysiwyg_load_includes($type = 'editors', $hook = 'editor', $file = NULL) {
-  // Determine implementations.
-  $directories = wysiwyg_get_directories($type);
-  $directories['wysiwyg_'] = drupal_get_path('module', 'wysiwyg') . '/' . $type;
-  $file_list = array();
-  foreach ($directories as $module => $path) {
-    $file_list[$module] = drupal_system_listing("$file" . '.inc$', $path, 'name', 0);
-  }
-
-  // Load implementations.
-  $info = array();
-  foreach (array_filter($file_list) as $module => $files) {
-    foreach ($files as $file) {
-      include_once './' . $file->filename;
-      $result = _wysiwyg_process_include('wysiwyg', $module . $file->name, dirname($file->filename), $hook);
-      if (is_array($result)) {
-        $info = array_merge($info, $result);
+function wysiwyg_load_includes($type = 'editors', $hook = 'editor', $file = NULL, $reset = FALSE) {
+  $cid = "wysiwyg_load_includes:$type:$file";
+  if (!$reset && $cached = cache_get($cid)) {
+    $info = $cached->data;
+
+    // Load include files.
+    foreach ($info as $data) {
+      include_once './' . $data['path'] . '/' . $data['name'] . '.inc';
+    }
+  }
+  else {
+    // Determine implementations.
+    $directories = wysiwyg_get_directories($type);
+    $directories['wysiwyg_'] = drupal_get_path('module', 'wysiwyg') . '/' . $type;
+    $file_list = array();
+    foreach ($directories as $module => $path) {
+      $file_list[$module] = drupal_system_listing("$file" . '.inc$', $path, 'name', 0);
+    }
+
+    // Load implementations.
+    $info = array();
+    foreach (array_filter($file_list) as $module => $files) {
+      foreach ($files as $file) {
+        include_once './' . $file->filename;
+        $result = _wysiwyg_process_include('wysiwyg', $module . $file->name, dirname($file->filename), $hook);
+        if (is_array($result)) {
+          $info = array_merge($info, $result);
+        }
       }
     }
+    cache_set($cid, $info);
   }
   return $info;
 }
