mirror of
https://github.com/flarum/framework.git
synced 2025-05-11 16:52:37 +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;
|
<?php namespace Flarum\Api\Actions\Posts;
|
||||||
|
|
||||||
use Flarum\Core\Repositories\PostRepositoryInterface;
|
|
||||||
use Flarum\Core\Models\User;
|
use Flarum\Core\Models\User;
|
||||||
use Flarum\Api\Actions\ApiParams;
|
use Flarum\Api\Actions\ApiParams;
|
||||||
|
|
||||||
|
@ -96,8 +96,11 @@ class EloquentPostRepository implements PostRepositoryInterface
|
|||||||
->from('posts')
|
->from('posts')
|
||||||
->where('discussion_id', $discussionId)
|
->where('discussion_id', $discussionId)
|
||||||
->whereNotNull('number')
|
->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();
|
return $this->scopeVisibleForUser($query, $user)->count();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user