Skip to content

Instantly share code, notes, and snippets.

@orakili
Created July 25, 2011 01:25
Show Gist options
  • Save orakili/1103357 to your computer and use it in GitHub Desktop.
Save orakili/1103357 to your computer and use it in GitHub Desktop.
#962664 - Taxonomy Index for unpublished entities
diff --git modules/taxonomy/taxonomy.module modules/taxonomy/taxonomy.module
index 45639a1..a6ee42c 100644
--- modules/taxonomy/taxonomy.module
+++ modules/taxonomy/taxonomy.module
@@ -1619,8 +1619,10 @@ function taxonomy_field_presave($entity_type, $entity, $field, $instance, $langc
function taxonomy_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
// We maintain a denormalized table of term/node relationships, containing
// only data for current, published nodes.
- if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) {
- _taxonomy_field_save_index($entity, $items);
+ if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') {
+ if ($entity->status || variable_get('taxonomy_index_unpublished', FALSE)) {
+ _taxonomy_field_save_index($entity, $items);
+ }
}
}
@@ -1639,7 +1641,7 @@ function taxonomy_field_update($entity_type, $entity, $field, $instance, $langco
db_delete('taxonomy_index')->condition('nid', $entity->nid)->execute();
}
// Only save data to the table if the node is published.
- if ($entity->status) {
+ if ($entity->status || variable_get('taxonomy_index_unpublished', FALSE)) {
_taxonomy_field_save_index($entity, $items);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment