mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 10:32:44 +08:00
Fix bug causing wrong index to be returned
This commit is contained in:
parent
9ea482254c
commit
3c53e512de
|
@ -1,6 +1,5 @@
|
|||
<?php namespace Flarum\Api\Actions\Posts;
|
||||
|
||||
use Flarum\Core\Repositories\PostRepositoryInterface;
|
||||
use Flarum\Core\Models\User;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
|
||||
|
|
|
@ -96,8 +96,11 @@ class EloquentPostRepository implements PostRepositoryInterface
|
|||
->from('posts')
|
||||
->where('discussion_id', $discussionId)
|
||||
->whereNotNull('number')
|
||||
->orderByRaw('ABS(CAST(number AS SIGNED) - ?)', [$number])
|
||||
->take(1);
|
||||
->take(1)
|
||||
|
||||
// We don't add $number as a binding because for some
|
||||
// reason doing so makes the bindings go out of order.
|
||||
->orderByRaw('ABS(CAST(number AS SIGNED) - '.(int) $number.')')
|
||||
});
|
||||
|
||||
return $this->scopeVisibleForUser($query, $user)->count();
|
||||
|
|
Loading…
Reference in New Issue
Block a user