From b0e27c2f39e3627a2edbc38f5551ea128f0b49d1 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 14 Jun 2018 15:33:31 -0400
Subject: [PATCH] Fix bug: only Solr tags display in favorites. - We were
 overly aggressive in our default filtering behavior, so the tag list in the
 "My Favorites" area only showed Solr-related tags.

---
 module/VuFind/src/VuFind/Db/Row/User.php   | 14 +++++++-------
 module/VuFind/src/VuFind/Db/Table/Tags.php | 12 ++++++++----
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/module/VuFind/src/VuFind/Db/Row/User.php b/module/VuFind/src/VuFind/Db/Row/User.php
index a01db720d15..a0de0e5de28 100644
--- a/module/VuFind/src/VuFind/Db/Row/User.php
+++ b/module/VuFind/src/VuFind/Db/Row/User.php
@@ -237,12 +237,12 @@ class User extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface,
      * @param int    $listId     Filter for tags tied to a specific list (null for no
      * filter).
      * @param string $source     Filter for tags tied to a specific record source.
+     * (null for no filter).
      *
      * @return \Zend\Db\ResultSet\AbstractResultSet
      */
-    public function getTags($resourceId = null, $listId = null,
-        $source = DEFAULT_SEARCH_BACKEND
-    ) {
+    public function getTags($resourceId = null, $listId = null, $source = null)
+    {
         return $this->getDbTable('Tags')
             ->getForUser($this->id, $resourceId, $listId, $source);
     }
@@ -255,13 +255,13 @@ class User extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface,
      * for no filter).
      * @param int    $listId     Filter for tags tied to a specific list (null for no
      * filter).
-     * @param string $source     Filter for tags tied to a specific record source.
+     * @param string $source     Filter for tags tied to a specific record source
+     * (null for no filter).
      *
      * @return string
      */
-    public function getTagString($resourceId = null, $listId = null,
-        $source = DEFAULT_SEARCH_BACKEND
-    ) {
+    public function getTagString($resourceId = null, $listId = null, $source = null)
+    {
         $myTagList = $this->getTags($resourceId, $listId, $source);
         $tagStr = '';
         if (count($myTagList) > 0) {
diff --git a/module/VuFind/src/VuFind/Db/Table/Tags.php b/module/VuFind/src/VuFind/Db/Table/Tags.php
index 6512d925eef..c9c7ec672c0 100644
--- a/module/VuFind/src/VuFind/Db/Table/Tags.php
+++ b/module/VuFind/src/VuFind/Db/Table/Tags.php
@@ -272,12 +272,13 @@ class Tags extends Gateway
      * for no filter).
      * @param int    $listId     Filter for tags tied to a specific list (null for no
      * filter).
-     * @param string $source     Filter for tags tied to a specific record source.
+     * @param string $source     Filter for tags tied to a specific record source
+     * (null for no filter).
      *
      * @return \Zend\Db\ResultSet\AbstractResultSet
      */
     public function getForUser($userId, $resourceId = null, $listId = null,
-        $source = DEFAULT_SEARCH_BACKEND
+        $source = null
     ) {
         $callback = function ($select) use ($userId, $resourceId, $listId, $source) {
             $select->columns(
@@ -310,8 +311,11 @@ class Tags extends Gateway
                 ->equalTo(
                     'ur.list_id', 'rt.list_id',
                     Predicate::TYPE_IDENTIFIER, Predicate::TYPE_IDENTIFIER
-                )
-                ->equalTo('r.source', $source);
+                );
+            
+            if (null !== $source) {
+                $select->where->equalTo('r.source', $source);
+            }
 
             if (null !== $resourceId) {
                 $select->where->equalTo('r.record_id', $resourceId);
-- 
GitLab