Index: ctools.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/ctools.install,v
retrieving revision 1.13
diff -u -p -r1.13 ctools.install
--- ctools.install	8 Oct 2009 11:18:57 -0000	1.13
+++ ctools.install	8 Oct 2009 23:30:06 -0000
@@ -13,22 +13,15 @@
 function ctools_requirements($phase) {
   $requirements = array();
   if ($phase == 'runtime') {
-    $path = file_create_path('ctools/css');
-    if (!file_check_directory($path)) {
-      $path = file_directory_path() . '/ctools';
-      file_check_directory($path, FILE_CREATE_DIRECTORY);
-      $path .= '/css';
-      file_check_directory($path, FILE_CREATE_DIRECTORY);
-    }
-
     $requirements['ctools_css_cache'] = array(
       'title' => t('CTools CSS Cache'),
       'severity' => REQUIREMENT_OK,
       'value' => t('Exists'),
     );
 
-    if (!file_check_directory($path)) {
-      $requirements['ctools_css_cache']['description'] = t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => $path));
+    $path = 'public://ctools/css';
+    if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
+      $requirements['ctools_css_cache']['description'] = t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path)));
       $requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR;
       $requirements['ctools_css_cache']['value'] = t('Unable to create');
     }
@@ -141,50 +134,37 @@ function ctools_schema_1() {
  * errors.
  */
 function ctools_update_6001() {
-  $ret = array();
-
   // Perform updates like this to reduce code duplication.
   $schema = ctools_schema_2();
 
-  db_change_field($ret, 'ctools_object_cache', 'name', 'name', $schema['ctools_object_cache']['fields']['name']);
-
-  return $ret;
+  db_change_field('ctools_object_cache', 'name', 'name', $schema['ctools_object_cache']['fields']['name']);
 }
 
 /**
  * Add the new css cache table.
  */
 function ctools_update_6002() {
-  $ret = array();
-
   // Schema 2 is locked and should not be changed.
   $schema = ctools_schema_2();
 
-  db_create_table($ret, 'ctools_css_cache', $schema['ctools_css_cache']);
-  return $ret;
+  db_create_table('ctools_css_cache', $schema['ctools_css_cache']);
 }
 
 /**
  * Take over for the panels_views module if it was on.
  */
 function ctools_update_6003() {
-  $ret = array();
-
-  $result = db_result(db_query("SELECT status FROM {system} WHERE name = 'panels_views'"));
+  $result = db_query('SELECT status FROM {system} WHERE name = :name', array(':name' => 'panels_views'))->fetchField();
   if ($result) {
-    $ret[] = update_sql("DELETE from {system} WHERE name = 'panels_views'");
+    db_delete('system')->condition('name', 'panels_views')->execute();
     drupal_install_modules(array('views_content'));
   }
-
-  return $ret;
 }
 
 /**
  * Add primary key to the ctools_object_cache table.
  */
 function ctools_update_6004() {
-  $ret = array();
-  db_add_primary_key($ret, 'ctools_object_cache', array('sid', 'obj', 'name'));
-  db_drop_index($ret, 'ctools_object_cache', 'sid_obj_name');
-  return $ret;
+  db_add_primary_key('ctools_object_cache', array('sid', 'obj', 'name'));
+  db_drop_index('ctools_object_cache', 'sid_obj_name');
 }
Index: ctools.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/ctools.module,v
retrieving revision 1.28
diff -u -p -r1.28 ctools.module
--- ctools.module	27 Sep 2009 03:41:00 -0000	1.28
+++ ctools.module	8 Oct 2009 12:37:42 -0000
@@ -226,13 +226,8 @@ function ctools_ctools_plugin_directory(
 function ctools_get_roles() {
   static $roles = NULL;
   if (!isset($roles)) {
-    $roles = array();
-    $result = db_query("SELECT r.rid, r.name FROM {role} r ORDER BY r.name");
-    while ($obj = db_fetch_object($result)) {
-      $roles[$obj->rid] = $obj->name;
-    }
+    $roles = db_query('SELECT r.rid, r.name FROM {role} r ORDER BY r.name')->fetchAllKeyed();
   }
-
   return $roles;
 }
 
Index: bulk_export/bulk_export.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/bulk_export/bulk_export.module,v
retrieving revision 1.3
diff -u -p -r1.3 bulk_export.module
--- bulk_export/bulk_export.module	22 Jul 2009 21:12:07 -0000	1.3
+++ bulk_export/bulk_export.module	4 Oct 2009 17:18:31 -0000
@@ -9,15 +9,21 @@
 /**
  * Implementation of hook_perm().
  */
-function bulk_export_perm() {
-  return array('use bulk exporter');
+function bulk_export_permission() {
+  return array(
+    'use bulk exporter' => array(
+      'title' => t('Access Bulk Exporter'),
+      'description' => t('Export various system objects into code.'),
+    ),
+  );
 }
 
 /**
  * Implementation of hook_theme().
  */
 function bulk_export_theme() {
-  return array('bulk_export_export_form' => array(
+  return array(
+    'bulk_export_export_form' => array(
       'arguments' => array('form' => NULL),
     ),
   );
@@ -56,14 +62,13 @@ function bulk_export_export() {
     }
   }
   if ($exportables) {
-    ctools_include('form');
     $form_state = array(
       're_render' => FALSE,
       'no_redirect' => TRUE,
       'exportables' => $exportables,
       'export_tables' => $export_tables,
     );
-    $output = ctools_build_form('bulk_export_export_form', $form_state);
+    $output = drupal_build_form('bulk_export_export_form', $form_state);
     if (!$output) {
       drupal_set_title(t('Bulk export results'));
       $output = '';
@@ -138,8 +143,7 @@ function bulk_export_export() {
  * FAPI definition for the bulk exporter form.
  *
  */
-function bulk_export_export_form(&$form_state) {
-  $form = array();
+function bulk_export_export_form($form, &$form_state) {
   $form['tables'] = array(
     '#prefix' => '<div class="clear-block">',
     '#suffix' => '</div>',
Index: includes/content.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/content.inc,v
retrieving revision 1.13
diff -u -p -r1.13 content.inc
--- includes/content.inc	8 Oct 2009 17:02:16 -0000	1.13
+++ includes/content.inc	8 Oct 2009 23:27:48 -0000
@@ -299,7 +299,7 @@ function ctools_content_render($type, $s
           $url = $content->title_link;
         }
         // set defaults so we don't bring up notices
-        $url += array('href' => '', 'attributes' => NULL, 'query' => NULL, 'fragment' => NULL, 'absolute' => NULL, 'html' => TRUE);
+        $url += array('href' => '', 'attributes' => array(), 'query' => array(), 'fragment' => '', 'absolute' => NULL, 'html' => TRUE);
         $content->title = l($content->title, $url['href'], $url);
       }
     }
@@ -420,7 +420,7 @@ function ctools_content_admin_info($type
   if (empty($output) || !is_object($output)) {
     $output = new stdClass();
     $output->title = t('No info');
-    $output->content =t ('No info available.');
+    $output->content = t('No info available.');
   }
   return $output;
 }
Index: includes/content.menu.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/content.menu.inc,v
retrieving revision 1.3
diff -u -p -r1.3 content.menu.inc
--- includes/content.menu.inc	27 Sep 2009 03:41:01 -0000	1.3
+++ includes/content.menu.inc	8 Oct 2009 12:38:06 -0000
@@ -31,20 +31,20 @@ function ctools_content_autocomplete_nod
       $match = preg_match('/^nid: (\d+)/', $string, $preg_matches);
     }
     if ($match) {
-      $arg = $preg_matches[1];
-      $where = "n.nid = %d";
+      $arg = array(':nid' => $preg_matches[1]);
+      $where = "n.nid = :nid";
     }
     else {
-      $arg = $string;
-      $where = "LOWER(n.title) LIKE LOWER('%%%s%%')";
+      $arg = array(':title' => '%' . $string . '%');
+      $where = "LOWER(n.title) LIKE LOWER(:title)";
     }
-    $result = db_query_range("SELECT n.nid, n.title, u.name FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE $where", $arg, 0, 10);
+    $result = db_query_range('SELECT n.nid, n.title, u.name FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE $where', 0, 10, $arg);
 
     $matches = array();
-    while ($node = db_fetch_object($result)) {
+    foreach ($result as $node) {
       $name = empty($node->name) ? variable_get('anonymous', t('Anonymous')) : check_plain($node->name);
       $matches[$node->title . " [nid: $node->nid]"] = '<span class="autocomplete_title">' . check_plain($node->title) . '</span> <span class="autocomplete_user">(' . t('by @user', array('@user' => $name)) . ')</span>';
     }
-    drupal_json($matches);
+    drupal_json_output($matches);
   }
 }
Index: includes/context-access-admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/context-access-admin.inc,v
retrieving revision 1.9
diff -u -p -r1.9 context-access-admin.inc
--- includes/context-access-admin.inc	8 Oct 2009 11:09:56 -0000	1.9
+++ includes/context-access-admin.inc	8 Oct 2009 11:10:43 -0000
@@ -113,7 +113,7 @@
 /**
  * Administrative form for access control.
  */
-function ctools_access_admin_form(&$form_state) {
+function ctools_access_admin_form($form, &$form_state) {
   ctools_include('context');
   $argument = isset($form_state['callback argument']) ? $form_state['callback argument'] : '';
   $fragment = $form_state['module'];
@@ -387,7 +387,7 @@ function ctools_access_ajax_edit($fragme
 /**
  * From to edit the settings of an access test.
  */
-function ctools_access_ajax_edit_item(&$form_state) {
+function ctools_access_ajax_edit_item($form, &$form_state) {
   $test = &$form_state['test'];
   $plugin = &$form_state['plugin'];
 
@@ -411,7 +411,7 @@ function ctools_access_ajax_edit_item(&$
 /**
  * Validate handler for argument settings.
  */
-function ctools_access_ajax_edit_item_validate(&$form, &$form_state) {
+function ctools_access_ajax_edit_item_validate($form, &$form_state) {
   if ($function = ctools_plugin_get_function($form_state['plugin'], 'settings form validate')) {
     $function($form, $form_state);
   }
@@ -420,7 +420,7 @@ function ctools_access_ajax_edit_item_va
 /**
  * Submit handler for argument settings.
  */
-function ctools_access_ajax_edit_item_submit(&$form, &$form_state) {
+function ctools_access_ajax_edit_item_submit($form, &$form_state) {
   if ($function = ctools_plugin_get_function($form_state['plugin'], 'settings form submit')) {
     $function($form, $form_state);
   }
Index: includes/context-task-handler.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/context-task-handler.inc,v
retrieving revision 1.24
diff -u -p -r1.24 context-task-handler.inc
--- includes/context-task-handler.inc	8 Oct 2009 16:27:00 -0000	1.24
+++ includes/context-task-handler.inc	8 Oct 2009 23:27:48 -0000
@@ -64,7 +64,7 @@ function ctools_context_handler_render($
         // such as a book.
         if (menu_get_active_menu_name() == 'navigation') {
           $item = menu_get_item();
-          $mlink = db_fetch_object(db_query("SELECT * FROM {menu_links} WHERE link_path = '%s'", $item['href']));
+          $mlink = db_query('SELECT * FROM {menu_links} WHERE link_path = :path', array(':path' => $item['href']))->fetchObject();
 
           if ($mlink && isset($mlink->menu_name)) {
             menu_set_active_menu_name($mlink->menu_name);
Index: includes/css.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/css.inc,v
retrieving revision 1.11
diff -u -p -r1.11 css.inc
--- includes/css.inc	27 Sep 2009 03:41:01 -0000	1.11
+++ includes/css.inc	8 Oct 2009 12:35:24 -0000
@@ -67,7 +67,7 @@
  * ctools_css_retrieve.
  */
 function ctools_css_store($id, $css, $filter = TRUE) {
-  $filename = db_result(db_query("SELECT filename FROM {ctools_css_cache} WHERE cid = ':cid'", array(':cid' => $id)));
+  $filename = db_query('SELECT filename FROM {ctools_css_cache} WHERE cid = :cid', array(':cid' => $id))->fetchField();
   if ($filename && file_exists($filename)) {
     file_unmanaged_delete($filename);
   }
@@ -96,7 +96,7 @@ function ctools_css_store($id, $css, $fi
  * This will ensure the file still exists and, if not, create it.
  */
 function ctools_css_retrieve($id) {
-  $cache = db_query("SELECT * FROM {ctools_css_cache} WHERE cid = ':id'", array(':id' => $id)))->fetchObject();
+  $cache = db_query('SELECT * FROM {ctools_css_cache} WHERE cid = :cid', array(':cid' => $id))->fetchObject();
   if (!$cache) {
     return;
   }
@@ -119,7 +119,7 @@ function ctools_css_retrieve($id) {
  * Remove stored CSS and any associated file.
  */
 function ctools_css_clear($id) {
-  $cache = db_query("SELECT * FROM {ctools_css_cache} WHERE cid = ':id'", array(':id' => $id)))->fetchObject();
+  $cache = db_query('SELECT * FROM {ctools_css_cache} WHERE cid = :cid', array(':cid' => $id))->fetchObject();
   if (!$cache) {
     return;
   }
@@ -545,6 +545,11 @@ function ctools_css_filter_default_allow
  * 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("DELETE FROM {ctools_css_cache}");
+  // Remove all generated files.
+  // @see http://drupal.org/node/573292
+  // file_unmanaged_delete_recursive('public://render');
+  $filedir = file_directory_path('public') . '/ctools/css';
+  file_unmanaged_delete_recursive($filedir);
+
+  db_delete('ctools_css_cache')->execute();
 }
Index: includes/export.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/export.inc,v
retrieving revision 1.21
diff -u -p -r1.21 export.inc
--- includes/export.inc	8 Oct 2009 16:12:08 -0000	1.21
+++ includes/export.inc	8 Oct 2009 23:31:29 -0000
@@ -113,34 +113,27 @@ function ctools_export_load_object($tabl
   }
 
   // Build the query
-  $query = "SELECT * FROM {" . $table . "}";
+  $query = db_select($table);
   $conditions = array();
   $query_args = array();
 
   // If they passed in names, add them to the query.
   if ($type == 'names') {
-    $conditions[] = "$export[key] IN (" . db_placeholders($args, $schema['fields'][$export['key']]['type']) . ")";
-    $query_args = $args;
+    $query->condition($export['key'], $args, 'IN');
   }
   else if ($type == 'conditions') {
     foreach ($args as $key => $value) {
       if (isset($schema['fields'][$key])) {
-        $conditions[] = "$key = " . db_type_placeholder($schema['fields'][$key]['type']);
-        $query_args[] = $value;
+        $query->condition($key, $value);
       }
     }
   }
 
-  // Make a string out of the conditions.
-  if ($conditions) {
-    $query .= " WHERE " . implode(' AND ', $conditions);
-  }
-
-  $result = db_query($query, $query_args);
+  $result = $query->execute();
 
   $status = variable_get($export['status'], array());
   // Unpack the results of the query onto objects and cache them.
-  while ($data = db_fetch_object($result)) {
+  foreach ($result as $data) {
     $object = _ctools_export_unpack_object($schema, $data, $export['object']);
     $object->table = $table;
     $object->type = t('Normal');
@@ -333,7 +326,7 @@ function _ctools_export_get_defaults($ta
  * @param $schema
  *   The schema from drupal_get_schema().
  * @param $data
- *   The data as loaded by db_fetch_object().
+ *   The data as loaded from the database.
  * @param $object
  *   If an object, data will be unpacked onto it. If a string
  *   an object of that type will be created.
@@ -350,7 +343,7 @@ function _ctools_export_unpack_object($s
 
   // Go through our schema and build correlations.
   foreach ($schema['fields'] as $field => $info) {
-    $object->$field = empty($info['serialize']) ? $data->$field : unserialize(db_decode_blob($data->$field));
+    $object->$field = empty($info['serialize']) ? $data->$field : unserialize($data->$field);
   }
 
   return $object;
@@ -362,7 +355,7 @@ function _ctools_export_unpack_object($s
  * @param $table
  *   The name of the table this object represents.
  * @param $data
- *   The data as loaded by db_fetch_object().
+ *   The data as loaded from the database.
  */
 function ctools_export_unpack_object($table, $data) {
   $schema = ctools_export_get_schema($table);
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/menu.inc,v
retrieving revision 1.4
diff -u -p -r1.4 menu.inc
--- includes/menu.inc	12 Jul 2009 05:28:31 -0000	1.4
+++ includes/menu.inc	7 Oct 2009 23:25:21 -0000
@@ -145,32 +145,29 @@ function ctools_menu_tree_page_data($ite
       // Build and run the query, and build the tree.
       if ($item['access']) {
         // Check whether a menu link exists that corresponds to the current path.
-        $args = array($menu_name, $item['href']);
-        $placeholders = "'%s'";
+        $args = array($item['href']);
         if (drupal_is_front_page()) {
           $args[] = '<front>';
-          $placeholders .= ", '%s'";
         }
-        $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path IN (". $placeholders .")", $args));
+        $parents = db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = :menu_name AND link_path IN (:href)", array(':menu_name' => $menu_name, ':href' => $args))->fetchAll(PDO::FETCH_ASSOC);
 
         if (empty($parents)) {
           // If no link exists, we may be on a local task that's not in the links.
           // TODO: Handle the case like a local task on a specific node in the menu.
-          $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['tab_root']));
+          $parents = db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = :menu_name AND link_path = :path", array(':menu_name' => $menu_name, ':path' => $item['tab_root']))->fetchAll(PDO::FETCH_ASSOC);
         }
         // We always want all the top-level links with plid == 0.
         $parents[] = '0';
 
         // Use array_values() so that the indices are numeric for array_merge().
         $args = $parents = array_unique(array_values($parents));
-        $placeholders = implode(', ', array_fill(0, count($args), '%d'));
         $expanded = variable_get('menu_expanded', array());
         // Check whether the current menu has any links set to be expanded.
         if (in_array($menu_name, $expanded)) {
           // Collect all the links set to be expanded, and then add all of
           // their children to the list as well.
           do {
-            $result = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = '%s' AND expanded = 1 AND has_children = 1 AND plid IN (". $placeholders .') AND mlid NOT IN ('. $placeholders .')', array_merge(array($menu_name), $args, $args));
+            $result = db_query('SELECT mlid FROM {menu_links} WHERE menu_name = :menu_name AND expanded = 1 AND has_children = 1 AND plid IN (:args) AND mlid NOT IN (:args)', array(':menu_name' => $menu_name, ':args' => $args))->fetchAll(PDO::FETCH_ASSOC);
             $num_rows = FALSE;
             while ($item = db_fetch_array($result)) {
               $args[] = $item['mlid'];
Index: includes/object-cache.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/object-cache.inc,v
retrieving revision 1.9
diff -u -p -r1.9 object-cache.inc
--- includes/object-cache.inc	27 Sep 2009 03:41:01 -0000	1.9
+++ includes/object-cache.inc	8 Oct 2009 12:38:48 -0000
@@ -35,9 +35,9 @@ function ctools_object_cache_get($obj, $
   }
 
   if (!array_key_exists($key, $cache)) {
-    $data = db_fetch_object(db_query("SELECT * FROM {ctools_object_cache} WHERE sid = '%s' AND obj = '%s' AND name = '%s'", session_id(), $obj, $name));
+    $data = db_query('SELECT * FROM {ctools_object_cache} WHERE sid = :session_id AND obj = :object AND name = :name', array(':session_id' => session_id(), ':object' => $obj, ':name' => $name))->fetchObject();
     if ($data) {
-      $cache[$key] = unserialize(db_decode_blob($data->data));
+      $cache[$key] = unserialize($data->data);
     }
   }
   return isset($cache[$key]) ? $cache[$key] : NULL;
@@ -56,7 +56,15 @@ function ctools_object_cache_get($obj, $
  */
 function ctools_object_cache_set($obj, $name, $cache) {
   ctools_object_cache_clear($obj, $name);
-  db_query("INSERT INTO {ctools_object_cache} (sid, obj, name, data, updated) VALUES ('%s', '%s', '%s', %b, %d)", session_id(), $obj, $name, serialize($cache), REQUEST_TIME);
+  db_insert('ctools_object_cache')
+    ->fields(array(
+      'sid' => session_id(),
+      'obj' => $obj,
+      'name' => $name,
+      'data' => serialize($cache),
+      'updated' => REQUEST_TIME,
+    ))
+    ->execute();
 }
 
 /**
@@ -69,7 +77,11 @@ function ctools_object_cache_set($obj, $
  *   The name of the object being removed.
  */
 function ctools_object_cache_clear($obj, $name) {
-  db_query("DELETE FROM {ctools_object_cache} WHERE sid = '%s' AND obj = '%s' AND name = '%s'", session_id(), $obj, $name);
+  db_delete('ctools_object_cache')
+    ->condition('sid', session_id())
+    ->condition('obj', $obj)
+    ->condition('name', $name)
+    ->execute();
 }
 
 
@@ -89,7 +101,7 @@ function ctools_object_cache_clear($obj,
  *   An object containing the UID and updated date if found; NULL if not.
  */
 function ctools_object_cache_test($obj, $name) {
-  return db_fetch_object(db_query("SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions}  s ON c.sid = s.sid WHERE s.sid != '%s' AND c.obj = '%s' AND c.name = '%s' ORDER BY c.updated ASC", session_id(), $obj, $name));
+  return db_query('SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid <> :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC', array(':session_id' => session_id(), ':obj' => $obj, ':name' => $name))->fetchObject();
 }
 
 /**
@@ -104,7 +116,10 @@ function ctools_object_cache_test($obj, 
  *   The name of the object being removed.
  */
 function ctools_object_cache_clear_all($obj, $name) {
-  db_query("DELETE FROM {ctools_object_cache} WHERE obj = '%s' AND name = '%s'", $obj, $name);
+  db_delete('ctools_object_cache')
+    ->condition('obj', $obj)
+    ->condition('name', $name)
+    ->execute();
 }
 
 /**
@@ -119,5 +134,7 @@ function ctools_object_cache_clean($age 
   if (empty($age)) {
     $age = 86400 * 7; // 7 days
   }
-  db_query("DELETE FROM {ctools_object_cache} WHERE updated < %d", REQUEST_TIME - $age);
+  db_delete('ctools_object_cache')
+    ->condition('updated', REQUEST_TIME - $age, '<')
+    ->execute();
 }
Index: page_manager/page_manager.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/page_manager/page_manager.install,v
retrieving revision 1.8
diff -u -p -r1.8 page_manager.install
--- page_manager/page_manager.install	8 Oct 2009 11:18:57 -0000	1.8
+++ page_manager/page_manager.install	8 Oct 2009 11:58:28 -0000
@@ -195,7 +195,10 @@ function page_manager_schema_1() {
  * Implementation of hook_install().
  */
 function page_manager_install() {
-  db_query("UPDATE {system} SET weight = 99 WHERE name = 'page_manager'");
+  db_update('system')
+    ->fields(array('weight' => 99))
+    ->condition('name', 'page_manager')
+    ->execute();
 }
 
 function page_manager_update_6101() {
Index: page_manager/page_manager.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/page_manager/page_manager.module,v
retrieving revision 1.19
diff -u -p -r1.19 page_manager.module
--- page_manager/page_manager.module	8 Oct 2009 16:27:00 -0000	1.19
+++ page_manager/page_manager.module	8 Oct 2009 23:27:49 -0000
@@ -443,8 +443,8 @@ function page_manager_load_task_handlers
       $placeholders[] = "'%s'";
     }
 
-    $result = db_query("SELECT name, weight FROM {page_manager_weights} WHERE name IN (" . implode(', ', $placeholders) . ")", $names);
-    while ($weight = db_fetch_object($result)) {
+    $result = db_query('SELECT name, weight FROM {page_manager_weights} WHERE name IN :names', array(':names' => $names));
+    foreach ($result as $weight) {
       $handlers[$weight->name]->weight = $weight->weight;
     }
   }
@@ -568,7 +568,9 @@ function page_manager_save_task_handler(
   }
 
   drupal_write_record('page_manager_handlers', $handler, $update);
-  db_query("DELETE FROM {page_manager_weights} WHERE name = '%s'", $handler->name);
+  db_delete('page_manager_weights')
+    ->condition('name', $handler->name)
+    ->execute();
 
   // If this was previously a default handler, we may have to write task handlers.
   if (!$update) {
@@ -585,8 +587,12 @@ function page_manager_delete_task_handle
   if ($function = ctools_plugin_load_function('page_manager', 'task_handlers', $handler->handler, 'delete')) {
     $function($handler);
   }
-  db_query("DELETE FROM {page_manager_handlers} WHERE name = '%s'", $handler->name);
-  db_query("DELETE FROM {page_manager_weights} WHERE name = '%s'", $handler->name);
+  db_delete('page_manager_handlers')
+    ->condition('name', $handler->name)
+    ->execute();
+  db_delete('page_manager_weights')
+    ->condition('name', $handler->name)
+    ->execute();
 }
 
 /**
@@ -654,8 +660,15 @@ function page_manager_new_task_handler($
  * to the database just because they have their weight changed.
  */
 function page_manager_update_task_handler_weight($handler, $weight) {
-  db_query("DELETE FROM {page_manager_weights} WHERE name = '%s'", $handler->name);
-  db_query("INSERT INTO {page_manager_weights} (name, weight) VALUES ('%s', %d)", $handler->name, $weight);
+  db_delete('page_manager_weights')
+    ->condition('name', $handler->name)
+    ->execute();
+  db_insert('page_manager_weights')
+    ->fields(array(
+      'name' => $handler->name,
+      'weight' => $weight,
+    ))
+    ->execute();
 }
 
 
@@ -996,7 +1009,7 @@ function page_manager_menu_link_alter(&$
     }
     else {
       // Since we didn't already see an mlid, let's check the database for one.
-      $mlid = db_result(db_query("SELECT mlid FROM {menu_links} WHERE router_path = '%s'", $item['parent_path']));
+      $mlid = db_query('SELECT mlid FROM {menu_links} WHERE router_path = :path', array('path' => $item['parent_path']))->fetchField();
       if ($mlid) {
         $item['plid'] = $mlid;
       }
Index: page_manager/plugins/tasks/page.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/page_manager/plugins/tasks/page.admin.inc,v
retrieving revision 1.20
diff -u -p -r1.20 page.admin.inc
--- page_manager/plugins/tasks/page.admin.inc	8 Oct 2009 11:09:57 -0000	1.20
+++ page_manager/plugins/tasks/page.admin.inc	8 Oct 2009 12:12:55 -0000
@@ -511,8 +511,8 @@ function page_manager_page_form_basic_va
 
   // Check to see if something that isn't a page manager page is using the path.
   $path = implode('/', $path);
-  $result = db_query("SELECT * FROM {menu_router} WHERE path = '%s'", $path);
-  while ($router = db_fetch_object($result)) {
+  $result = db_query('SELECT * FROM {menu_router} WHERE path = :path', array(':path' => $path));
+  foreach ($result as $router) {
     if ($router->page_callback != 'page_manager_page_execute') {
       form_error($form['path'], t('That path is already in used. This system cannot override existing paths.'));
     }
@@ -520,8 +520,8 @@ function page_manager_page_form_basic_va
 
   // Ensure the path is not already an alias to something else.
   if (strpos($path, '%') === FALSE) {
-    $result = db_query("SELECT src, dst FROM {url_alias} WHERE dst = '%s'", $path);
-    if ($alias = db_fetch_object($result)) {
+    $alias = db_query('SELECT src, dst FROM {url_alias} WHERE dst = :path', array(':path' => $path))->fetchObject();
+    if ($alias) {
       form_error($form['path'], t('That path is currently assigned to be an alias for @alias. This system cannot override existing aliases.', array('@alias' => $alias->src)));
     }
   }
Index: page_manager/plugins/tasks/page.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/page_manager/plugins/tasks/page.inc,v
retrieving revision 1.18
diff -u -p -r1.18 page.inc
--- page_manager/plugins/tasks/page.inc	8 Oct 2009 11:09:57 -0000	1.18
+++ page_manager/plugins/tasks/page.inc	8 Oct 2009 12:13:37 -0000
@@ -439,7 +439,9 @@ function page_manager_page_delete($page)
       page_manager_delete_task_handler($handler);
     }
   }
-  db_query("DELETE FROM {page_manager_pages} WHERE name = '%s'", $page->name);
+  db_delete('page_manager_pages')
+    ->condition('name', $page->name)
+    ->execute();
 
   // Check to see if this was the site frontpage. If so, reset the site
   // frontpage to default.
Index: plugins/content_types/block/block.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/content_types/block/block.inc,v
retrieving revision 1.9
diff -u -p -r1.9 block.inc
--- plugins/content_types/block/block.inc	17 Jul 2009 21:53:41 -0000	1.9
+++ plugins/content_types/block/block.inc	8 Oct 2009 12:15:39 -0000
@@ -75,7 +75,7 @@ function ctools_block_content_type_rende
   $block->delta = $delta;
 
   if ($module == 'block' && empty($conf['override_title'])) {
-    $block->subject = db_result(db_query("SELECT title FROM {blocks} WHERE module = '%s' AND delta = '%s'", 'block', $delta));
+    $block->subject = db_query('SELECT title FROM {blocks} WHERE module = :module AND delta = :delta', array(':module' => 'block', ':delta' => $delta))->fetchField();
   }
 
   if (isset($block->subject)) {
@@ -106,9 +106,7 @@ function ctools_block_content_type_rende
   }
 
   // Test for block visibility
-
-  $result = db_query("SELECT title, pages, visibility FROM {blocks} WHERE module = '%s' AND delta = '%s'", $block->module, $block->delta);
-  $block_visibility = db_fetch_object($result);
+  $block_visibility = db_query('SELECT title, pages, visibility FROM {blocks} WHERE module = :module AND delta = :delta', array(':module' => $block->module, ':delta' => $block->delta))->fetchObject();
 
   if ($block->module == 'block') {
     $block->title = $block_visibility->title;
Index: plugins/content_types/node/node.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/content_types/node/node.inc,v
retrieving revision 1.7
diff -u -p -r1.7 node.inc
--- plugins/content_types/node/node.inc	27 Sep 2009 03:41:02 -0000	1.7
+++ plugins/content_types/node/node.inc	8 Oct 2009 12:17:53 -0000
@@ -166,10 +166,10 @@ function  ctools_node_content_type_edit_
     $nid = $preg_matches[1];
   }
   if (is_numeric($nid)) {
-    $node = db_fetch_object(db_query("SELECT n.nid FROM {node} n WHERE n.nid = %d", $nid));
+    $node = db_query('SELECT nid FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
   }
   else {
-    $node = db_fetch_object(db_query("SELECT n.nid FROM {node} n WHERE LOWER(n.title) = LOWER('%s')", $nid));
+    $node = db_query('SELECT nid FROM {node} WHERE LOWER(title) = LOWER(:title)', array(':title' => $nid))->fetchObject();
   }
   if ($node) {
     $form_state['values']['nid'] = $node->nid;
Index: plugins/content_types/node_context/node_comments.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/content_types/node_context/node_comments.inc,v
retrieving revision 1.3
diff -u -p -r1.3 node_comments.inc
--- plugins/content_types/node_context/node_comments.inc	27 Sep 2009 03:41:02 -0000	1.3
+++ plugins/content_types/node_context/node_comments.inc	8 Oct 2009 23:50:07 -0000
@@ -96,41 +96,43 @@ function ctools_comment_render($node, $c
   $comments_per_page = $conf['comments_per_page'];
 
   // Multiple comment view
-  $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d';
-  $query = 'SELECT c.cid AS cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.thread, c.status, parent_user.uid as parent_uid, parent_user.data as parent_data, parent_user.name as parent_name, parent_user.picture as parent_picture FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid LEFT OUTER JOIN {comments} parent ON c.pid = parent.cid LEFT OUTER JOIN {users} parent_user ON parent.uid = parent_user.uid WHERE c.nid = %d';
+  $query = db_select('comment', 'c')->extend('PagerDefault');
+  $query->addField('c', 'cid');
+  $query
+    ->condition('c.nid', $node->nid)
+    ->addTag('node_access')
+    ->limit($comments_per_page);
+
+  $count_query = db_select('comment', 'c');
+  $count_query->addExpression('COUNT(*)');
+  $count_query
+    ->condition('c.nid', $node->nid)
+    ->addTag('node_access');
 
-  $query_args = array($node->nid);
   if (!user_access('administer comments')) {
-    $query       .= ' AND c.status = %d';
-    $query_count .= ' AND status = %d';
-    $query_args[] = COMMENT_PUBLISHED;
+    $query->condition('c.status', COMMENT_PUBLISHED);
+    $count_query->condition('c.status', COMMENT_PUBLISHED);
   }
-
-  if ($order == COMMENT_ORDER_NEWEST_FIRST) {
-    if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
-      $query .= ' ORDER BY c.timestamp DESC';
-    }
-    else {
-      $query .= ' ORDER BY c.thread DESC';
-    }
+  if ($mode === COMMENT_MODE_FLAT) {
+    $query->orderBy('c.cid', 'ASC');
   }
-  else if ($order == COMMENT_ORDER_OLDEST_FIRST) {
-    if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
-      $query .= ' ORDER BY c.timestamp';
-    }
-    else {
-      $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))';
-    }
+  else {
+    // See comment above. Analysis reveals that this doesn't cost too
+    // much. It scales much much better than having the whole comment
+    // structure.
+    $query->orderBy('SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))', 'ASC');
   }
 
-  // Start a form, for use with comment control.
-  $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
+  $query->setCountQuery($count_query);
+  $cids = $query->execute()->fetchCol();
+
+  $comments = comment_load_multiple($cids);
 
   $divs = 0;
   $last_depth = 0;
   drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
-  while ($comment = db_fetch_object($result)) {
-    $comment = drupal_unpack($comment);
+  foreach ($comments as $comment) {
+    // @todo Not sure about what of this is still needed. 09/10/2009 sun
     $comment->name  = $comment->uid ? $comment->registered_name : $comment->name;
     $comment->depth = count(explode('.', $comment->thread)) - 1;
 
Index: plugins/content_types/term_context/term_list.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/content_types/term_context/term_list.inc,v
retrieving revision 1.4
diff -u -p -r1.4 term_list.inc
--- plugins/content_types/term_context/term_list.inc	27 Sep 2009 03:41:02 -0000	1.4
+++ plugins/content_types/term_context/term_list.inc	8 Oct 2009 12:18:52 -0000
@@ -40,7 +40,7 @@ function ctools_term_list_content_type_r
         break;
 
       case 'sibling':
-        $parent = db_result(db_query("SELECT parent FROM {taxonomy_term_hierarchy} WHERE tid = %d", $term->tid));
+        $parent = db_query('SELECT parent FROM {taxonomy_term_hierarchy} WHERE tid = :tid', array(':tid' => $term->tid))->fetchField();
         $terms = taxonomy_get_children($parent, $term->vid);
         // Remove the term that started this.
         unset($terms[$term->tid]);
Index: plugins/content_types/vocabulary_context/vocabulary_terms.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/content_types/vocabulary_context/vocabulary_terms.inc,v
retrieving revision 1.4
diff -u -p -r1.4 vocabulary_terms.inc
--- plugins/content_types/vocabulary_context/vocabulary_terms.inc	27 Sep 2009 03:41:03 -0000	1.4
+++ plugins/content_types/vocabulary_context/vocabulary_terms.inc	8 Oct 2009 23:53:49 -0000
@@ -52,11 +52,11 @@ function _ctools_content_vocabulary_term
     return array();
   }
   $return = array();
-  $query = db_query('SELECT t.name, t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d AND h.parent = %d ORDER BY t.weight ASC, t.name ASC', $vid, $tid);
-  while ($result = db_fetch_object($query)) {
+  $result = db_query('SELECT t.name, t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} h ON t.tid = h.tid WHERE t.vid = :vid AND h.parent = :parent ORDER BY t.weight ASC, t.name ASC', array(':vid' => $vid, ':parent' => $tid));
+  foreach ($result as $term) {
     $return[] = array(
-      'data' => l($result->name, 'taxonomy/term/'. $result->tid),
-      'children' => _ctools_content_vocabulary_terms($vid, $max_depth, $depth, $result->tid),
+      'data' => l($term->name, 'taxonomy/term/'. $term->tid),
+      'children' => _ctools_content_vocabulary_terms($vid, $max_depth, $depth, $term->tid),
     );
   }
   return $return;
Index: plugins/contexts/node.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/contexts/node.inc,v
retrieving revision 1.12
diff -u -p -r1.12 node.inc
--- plugins/contexts/node.inc	27 Sep 2009 03:41:03 -0000	1.12
+++ plugins/contexts/node.inc	8 Oct 2009 12:26:31 -0000
@@ -86,7 +86,7 @@ function ctools_context_node_settings_fo
   );
 
   if (!empty($conf['nid'])) {
-    $info = db_fetch_object(db_query("SELECT * FROM {node} n WHERE n.nid = %d", $conf['nid']));
+    $info = db_query('SELECT * FROM {node} WHERE nid = :nid', array(':nid' => $conf['nid']))->fetchObject();
     if ($info) {
       $link = l(t("'%title' [node id %nid]", array('%title' => $info->title, '%nid' => $info->nid)), "node/$info->nid", array('attributes' => array('target' => '_blank', 'title' => t('Open in new window')), 'html' => TRUE));
       $form['node']['#description'] = t('Currently set to !link', array('!link' => $link));
@@ -133,10 +133,10 @@ function ctools_context_node_settings_fo
     $nid = $preg_matches[1];
   }
   if (is_numeric($nid)) {
-    $node = db_fetch_object(db_query("SELECT n.nid FROM {node} n WHERE n.nid = %d"), $nid);
+    $node = db_query('SELECT nid FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
   }
   else {
-    $node = db_fetch_object(db_query("SELECT n.nid FROM {node} n WHERE LOWER(n.title) = LOWER('%s')", $nid));
+    $node = db_query('SELECT nid FROM {node} WHERE LOWER(title) = LOWER(:title)', array(':title' => $nid))->fetchObject();
   }
 
   if (!$node) {
Index: plugins/contexts/node_edit_form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/contexts/node_edit_form.inc,v
retrieving revision 1.11
diff -u -p -r1.11 node_edit_form.inc
--- plugins/contexts/node_edit_form.inc	27 Sep 2009 03:41:03 -0000	1.11
+++ plugins/contexts/node_edit_form.inc	8 Oct 2009 12:27:31 -0000
@@ -85,7 +85,7 @@ function ctools_context_node_edit_form_s
   );
 
   if (!empty($conf['nid'])) {
-    $info = db_fetch_object(db_query("SELECT * FROM {node} WHERE nid = %d", $conf['nid']));
+    $info = db_query('SELECT * FROM {node} WHERE nid = :nid', array(':nid' => $conf['nid']))->fetchObject();
     if ($info) {
       $link = l(t("'%title' [node id %nid]", array('%title' => $info->title, '%nid' => $info->nid)), "node/$info->nid", array('target' => '_blank', 'title' => t('Open in new window')));
       $form['node']['#description'] = t('Currently set to !link', array('!link' => $link));
@@ -115,10 +115,10 @@ function ctools_context_node_edit_form_s
 
   $nid = $form_values['node'];
   if (is_numeric($nid)) {
-    $node = db_fetch_object(db_query("SELECT n.nid FROM {node} n WHERE n.nid = %d", $nid));
+    $node = db_query('SELECT nid FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
   }
   else {
-    $node = db_fetch_object(db_query("SELECT n.nid FROM {node} n WHERE LOWER(n.title) = LOWER('%s')", $nid));
+    $node = db_query('SELECT nid FROM {node} WHERE LOWER(title) = LOWER(:title)', array(':title' => $nid))->fetchObject();
     if ($node) {
       form_set_value($form['nid'], $node->nid, $form_state);
     }
Index: plugins/contexts/term.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/contexts/term.inc,v
retrieving revision 1.6
diff -u -p -r1.6 term.inc
--- plugins/contexts/term.inc	27 Sep 2009 03:41:03 -0000	1.6
+++ plugins/contexts/term.inc	8 Oct 2009 12:30:08 -0000
@@ -75,7 +75,7 @@ function ctools_context_term_settings_fo
 
   $description = '';
   if (!empty($conf['tid'])) {
-    $info = db_fetch_object(db_query("SELECT * FROM {taxonomy_term_data} n WHERE n.tid = %d", $conf['tid']));
+    $info = db_query('SELECT * FROM {taxonomy_term_data} WHERE tid = :tid', array(':tid' => $conf['tid']))->fetchObject();
     if ($info) {
       $description = ' ' . t('Currently set to @term. Enter another term if you wish to change the term.', array('@term' => $info->name));
     }
@@ -134,7 +134,7 @@ function ctools_context_term_settings_fo
     return;
   }
 
-  $term = db_fetch_object(db_query("SELECT t.tid FROM {taxonomy_term_data} t WHERE LOWER(t.name) = LOWER('%s') AND t.vid = %d", $form_values['taxonomy'][$vid], $vid));
+  $term = db_query('SELECT tid FROM {taxonomy_term_data} WHERE LOWER(name) = LOWER(:name) AND t.vid = :vid', array(':name' => $form_values['taxonomy'][$vid], ':vid' => $vid))->fetchObject();
 
   if (!$term) {
     form_error($form['taxonomy'][$vid], t('Invalid term selected.'));
@@ -146,7 +146,7 @@ function ctools_context_term_settings_fo
 
 function ctools_context_term_settings_form_submit($form, &$form_values, &$form_state) {
   if ($form_values['set_identifier']) {
-    $term = db_fetch_object(db_query("SELECT t.tid, t.name FROM {taxonomy_term_data} t WHERE LOWER(t.tid) = %d", $form_values['tid']));
+    $term = db_query('SELECT tid, name FROM {taxonomy_term_data} WHERE LOWER(tid) = :tid', array(':tid' => $form_values['tid']))->fetchObject();
     $form_state['values']['context']['identifier'] = $term->name;
   }
 
Index: plugins/contexts/terms.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/contexts/terms.inc,v
retrieving revision 1.5
diff -u -p -r1.5 terms.inc
--- plugins/contexts/terms.inc	27 Sep 2009 03:41:03 -0000	1.5
+++ plugins/contexts/terms.inc	8 Oct 2009 12:31:06 -0000
@@ -81,8 +81,8 @@ function ctools_context_terms_convert($c
           $context->names = '';
         }
         else {
-          $result = db_query("SELECT tid, name FROM {taxonomy_term_data} WHERE tid IN (" . db_placeholders($context->tids) . ")", $context->tids);
-          while ($term = db_fetch_object($result)) {
+          $result = db_query('SELECT tid, name FROM {taxonomy_term_data} WHERE tid IN :tids', array(':tids' => $context->tids));
+          foreach ($result as $term) {
             $names[$term->tid] = $term->name;
           }
           $context->names = implode($context->operator == 'or' ? ' + ' : ', ', $names);
Index: plugins/relationships/book_parent.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/relationships/book_parent.inc,v
retrieving revision 1.2
diff -u -p -r1.2 book_parent.inc
--- plugins/relationships/book_parent.inc	20 Jul 2009 16:01:20 -0000	1.2
+++ plugins/relationships/book_parent.inc	8 Oct 2009 12:31:53 -0000
@@ -36,7 +36,7 @@ function ctools_book_parent_context($con
       // Search through the book tree to load the top level.
       $result = array('nid' => $context->data->nid, 'vid' => $context->data->vid, 'parent' => $context->data->parent);
       while (!empty($result['parent'])) {
-        $result = db_fetch_array(db_query("SELECT * FROM {book} b INNER JOIN {node} n ON b.vid = n.nid WHERE b.nid = %d", $result['parent']));
+        $result = db_query('SELECT * FROM {book} b INNER JOIN {node} n ON b.vid = n.nid WHERE b.nid = :nid', array(':nid' => $result['parent']))->fetchAssoc();
       }
       $nid = $result['nid'];
     }
Index: plugins/relationships/term_parent.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/plugins/relationships/term_parent.inc,v
retrieving revision 1.3
diff -u -p -r1.3 term_parent.inc
--- plugins/relationships/term_parent.inc	27 Sep 2009 03:41:03 -0000	1.3
+++ plugins/relationships/term_parent.inc	8 Oct 2009 12:32:52 -0000
@@ -32,7 +32,7 @@ function ctools_term_parent_context($con
   }
 
   if (isset($context->data)) {
-    $result = db_fetch_array(db_query("SELECT t1.* FROM {taxonomy_term_hierarchy} t1 INNER JOIN {taxonomy_term_hierarchy} t2 ON t1.tid = t2.parent WHERE t2.tid = %d", $context->data->tid));
+    $result = db_query('SELECT t1.* FROM {taxonomy_term_hierarchy} t1 INNER JOIN {taxonomy_term_hierarchy} t2 ON t1.tid = t2.parent WHERE t2.tid = :tid', array(':tid' => $context->data->tid))->fetchAssoc();
 
     // If top level term, keep looking up until we see a top level.
     if ($conf['type'] == 'top') {
@@ -42,7 +42,7 @@ function ctools_term_parent_context($con
         $result['tid'] = $context->data->tid;
       }
       while (!empty($result['parent'])) {
-        $result = db_fetch_array(db_query("SELECT * FROM {taxonomy_term_hierarchy} WHERE tid = %d", $result['parent']));
+        $result = db_query('SELECT * FROM {taxonomy_term_hierarchy} WHERE tid = :tid', array(':tid' => $result['parent']))->fetchAssoc();
       }
     }
 
