diff --git a/feeds.module b/feeds.module index cbd40e1f58c39e23ed6f2d0321796cc40f3e404a..6c0142c057b59fb702b2dc550126af752f401173 100644 --- a/feeds.module +++ b/feeds.module @@ -30,8 +30,11 @@ function feeds_cron() { if ($importers = feeds_reschedule()) { foreach ($importers as $id) { feeds_importer($id)->schedule(); - $result = db_query("SELECT feed_nid FROM {feeds_source} WHERE id = '%s'", $id); - while ($row = db_fetch_object($result)) { + $rows = db_select('feeds_source') + ->fields('feed_nid') + ->condition('id', $id) + ->execute(); + foreach ($rows as $row) { feeds_source($id, $row->feed_nid)->schedule(); } } @@ -396,7 +399,7 @@ function feeds_nodeapi(&$node, $op, $form) { function _feeds_nodeapi_node_processor($node, $op) { switch ($op) { case 'load': - if ($result = db_fetch_object(db_query("SELECT imported, guid, url, feed_nid FROM {feeds_node_item} WHERE nid = %d", $node->nid))) { + if ($result = db_query("SELECT imported, guid, url, feed_nid FROM {feeds_node_item} WHERE nid = :nid", array(':nid' => $node->nid))->fetch()) { $node->feeds_node_item = $result; } break; @@ -414,7 +417,9 @@ function _feeds_nodeapi_node_processor($node, $op) { break; case 'delete': if (isset($node->feeds_node_item)) { - db_query("DELETE FROM {feeds_node_item} WHERE nid = %d", $node->nid); + db_delete('feeds_node_item') + ->condition('nid', $node->nid) + ->execute(); } break; } @@ -427,11 +432,15 @@ function feeds_taxonomy($op = NULL, $type = NULL, $term = NULL) { if ($type =='term' && $term['tid']) { switch ($op) { case 'delete': - db_query("DELETE FROM {feeds_term_item} WHERE tid = %d", $term['tid']); + db_delete('feeds_term_item') + ->condition('tid', $term['tid']) + ->execute(); break; case 'update': if (isset($term['importer_id'])) { - db_query("DELETE FROM {feeds_term_item} WHERE tid = %d", $term['tid']); + db_delete('feeds_term_item') + ->condition('tid', $term['tid']) + ->execute(); } case 'insert': if (isset($term['importer_id'])) { diff --git a/includes/FeedsImporter.inc b/includes/FeedsImporter.inc index 57d0e01e96b17ec47d72d70675642f817242cf9f..f868496e07d1ad7da081a2c50bb0f48044003bec 100644 --- a/includes/FeedsImporter.inc +++ b/includes/FeedsImporter.inc @@ -129,7 +129,9 @@ class FeedsImporter extends FeedsConfigurable { * from database, does not delete configuration itself. */ public function delete() { - db_query("DELETE FROM {feeds_importer} WHERE id = '%s'", $this->id); + db_delete('feeds_importer') + ->condition('id', $this->id) + ->execute(); $job = array( 'callback' => 'feeds_importer_expire', 'type' => $this->id, diff --git a/includes/FeedsSource.inc b/includes/FeedsSource.inc index b6f2a89be98b1760db4ae9cbab4adb889e61d1ac..eff59e052d946c5399baa328f22670574f976538 100644 --- a/includes/FeedsSource.inc +++ b/includes/FeedsSource.inc @@ -276,7 +276,10 @@ class FeedsSource extends FeedsConfigurable { foreach ($this->importer->plugin_types as $type) { $this->importer->$type->sourceDelete($this); } - db_query("DELETE FROM {feeds_source} WHERE id = '%s' AND feed_nid = %d", $this->id, $this->feed_nid); + db_delete('feeds_source') + ->condition('id', $this->id) + ->condition('feed_nid', $this->feed_nid) + ->execute(); // Remove from schedule. $job = array( 'callback' => 'feeds_source_import', diff --git a/plugins/FeedsHTTPFetcher.inc b/plugins/FeedsHTTPFetcher.inc index 46b71112a2a93620816bf0401901a7fc0b3edb93..f17aaff707e10a16abb9a21180c946cfca935d1f 100644 --- a/plugins/FeedsHTTPFetcher.inc +++ b/plugins/FeedsHTTPFetcher.inc @@ -258,7 +258,10 @@ class PuSHSubscription implements PuSHSubscriptionInterface { * Delete a subscription. */ public function delete() { - db_query("DELETE FROM {feeds_push_subscriptions} WHERE domain = '%s' AND subscriber_id = %d", $this->domain, $this->subscriber_id); + db_delete('feeds_push_subscriptions') + ->condition('domain', $this->domain) + ->condition('subscriber_id', $this->subscriber_id) + ->execute(); } } diff --git a/plugins/FeedsNodeProcessor.inc b/plugins/FeedsNodeProcessor.inc index 7b09570a76f33a0b2337b61046715d4f9cab91b5..7cfc4813d13caa269eec10e1a0486add7fd0e1d0 100644 --- a/plugins/FeedsNodeProcessor.inc +++ b/plugins/FeedsNodeProcessor.inc @@ -91,7 +91,7 @@ class FeedsNodeProcessor extends FeedsProcessor { } $result = db_query_range("SELECT nid FROM {feeds_node_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE)); while ($node = db_fetch_object($result)) { - _feeds_node_delete($node->nid); + node_delete($node->nid); $batch->deleted++; } if (db_result(db_query_range("SELECT nid FROM {feeds_node_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid, 0, 1))) { @@ -406,30 +406,3 @@ class FeedsNodeProcessor extends FeedsProcessor { return ''; } } - -/** - * Copy of node_delete() that circumvents node_access(). - * - * Used for batch deletion. - */ -function _feeds_node_delete($nid) { - - $node = node_load($nid); - - db_query("DELETE FROM {node} WHERE nid = %d", $node->nid); - db_query("DELETE FROM {node_revisions} WHERE nid = %d", $node->nid); - - // Call the node-specific callback (if any): - node_invoke($node, 'delete'); - node_invoke_nodeapi($node, 'delete'); - - // Clear the page and block caches. - cache_clear_all(); - - // Remove this node from the search index if needed. - if (function_exists('search_wipe')) { - search_wipe($node->nid, 'node'); - } - watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title)); - drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title))); -}