[Autocomplete] Fix postgres incompatible query in AutocompleteAction

This commit is contained in:
susdiv 2020-06-05 19:14:37 +00:00
parent 684675bd84
commit 97bddc4537

View File

@ -104,12 +104,13 @@ class AutocompleteAction extends Action
if(substr($term,0,1)=='@'){ if(substr($term,0,1)=='@'){
//profile search //profile search
$term=substr($term,1); $term=substr($term,1);
$user_table = common_database_tablename('user');
$profile = new Profile(); $profile = new Profile();
$profile->limit($limit); $profile->limit($limit);
$profile->whereAdd('nickname like \'' . trim($profile->escape($term), '\'') . '%\''); $profile->whereAdd('nickname like \'' . trim($profile->escape($term), '\'') . '%\'');
$profile->whereAdd(sprintf('id in (SELECT id FROM user) OR ' $profile->whereAdd(sprintf('id in (SELECT id FROM %s) OR '
. 'id in (SELECT subscribed from subscription' . 'id in (SELECT subscribed from subscription'
. ' where subscriber = %d)', $this->scoped->id)); . ' where subscriber = %d)', $user_table, $this->scoped->id));
if ($profile->find()) { if ($profile->find()) {
while($profile->fetch()) { while($profile->fetch()) {
$this->profiles[]=clone($profile); $this->profiles[]=clone($profile);