Commit e33ede0f authored by webchick's avatar webchick

Issue #2195915 by larowlan, andypost, jhodgdon: Cannot save text filter config...

Issue #2195915 by larowlan, andypost, jhodgdon: Cannot save text filter config using PostgreSQL if Comment is enabled [blocks installation!].
parent 1bc1da80
......@@ -950,17 +950,25 @@ function comment_entity_insert(EntityInterface $entity) {
* Implements hook_entity_predelete().
*/
function comment_entity_predelete(EntityInterface $entity) {
$cids = db_select('comment', 'c')
->fields('c', array('cid'))
->condition('entity_id', $entity->id())
->condition('entity_type', $entity->getEntityTypeId())
->execute()
->fetchCol();
entity_delete_multiple('comment', $cids);
db_delete('comment_entity_statistics')
->condition('entity_id', $entity->id())
->condition('entity_type', $entity->getEntityTypeId())
->execute();
// Entities can have non-numeric IDs, but {comment} and
// {comment_entity_statistics} tables have integer columns for entity ID, and
// PostgreSQL throws exceptions if you attempt query conditions with
// mismatched types. So, we need to verify that the ID is numeric (even for an
// entity type that has an integer ID, $entity->id() might be a string
// containing a number), and then cast it to an integer when querying.
if ($entity->getEntityType()->isFieldable() && is_numeric($entity->id())) {
$cids = db_select('comment', 'c')
->fields('c', array('cid'))
->condition('entity_id', (int) $entity->id())
->condition('entity_type', $entity->getEntityTypeId())
->execute()
->fetchCol();
entity_delete_multiple('comment', $cids);
db_delete('comment_entity_statistics')
->condition('entity_id', (int) $entity->id())
->condition('entity_type', $entity->getEntityTypeId())
->execute();
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment