From 66b9366ba1d120f15b1cbe5aa9394863a07691e5 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Wed, 24 Oct 2012 14:24:00 -0400
Subject: [PATCH] Resolving VUFIND-628 (Facets out of order when shown by
 multiple recommendation modules).

---
 module/VuFind/src/VuFind/Search/Solr/Results.php | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/module/VuFind/src/VuFind/Search/Solr/Results.php b/module/VuFind/src/VuFind/Search/Solr/Results.php
index 232e2a9fe90..cdcb1b88086 100644
--- a/module/VuFind/src/VuFind/Search/Solr/Results.php
+++ b/module/VuFind/src/VuFind/Search/Solr/Results.php
@@ -411,11 +411,12 @@ class Results extends BaseResults
         }
 
         // Loop through every field returned by the result set
-        $validFields = array_keys($filter);
-        foreach ($this->rawResponse['facet_counts']['facet_fields']
-                 as $field => $data) {
-            // Skip filtered fields and empty arrays:
-            if (!in_array($field, $validFields) || count($data) < 1) {
+        foreach (array_keys($filter) as $field) {
+            $data = isset($this->rawResponse['facet_counts']['facet_fields'][$field])
+                ? $this->rawResponse['facet_counts']['facet_fields'][$field]
+                : array();
+            // Skip empty arrays:
+            if (count($data) < 1) {
                 continue;
             }
             // Initialize the settings for the current field
-- 
GitLab