Issue 8732: Fix fetch aved searches

This commit is contained in:
Michael 2020-06-06 18:45:16 +00:00
parent b3c07fc726
commit d68372c872

View file

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