diff --git a/config/vufind/HierarchyDefault.ini b/config/vufind/HierarchyDefault.ini index b342201180ded87e1098e783611fa844fd9471e5..e2b00196c47af1f367622eea42a6321af43a98b4 100644 --- a/config/vufind/HierarchyDefault.ini +++ b/config/vufind/HierarchyDefault.ini @@ -27,4 +27,13 @@ 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. Without this setting, if a referenced parent_id +; or top_id does not exist the frontend will show HierarchyTree layout-elements +; but will hang on actually building the HierarchyTree. If you know this will +; never happen in your instance (i.e. all hierarchy elements are always retrievable +; from the Solr index under all conditions -- usually the case unless you have +; conditional filters), you can turn this off for a slight performance gain. +; (default = true) +checkAvailability = true \ No newline at end of file diff --git a/config/vufind/HierarchyFlat.ini b/config/vufind/HierarchyFlat.ini index eb7b46355284df6e556d93d76dda479cfda1be10..c758be179d640023dacbbb6ca42de46941cb2ba6 100644 --- a/config/vufind/HierarchyFlat.ini +++ b/config/vufind/HierarchyFlat.ini @@ -24,3 +24,12 @@ 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. Without this setting, if a referenced parent_id +; or top_id does not exist the frontend will show HierarchyTree layout-elements +; but will hang on actually building the HierarchyTree. If you know this will +; never happen in your instance (i.e. all hierarchy elements are always retrievable +; from the Solr index under all conditions -- usually the case unless you have +; conditional filters), you can turn this off for a slight performance gain. +; (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 4ec56b1c7035427b3f6f1d6f24d53337d8d1d9e6..6e6ec3cd94aacb508782388c4c4bc4f6ccd3339b 100644 --- a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php +++ b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php @@ -349,7 +349,17 @@ class Solr extends AbstractBase */ public function supports($id) { - // Assume all IDs are supported. + $settings = $this->hierarchyDriver->getTreeSettings(); + + if (!isset($settings['checkAvailability']) || $settings['checkAvailability']==1) { + $results = $this->searchService->retrieve( + 'Solr', $id, new ParamBag(array('fq' => $this->filters)) + ); + if ($results->getTotal() < 1) { + return false; + } + } + // If we got this far the support-check was positive in any case. return true; } } diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php index c2ebd31474fa487d98b0200780e69da7bf688e24..f2f5f0e7d83468bb4bc048287f1be9f2fcc7f516 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php @@ -462,27 +462,31 @@ class UtilController extends AbstractBase "\tBuilding tree for " . $recordid . '... ' . number_format($count) . ' records' ); - $driver = $recordLoader->load($recordid); - // Only do this if the record is actually a hierarchy type record - if ($driver->getHierarchyType()) { - // JSON - if (!$this->consoleOpts->getOption('skip-json')) { - Console::writeLine("\t\tJSON cache..."); - $driver->getHierarchyDriver()->getTreeSource()->getJSON( - $recordid, array('refresh' => true) - ); - } else { - Console::writeLine("\t\tJSON skipped."); - } - // XML - if (!$this->consoleOpts->getOption('skip-xml')) { - Console::writeLine("\t\tXML cache..."); - $driver->getHierarchyDriver()->getTreeSource()->getXML( - $recordid, array('refresh' => true) - ); - } else { - Console::writeLine("\t\tXML skipped."); + try { + $driver = $recordLoader->load($recordid); + // Only do this if the record is actually a hierarchy type record + if ($driver->getHierarchyType()) { + // JSON + if (!$this->consoleOpts->getOption('skip-json')) { + Console::writeLine("\t\tJSON cache..."); + $driver->getHierarchyDriver()->getTreeSource()->getJSON( + $recordid, array('refresh' => true) + ); + } else { + Console::writeLine("\t\tJSON skipped."); + } + // XML + if (!$this->consoleOpts->getOption('skip-xml')) { + Console::writeLine("\t\tXML cache..."); + $driver->getHierarchyDriver()->getTreeSource()->getXML( + $recordid, array('refresh' => true) + ); + } else { + Console::writeLine("\t\tXML skipped."); + } } + } catch (\VuFind\Exception\RecordMissing $e) { + Console::writeLine("WARNING! - Caught exception: " . $e->getMessage() . "\n"); } } Console::writeLine( @@ -554,4 +558,4 @@ class UtilController extends AbstractBase Console::writeLine(str_replace('%%count%%', $count, $successString)); return $this->getSuccessResponse(); } -} \ No newline at end of file +}