Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save orakili/5820243 to your computer and use it in GitHub Desktop.
Save orakili/5820243 to your computer and use it in GitHub Desktop.
Fix facet date granularity for the Drupal 7 search_api module version 1.6.
diff --git a/contrib/search_api_facetapi/plugins/facetapi/query_type_date.inc b/contrib/search_api_facetapi/plugins/facetapi/query_type_date.inc
index 7277b56..0610d83 100644
--- a/contrib/search_api_facetapi/plugins/facetapi/query_type_date.inc
+++ b/contrib/search_api_facetapi/plugins/facetapi/query_type_date.inc
@@ -204,9 +204,15 @@ class SearchApiFacetapiDate extends SearchApiFacetapiTerm implements FacetapiQue
}
// Adds parent information if not already set.
- if (NULL !== $parent && $parent != $new_value) {
- $build[$parent]['#item_children'][$new_value] = &$build[$new_value];
- $build[$new_value]['#item_parents'][$parent] = $parent;
+ if (NULL !== $parent) {
+ if ($parent != $new_value) {
+ $build[$parent]['#item_children'][$new_value] = &$build[$new_value];
+ $build[$new_value]['#item_parents'][$parent] = $parent;
+ }
+ // If the parent is the same as the value then it's the end.
+ else {
+ break;
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment