diff --git a/feeds.module b/feeds.module index ecf5f9b688de645f45a9e0c0860987dc12a867c8..db99305d2db615b70ff9cd0ec1dfefdf3df8767d 100644 --- a/feeds.module +++ b/feeds.module @@ -325,8 +325,8 @@ function feeds_feeds_plugins() { /** * Implements hook_node_load(). */ -function feeds_node_load($node) { - _feeds_node_processor_node_load($node); +function feeds_node_load($nodes) { + _feeds_node_processor_node_load($nodes); } /** @@ -424,9 +424,11 @@ function feeds_node_delete($node) { /** * FeedsNodeProcessor's hook_node_load(). */ -function _feeds_node_processor_node_load($node) { - 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; +function _feeds_node_processor_node_load($nodes) { + if ($items = db_query("SELECT nid, imported, guid, url, feed_nid FROM {feeds_node_item} WHERE nid IN nids(:nids)", array(':nids' => array_keys($nodes)))) { + foreach ($items as $item) { + $node->{$item->nid} = $item; + } } } @@ -488,6 +490,48 @@ function feeds_taxonomy($op = NULL, $type = NULL, $term = NULL) { } } +/** + * Implements hook_taxonomy_term_update(). + */ +function feeds_taxonomy_term_update($term) { + if (isset($term->feeds_importer_id)) { + db_delete('feeds_term_item') + ->condition('tid', $term->tid) + ->execute(); + } +} + +/** + * Implements hook_taxonomy_term_insert(). + */ +function feeds_taxonomy_term_insert($term) { + if ($term->feeds_importer_id) { + $record = array( + 'id' => $term->feeds_importer_id, + 'tid' => $term->tid, + ); + drupal_write_record('feeds_term_item', $record); + } +} + +/** + * Implements hook_taxonomy_term_delete(). + */ +function feeds_taxonomy_term_delete($term) { + db_delete('feeds_term_item') + ->condition('tid', $term->tid) + ->execute(); +} + +/** + * Implements hook_taxonomy_delete(). + */ +function feeds_taxonomy_term_delete($term) { + db_delete('feeds_term_item') + ->condition('tid', $term->tid) + ->execute(); +} + /** * Implements hook_form_alter(). */ diff --git a/plugins/FeedsTermProcessor.inc b/plugins/FeedsTermProcessor.inc index 1ff82d7d747714b214c29642874de44ba2146d9d..8bc9787e2ab2f462381580d94ceaa93080610c54 100644 --- a/plugins/FeedsTermProcessor.inc +++ b/plugins/FeedsTermProcessor.inc @@ -47,7 +47,7 @@ class FeedsTermProcessor extends FeedsProcessor { } // Save the term. - $term['importer_id'] = $this->id; + $term['feeds_importer_id'] = $this->id; $term['feed_nid'] = $this->feed_nid; taxonomy_save_term($term); if ($tid) {