[DB] Fix uses of `DB::sql`, to remove the deprecated second `entities` parameter

This commit is contained in:
Hugo Sales 2021-11-08 20:21:41 +00:00
parent 767b2035e7
commit f0c532340e
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 19 additions and 18 deletions

View File

@ -100,7 +100,7 @@ class Network extends Controller
note.scope <> {$this->message_scope} note.scope <> {$this->message_scope}
order by note.modified DESC order by note.modified DESC
END; END;
$notes = DB::sql($query, ['note' => 'App\Entity\Note'], ['target_actor_id' => $target->getId()]); $notes = DB::sql($query, ['target_actor_id' => $target->getId()]);
$notes_out = null; $notes_out = null;
Event::handle('FormatNoteList', [$notes, &$notes_out]); Event::handle('FormatNoteList', [$notes, &$notes_out]);

View File

@ -162,16 +162,16 @@ class Note extends Entity
return $this->conversation; return $this->conversation;
} }
/* public function setRepeatOf(?int $repeat_of): self /* public function setRepeatOf(?int $repeat_of): self
{ {
$this->repeat_of = $repeat_of; $this->repeat_of = $repeat_of;
return $this; return $this;
} }
public function getRepeatOf(): ?int public function getRepeatOf(): ?int
{ {
return $this->repeat_of; return $this->repeat_of;
}*/ }*/
public function setScope(int $scope): self public function setScope(int $scope): self
{ {
@ -251,14 +251,15 @@ class Note extends Entity
return Avatar::getAvatarUrl($this->getActorId(), $size); return Avatar::getAvatarUrl($this->getActorId(), $size);
} }
public static function getAllNotes(int $noteScope): array public static function getAllNotes(int $note_scope): array
{ {
return DB::sql( return DB::sql(
'select * from note n ' <<<'EOF'
. 'where n.reply_to is null and (n.scope & :notescope) <> 0 ' select * from note n
. 'order by n.created DESC', where (n.scope & :notescope) <> 0
['n' => 'App\Entity\Note'], order by n.created DESC
['notescope' => $noteScope], EOF,
['notescope' => $note_scope],
); );
} }
@ -361,7 +362,7 @@ class Note extends Entity
'note_created_id_is_local_idx' => ['created', 'is_local'], 'note_created_id_is_local_idx' => ['created', 'is_local'],
'note_actor_created_idx' => ['actor_id', 'created'], 'note_actor_created_idx' => ['actor_id', 'created'],
'note_is_local_created_actor_idx' => ['is_local', 'created', 'actor_id'], 'note_is_local_created_actor_idx' => ['is_local', 'created', 'actor_id'],
// 'note_repeat_of_created_idx' => ['repeat_of', 'created'], 'note_repeat_of_created_idx' => ['repeat_of', 'created'],
'note_conversation_created_idx' => ['conversation', 'created'], 'note_conversation_created_idx' => ['conversation', 'created'],
'note_reply_to_idx' => ['reply_to'], 'note_reply_to_idx' => ['reply_to'],
], ],

View File

@ -44,7 +44,7 @@ class DBTest extends GNUsocialTestCase
public function testSql() public function testSql()
{ {
static::bootKernel(); static::bootKernel();
$actor = DB::sql('select {select} from actor a where a.nickname = :nickname', ['a' => 'App\Entity\Actor'], ['nickname' => 'taken_user']); $actor = DB::sql('select {select} from actor a where a.nickname = :nickname', ['nickname' => 'taken_user']);
static::assertIsArray($actor); static::assertIsArray($actor);
static::assertTrue($actor[0] instanceof Actor); static::assertTrue($actor[0] instanceof Actor);
} }