diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 1b0ab98..5f49b94 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -547,7 +547,11 @@ function forum_field_storage_pre_insert($entity_type, $entity, &$skip_fields) { function forum_field_storage_pre_update($entity_type, $entity, &$skip_fields) { $first_call = &drupal_static(__FUNCTION__, array()); - if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) { + if ($entity_type == 'node' && _forum_node_check_node_type($entity)) { + + // If the node is published, update the forum index. + if ($entity->status) { + // We don't maintain data for old revisions, so clear all previous values // from the table. Since this hook runs once per field, per object, make // sure we only wipe values once. @@ -574,6 +578,13 @@ function forum_field_storage_pre_update($entity_type, $entity, &$skip_fields) { // call _forum_update_forum_index() too. _forum_update_forum_index($entity->nid); } + + // When a forum node is unpublished, remove it from the forum_index table. + else { + db_delete('forum_index')->condition('nid', $entity->nid)->execute(); + } + + } } /**