I deleted a notebook page from our Open Atrium site and got this warning:

user warning: Table 'cgraphics.projects_time_tracker_timer' doesn't exist query: DELETE FROM projects_time_tracker_timer WHERE nid = 5331 in /home/projects/public_html/sites/all/modules/time_tracker/time_tracker.module on line 609.

Time tracking was not enabled on our notebook content type.

CommentFileSizeAuthor
#3 time_node_delete.patch716 byteschertzog

Comments

deekayen’s picture

It might also help to note the database is named cgraphics, the table prefix is projects_.

drclaw’s picture

Hmmm... That's a strange bug... I'll take a look.

chertzog’s picture

StatusFileSize
new716 bytes

Yeah, line 608 of time_tracker.module:

>
function time_tracker_nodeapi(&$node, $op) {
...
      case 'delete':
        db_query("DELETE FROM {time_tracker_entry} WHERE nid = %d", $node->nid);
        db_query("DELETE FROM {time_tracker_timer} WHERE nid = %d", $node->nid);
      break;

I would think that we should probably wrap that in a module_exists('time_tracker_timer'). And while we are at it probably check time_estimate as well.

>
function time_tracker_nodeapi(&$node, $op) {
...
      case 'delete':
        db_query("DELETE FROM {time_tracker_entry} WHERE nid = %d", $node->nid);
        if (module_exists('time_tracker_timer')){
          db_query("DELETE FROM {time_tracker_timer} WHERE nid = %d", $node->nid);
        }
        elseif (module_exists('time_estimate') {
          db_query("DELETE FROM {time_estimate_entry} WHERE nid = %d", $node->nid);
        }
      break;

Attached is a patch.

drclaw’s picture

Hmmm.... I should probably port that over to D6 as well...

chertzog’s picture

Yeah, the patch in #3 is against the D6 dev. I should probably put something like this in for D7.

drclaw’s picture

I see. Nice one.

chertzog’s picture

I am in the process of adding this to D7, and noticed i missed a parenthesis in the second module_exists

elseif (module_exists('time_estimate') {

should be

elseif (module_exists('time_estimate')) {
drclaw’s picture

Status: Active » Fixed

I think it makes more sense to add the deletes to their respective module's nodeapi implementations. In fact, the time_estimate module actually already had a delete case for nodes. I just had to add it to the time_tracker_timer module. Fix is pushed to dev branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.