Index: render.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/render/render.module,v
retrieving revision 1.10
diff -u -p -r1.10 render.module
--- render.module	25 Oct 2008 12:46:34 -0000	1.10
+++ render.module	25 Oct 2008 12:56:29 -0000
@@ -664,33 +664,37 @@ function render_get_fonts($plugin = NULL
  *   An array of rules.
  */
 function render_get_rules($plugin = NULL, $reset = FALSE) {
-  static $rules = array();
-  
-  if (!empty($rules) && !$reset) {
-    return $rules;
-  }
-  
-  if (isset($plugin)) {
-    $result = db_query("SELECT * FROM {render} WHERE plugin = '%s' ORDER BY weight", check_plain($plugin));
-  }
-  else {
+  static $rules;
+
+  if (!isset($rules) || $reset) {
+    $rules = array();
     $result = db_query('SELECT * FROM {render} ORDER BY weight');
-  }
-  while ($rule = db_fetch_array($result)) {
-    // Unserialize custom plugin properties.
-    $properties = unserialize($rule['properties']);
-    $rule = array_merge($rule, $properties);
-    
-    $rules[$rule['rid']] = $rule;
+    while ($rule = db_fetch_array($result)) {
+      // Unserialize custom plugin properties.
+      // @todo Use objects instead of arrays, and drupal_unpack() for this.
+      $properties = unserialize($rule['properties']);
+      $rule = array_merge($rule, $properties);
+
+      $rules[$rule['rid']] = $rule;
+    }
+
+    // Store active plugins in a variable.
+    $active_plugins = array();
+    foreach ($rules as $rule) {
+      $active_plugins[$rule['plugin']] = $rule['plugin'];
+    }
+    variable_set('render_plugins', $active_plugins);
   }
 
-  // Store active plugins in a variable.
-  $active_plugins = array();
-  foreach ($rules as $rule) {
-    $active_plugins[$rule['plugin']] = $rule['plugin'];
+  // If rules from a single plugin were requested, remove all other rules.
+  // @todo Add plugin as first array key to $rules array.
+  if (isset($plugin)) {
+    foreach ($rules as $rid => $rule) {
+      if ($rule['plugin'] != $plugin) {
+        unset($rules[$rid]);
+      }
+    }
   }
-  variable_set('render_plugins', $active_plugins);
-  
   return $rules;
 }
 
