mirror of
https://github.com/wallabag/wallabag.git
synced 2025-10-20 19:52:09 +00:00
Avoid error when a bad order
parameter is given
Only allowed parameter are asc & desc
This commit is contained in:
parent
a5e9a98aa3
commit
78e3fafa3f
3 changed files with 32 additions and 14 deletions
|
@ -142,7 +142,7 @@ class EntryRepository extends EntityRepository
|
|||
*
|
||||
* @return Pagerfanta
|
||||
*/
|
||||
public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '')
|
||||
public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'asc', $since = 0, $tags = '')
|
||||
{
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->leftJoin('e.tags', 't')
|
||||
|
@ -185,6 +185,10 @@ class EntryRepository extends EntityRepository
|
|||
}
|
||||
}
|
||||
|
||||
if (!\in_array(strtolower($order), ['asc', 'desc'], true)) {
|
||||
throw new \Exception('Order "' . $order . '" parameter is wrong, allowed: asc or desc');
|
||||
}
|
||||
|
||||
if ('created' === $sort) {
|
||||
$qb->orderBy('e.id', $order);
|
||||
} elseif ('updated' === $sort) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue