From cab3a9a9284ecb6bb42d191f72f15e3070d40b86 Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Sat, 19 Mar 2016 10:11:52 -0400
Subject: [PATCH] Only fetch unsaved searches by session id.

---
 module/VuFind/src/VuFind/Db/Table/Search.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/module/VuFind/src/VuFind/Db/Table/Search.php b/module/VuFind/src/VuFind/Db/Table/Search.php
index 5461163efe9..a397492448a 100644
--- a/module/VuFind/src/VuFind/Db/Table/Search.php
+++ b/module/VuFind/src/VuFind/Db/Table/Search.php
@@ -122,7 +122,7 @@ class Search extends Gateway
     public function getSearches($sid, $uid = null)
     {
         $callback = function ($select) use ($sid, $uid) {
-            $select->where->equalTo('session_id', $sid);
+            $select->where->equalTo('session_id', $sid)->and->equalTo('saved', 0);
             if ($uid != null) {
                 $select->where->OR->equalTo('user_id', $uid);
             }
@@ -223,7 +223,7 @@ class Search extends Gateway
                 ->equalTo('checksum', $checksum)
                 ->and
                 ->nest
-                ->equalTo('session_id', $sessionId);
+                ->equalTo('session_id', $sessionId)->and->equalTo('saved', 0);
             if (!empty($userId)) {
                 $nest->or->equalTo('user_id', $userId);
             }
-- 
GitLab