I get a PDOException error for a bad integer value under Postgresql when deleting nodes.

I've tracked down the error, to the following -- sorry I don't have the means at the moment to roll a proper patch. The problem is the return value from entity_extract_ids() is not what the code is expecting.

Here's a working version of the function in question. The only bit I'm not sure about is if _votingapi_delete_cache_by_entity() and _votingapi_delete_votes_by_entity() should also receive the vid, but I'll leave that to the experts to figure out.

/**
 * Implements hook_entity_delete().
 *
 * Delete all votes and cache entries for the deleted entities
 */
function votingapi_entity_delete($entity, $type) {
  $ids = entity_extract_ids($type, $entity);
  /*
  *  returns
  *   A numerically indexed array (not a hash table) containing these
  *   elements:
  *   0: primary id of the entity
  *   1: revision id of the entity, or NULL if $entity_type is not versioned
  *   2: bundle name of the entity
  */
  $id = $ids[0];
  _votingapi_delete_cache_by_entity(array($id), $type);
  _votingapi_delete_votes_by_entity(array($id), $type);
}

Comments

torotil’s picture

Status: Active » Fixed

Fixed with http://drupalcode.org/project/votingapi.git/commit/3e6f6a7 in 7.x-2.x. Thanks for posting your fix!

Status: Fixed » Closed (fixed)

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