Merge pull request #8739 from annando/issue-8732

Issue 8732: Fix fetch saved searches
This commit is contained in:
Hypolite Petovan 2020-06-06 15:21:38 -04:00 committed by GitHub
commit b1e6a4e499
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,12 +36,9 @@ class SavedSearches
*/ */
public static function getHTML($return_url, $search = '') public static function getHTML($return_url, $search = '')
{ {
$o = '';
$saved_searches = DBA::select('search', ['id', 'term'], ['uid' => local_user()]);
if (DBA::isResult($saved_searches)) {
$saved = []; $saved = [];
foreach ($saved_searches as $saved_search) { $saved_searches = DBA::select('search', ['id', 'term'], ['uid' => local_user()]);
while ($saved_search = DBA::fetch($saved_searches)) {
$saved[] = [ $saved[] = [
'id' => $saved_search['id'], 'id' => $saved_search['id'],
'term' => $saved_search['term'], 'term' => $saved_search['term'],
@ -51,10 +48,15 @@ class SavedSearches
'selected' => $search == $saved_search['term'], 'selected' => $search == $saved_search['term'],
]; ];
} }
DBA::close($saved_searches);
if (empty($saved)) {
return '';
}
$tpl = Renderer::getMarkupTemplate('widget/saved_searches.tpl'); $tpl = Renderer::getMarkupTemplate('widget/saved_searches.tpl');
$o = Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [
'$title' => DI::l10n()->t('Saved Searches'), '$title' => DI::l10n()->t('Saved Searches'),
'$add' => '', '$add' => '',
'$searchbox' => '', '$searchbox' => '',
@ -62,7 +64,4 @@ class SavedSearches
'$return_url' => urlencode($return_url), '$return_url' => urlencode($return_url),
]); ]);
} }
return $o;
}
} }