diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-01-09 23:29:30 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-01-09 23:31:14 +0100 |
commit | 3a2d4cf9fda87760c86320a7f8a5041d1d4256c6 (patch) | |
tree | e21e28b440f9318cd3fbb91043e40e0d725bbc5c /src/Wallabag/ApiBundle/Repository | |
parent | 4d0c632c70ea50d459c3c55ddda2e0f394dd51cb (diff) | |
download | wallabag-3a2d4cf9fda87760c86320a7f8a5041d1d4256c6.tar.gz wallabag-3a2d4cf9fda87760c86320a7f8a5041d1d4256c6.tar.zst wallabag-3a2d4cf9fda87760c86320a7f8a5041d1d4256c6.zip |
Cast client id to avoid PG error
If someone send a malformated client_id when trying to authenticate using the API we got a 500 if wallabag use postgres because the request send a string instead of an integer.
Diffstat (limited to 'src/Wallabag/ApiBundle/Repository')
-rw-r--r-- | src/Wallabag/ApiBundle/Repository/ClientRepository.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Wallabag/ApiBundle/Repository/ClientRepository.php b/src/Wallabag/ApiBundle/Repository/ClientRepository.php new file mode 100644 index 00000000..fc14262e --- /dev/null +++ b/src/Wallabag/ApiBundle/Repository/ClientRepository.php | |||
@@ -0,0 +1,19 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ApiBundle\Repository; | ||
4 | |||
5 | use Doctrine\ORM\EntityRepository; | ||
6 | |||
7 | class ClientRepository extends EntityRepository | ||
8 | { | ||
9 | public function findOneBy(array $criteria, array $orderBy = null) | ||
10 | { | ||
11 | if (!empty($criteria['id'])) { | ||
12 | // cast client id to be an integer to avoid postgres error: | ||
13 | // "invalid input syntax for integer" | ||
14 | $criteria['id'] = (int) $criteria['id']; | ||
15 | } | ||
16 | |||
17 | return parent::findOneBy($criteria, $orderBy); | ||
18 | } | ||
19 | } | ||