Commit 645da9ad8bbd4c7e4672cea26911f1705fa033df

Authored by jjordaan
1 parent d0a5bd30

KTS:4183 Cloud Tag filter error handled with empty search results, instead of DB error

Committed by: Jarrett Jordaan

Reviewed by: Megan Watson
plugins/tagcloud/TagCloudUtil.inc.php
... ... @@ -120,7 +120,10 @@ function get_relevant_tags($oUser, $sTag)
120 120  
121 121 $aDocIds = DBUtil::getResultArrayKey($aQuery, 'document_id');
122 122 $sDocs = implode(',', $aDocIds);
123   -
  123 + // Make sure user not opening a new window on tag cloud filters
  124 + if(!$sDocs) {
  125 + return array();
  126 + }
124 127 // Don't display tags that have already been selected.
125 128 $tagTree[] = $sTag;
126 129 $cnt = count($tagTree);
... ... @@ -135,7 +138,11 @@ function get_relevant_tags($oUser, $sTag)
135 138 WHERE DT.document_id in ($sDocs) AND TW.tag NOT IN ($sIgnoreTags)
136 139 GROUP BY TW.tag";
137 140  
138   - $tags = DBUtil::getResultArray(array($sQuery, $tagTree), null);
  141 + $tags = DBUtil::getResultArray(array($sQuery, $tagTree));
  142 +
  143 + if(PEAR::isError($tags)){
  144 + echo $tags->getMessage();
  145 + }
139 146  
140 147 // Add new tag to the session
141 148 if($sPrevTag != $sTag){
... ... @@ -144,13 +151,14 @@ function get_relevant_tags($oUser, $sTag)
144 151 }
145 152 }
146 153  
147   - // Create tag / frequency array
148 154 $aTags = array();
149   - foreach($tags as $tag)
150   - {
151   - $word=$tag['tag'];
152   - $freq=$tag['freq'];
153   - $aTags[$word] = $freq;
  155 + if($tags) {
  156 + foreach($tags as $tag)
  157 + {
  158 + $word=$tag['tag'];
  159 + $freq=$tag['freq'];
  160 + $aTags[$word] = $freq;
  161 + }
154 162 }
155 163  
156 164 return $aTags;
... ...