I get the following error when I delete a node.

notice: Undefined variable: gid in _node_gallery_delete() (line 815 of /public_html/sites/all/modules/node_gallery/node_gallery.module).

It is in the function _node_gallery_delete(&$node) and the actual line that calls it is
node_gallery_clear_gallery_caches($gid);

I think the simple answer would be to set $gid to NULL unless there is a reason to set it to something else because everything in the function is in if statements except clearing the cache.

The other solution would be to move the statement into the either or both if statements.

function _node_gallery_delete(&$node) {
+  $gid = NULL;
  if (in_array($node->type, (array)node_gallery_get_types('gallery'))) {
    $gid = $node->nid;
    $imagenids = node_gallery_get_image_nids($gid, FALSE, FALSE, TRUE);
    $total = count($imagenids);
    // Split our operations into X deletes at a time
    while (count($imagenids) > 0) {
      if (count($imagenids) >= NODE_GALLERY_BATCH_DELETE) {
        $nids = array_splice($imagenids, 0, 10);
      }
      else {
        $nids = $imagenids;
        unset($imagenids);
      }
      $operations[] = array('node_gallery_image_delete_process', array($nids));
    }
    if (!empty($operations)) {
      $batch = array(
        'operations' => $operations,
        'finished' => 'node_gallery_image_process_finished',
        'title' => t('Processing Gallery Delete.'),
        'init_message' => t('Gallery deletion is cascading to images.'),
        'progress_message' => t('Processing image deletions.'),
        'error_message' => t('Gallery deletion has encountered an error.'),
      );

      batch_set($batch);
    }
    node_gallery_delete_gallery($node);
  }
  if (in_array($node->type, (array)node_gallery_get_types('image'))) {
    $gid = $node->gid;
    node_gallery_delete_image($node);
  }
  node_gallery_clear_gallery_caches($gid);
}

Comments

zengenuity’s picture

Status: Fixed » Closed (fixed)

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