Download & Extend

Avoid one query during nodeapi for insert/update/delete operations

Project:Tracker 2
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

During nodeapi for insert/update operations, _tracker2_add() is invoked to record tracker data, and here the {node} table is queries to obtain the node status. However, this is already available from the $node object passed to nodeapi, so this query is not really required in that case.

I think $node->status could be passed as an additional argument to _tracker2_add(), and perform the query against the {node} table, only when the $status argument is not passed.

Comments

#1

Title:Avoid one query during nodeapi for insert/update operations» Avoid one query during nodeapi for insert/update/delete operations

hmm... and the same logic could also be applied to _tracker2_remove(). When invoked from nodeapi('delete'), $node->status could be passed as an additional argument, and this could be used to avoid a query in _tracker2_remove() because when $status would be passed to _tracker2_remove() that means the node is being deleted, so there's no need to check if it exists.

[EDIT] In fact, during nodeapi('delete') there's no need to invoke _tracker2_remove() because the following is enough, I think:

<?php
  db_query
("DELETE FROM {tracker2_node} WHERE nid = %d", $node->nid);
 
db_query("DELETE FROM {tracker2_user} WHERE nid = %d", $node->nid);
?>

So here we can save a query to the {node} table, and an invocation to _tracker2_remove(). :)

nobody click here