From 1585e7c7b2bccb2114856a05df3bd19b94834e3c Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Mon, 26 Aug 2013 13:21:43 -0400
Subject: [PATCH] Added maxLimit parameter to cap number of editions.

---
 module/VuFind/src/VuFind/Related/Editions.php | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/module/VuFind/src/VuFind/Related/Editions.php b/module/VuFind/src/VuFind/Related/Editions.php
index c6f5c6934f5..945a2503c98 100644
--- a/module/VuFind/src/VuFind/Related/Editions.php
+++ b/module/VuFind/src/VuFind/Related/Editions.php
@@ -59,17 +59,27 @@ class Editions implements RelatedInterface
      */
     protected $wcUtils;
 
+    /**
+     * Maximum limit
+     *
+     * @var int
+     */
+    protected $maxLimit;
+
     /**
      * Constructor
      *
-     * @param \VuFind\Search\Results\PluginManager $results Results plugin manager
-     * @param \VuFind\Connection\WorldCatUtils     $wcUtils WorldCat utils object
+     * @param \VuFind\Search\Results\PluginManager $results  Results plugin manager
+     * @param \VuFind\Connection\WorldCatUtils     $wcUtils  WorldCat utils object
+     * @param int                                  $maxLimit The maximum number of
+     * results to look up in Solr; set to -1 to use the "max boolean clauses" limit.
      */
     public function __construct(\VuFind\Search\Results\PluginManager $results,
-        \VuFind\Connection\WorldCatUtils $wcUtils
+        \VuFind\Connection\WorldCatUtils $wcUtils, $maxLimit = -1
     ) {
         $this->resultsManager = $results;
         $this->wcUtils = $wcUtils;
+        $this->maxLimit = $maxLimit;
     }
 
     /**
@@ -91,6 +101,9 @@ class Editions implements RelatedInterface
             $result = $this->resultsManager->get('Solr');
             $params = $result->getParams();
             $limit = $params->getQueryIDLimit();
+            if ($this->maxLimit > 0 && $limit > $this->maxLimit) {
+                $limit = $this->maxLimit;
+            }
             if (count($parts) > $limit) {
                 $parts = array_slice($parts, 0, $limit);
             }
-- 
GitLab