From aef88feddafd16f70b9534f12e3fd8401b56c860 Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Tue, 15 Nov 2016 10:44:08 +0200
Subject: [PATCH] Missing current view model should not cause Piwik helper to
 fail.

---
 module/VuFind/src/VuFind/View/Helper/Root/Piwik.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php
index db7ea75626a..beca5b60912 100644
--- a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php
+++ b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php
@@ -266,7 +266,11 @@ class Piwik extends \Zend\View\Helper\AbstractHelper
     protected function getCombinedSearchResults()
     {
         $viewModel = $this->getView()->plugin('view_model');
-        $children = $viewModel->getCurrent()->getChildren();
+        $current = $viewModel->getCurrent();
+        if (null === $current) {
+            return null;
+        }
+        $children = $current->getChildren();
         if (isset($children[0])) {
             $results = $children[0]->getVariable('combinedResults');
             if (is_array($results)) {
-- 
GitLab