Skip to content
Snippets Groups Projects
Commit 681a5658 authored by Alex Barth's avatar Alex Barth
Browse files

Convert delete queries, some select queries, remove _feeds_node_delete() - not necessary anymore.

parent 476a3302
No related branches found
No related tags found
No related merge requests found
......@@ -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'])) {
......
......@@ -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,
......
......@@ -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',
......
......@@ -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();
}
}
......
......@@ -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)));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment