Index: chessboard.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chessboard/chessboard.module,v
retrieving revision 1.70
diff -u -p -r1.70 chessboard.module
--- chessboard.module	15 Nov 2010 15:34:07 -0000	1.70
+++ chessboard.module	15 Nov 2010 19:41:10 -0000
@@ -23,19 +23,9 @@ function chessboard_help($path, $arg) {
  * Implementation of hook_init().
  */
 function chessboard_init() {
-  $formats = db_query('SELECT format FROM {filter_formats}');
-  while (is_numeric($format = db_result($formats))) {
-    if (filter_format_allowcache($format)) {
-      $list = cache_get($format . ':chessboard-filter-attached-cids', 'cache_filter');
-      if (isset($list->data)) {
-        foreach ($list->data as $cid => $status) {
-          $cache = cache_get($cid, 'cache_filter');
-          if (isset($cache->data['#attached'])) {
-            chessboard_process_attached($cache->data);
-          }
-        }
-      }
-    }
+  $result = db_query('SELECT * FROM {filter_formats}');
+  while ($format = db_fetch_object($result)) {
+    _chessboard_filter_add_structures($format);
   }
 }
 
@@ -307,6 +297,20 @@ function _chessboard_filter_callback($ma
   return $output;
 }
 
+function _chessboard_filter_add_structures($format) {
+  if (filter_format_allowcache($format->format)) {
+    $list = cache_get($format->format . ':chessboard-filter-attached-cids', 'cache_filter');
+    if (isset($list->data)) {
+      foreach ($list->data as $cid => $status) {
+        $cache = cache_get($cid, 'cache_filter');
+        if (isset($cache->data['#attached'])) {
+          chessboard_process_attached($cache->data);
+        }
+      }
+    }
+  }
+}
+
 function chessboard_formatter_view($items) {
   $element = array(
     '#attached' => array(
