From 59b07e29fa2edcc81c7a071bef2600936f047bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lahmann?= <lahmann@ub.uni-leipzig.de> Date: Tue, 27 Jan 2015 17:06:13 +0100 Subject: [PATCH] refs #4577: * added check for availability of hierarchical parent to Solr-TreeDataSource * added configuration option for availability check to HierarchyTree inis --- config/vufind/HierarchyDefault.ini | 8 +++++++- config/vufind/HierarchyFlat.ini | 6 ++++++ .../src/VuFind/Hierarchy/TreeDataSource/Solr.php | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/config/vufind/HierarchyDefault.ini b/config/vufind/HierarchyDefault.ini index b342201180d..5c1f58595e4 100644 --- a/config/vufind/HierarchyDefault.ini +++ b/config/vufind/HierarchyDefault.ini @@ -27,4 +27,10 @@ fullHierarchyRecordView = true ; Filter queries filter what kind of children are displayed in the tree ; Note: The hidden filters from searches.ini are applied as well ; Note: Only applies when treeSource = Solr -;filterQueries[] = "-relsext.hasModel:\"DataModel\" AND -relsext.hasModel:\"ListCollection\"" \ No newline at end of file +;filterQueries[] = "-relsext.hasModel:\"DataModel\" AND -relsext.hasModel:\"ListCollection\"" +; Check whether the hierarchy_parent_id and hierarchy_top_id records are +; available in the index. If a referenced parent_id or top_id does not +; exist the frontend will show HierarchyTree layout-elements but will +; hang on acutally building the HierarchyTree. +; (default = true) +checkAvailability = true \ No newline at end of file diff --git a/config/vufind/HierarchyFlat.ini b/config/vufind/HierarchyFlat.ini index eb7b4635528..79de9e358df 100644 --- a/config/vufind/HierarchyFlat.ini +++ b/config/vufind/HierarchyFlat.ini @@ -24,3 +24,9 @@ show = false ; (true = show full hierarchy, false = only show path to current selected node, ; default = true) ;fullHierarchyRecordView = true +; Check whether the hierarchy_parent_id and hierarchy_top_id records are +; available in the index. If a referenced parent_id or top_id does not +; exist the frontend will show HierarchyTree layout-elements but will +; hang on acutally building the HierarchyTree. +; (default = true) +checkAvailability = true \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php index 87e25f6e0c7..058e89e08b1 100644 --- a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php +++ b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php @@ -228,6 +228,20 @@ class Solr extends AbstractBase */ public function supports($id) { + $settings = $this->hierarchyDriver->getTreeSettings(); + + if (isset($settings['checkAvailability']) && $settings['checkAvailability']==1) { + $query = new Query( + 'id:"' . addcslashes($id, '"') . '"' + ); + $results = $this->searchService->search( + 'Solr', $query, 0, 10000, + new ParamBag(array('fq' => $this->filters, 'hl' => 'false')) + ); + if ($results->getTotal() < 1) { + return false; + } + } // Assume all IDs are supported. return true; } -- GitLab