API page: http://api.drupal.org/api/drupal/modules--node--node.api.php/function/ho...

Describe the problem you have found:

Documentation reads:

function hook_delete($node) {
  db_delete('mytable')
    ->condition('nid', $nid->nid)
    ->execute();
} 

Should read:

function hook_delete($node) {
  db_delete('mytable')
    ->condition('nid', $node->nid)
    ->execute();
} 

$nid->nid needs to be changed to $node->nid.

CommentFileSizeAuthor
#2 hook_delete-1205882-2.patch377 bytesPsikik

Comments

jhodgdon’s picture

Title: Documentation problem with hook_delete » hook_delete function body has typo
Version: 7.x-dev » 8.x-dev
Issue tags: +Novice, +Needs backport to D7

Good catch, thanks for reporting this! Quick patch to make for someone...

Psikik’s picture

Status: Active » Needs review
Issue tags: -Needs backport to D7
StatusFileSize
new377 bytes

Here's the patch for 8.x

I was also checking to apply this to 7.x, but the function seems to be correct in the 7.x branch. So removing backport tag.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

Thanks, the patch looks good. I believe it needs to be applied to both D7 and D8. D6 is fine.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

nice catch!

Committed and pushed to 7.x and 8.x. Thanks!

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