]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #3362 from sviande/fix_3361_api_warning
authorJérémy Benoist <j0k3r@users.noreply.github.com>
Wed, 18 Oct 2017 09:16:50 +0000 (11:16 +0200)
committerGitHub <noreply@github.com>
Wed, 18 Oct 2017 09:16:50 +0000 (11:16 +0200)
Fix #3361 check type for tags in entry repository

src/Wallabag/ApiBundle/Controller/EntryRestController.php
src/Wallabag/CoreBundle/Repository/EntryRepository.php
tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php

index 86e723351c696db1bcc09788710499cf2bafb704..6f161a081eb436431a26d7854988e1c6d3b7cb6c 100644 (file)
@@ -102,7 +102,7 @@ class EntryRestController extends WallabagRestController
         $order = $request->query->get('order', 'desc');
         $page = (int) $request->query->get('page', 1);
         $perPage = (int) $request->query->get('perPage', 30);
-        $tags = $request->query->get('tags', '');
+        $tags = is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', '');
         $since = $request->query->get('since', 0);
 
         /** @var \Pagerfanta\Pagerfanta $pager */
index 05f0e0ba17e665bb4cea4ed942d8e7aa1fd406e2..b5e35eff3848a69a8e0ee43e769a7fa55aee18b1 100644 (file)
@@ -151,7 +151,7 @@ class EntryRepository extends EntityRepository
             $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since)));
         }
 
-        if ('' !== $tags) {
+        if (is_string($tags) && '' !== $tags) {
             foreach (explode(',', $tags) as $i => $tag) {
                 $entryAlias = 'e' . $i;
                 $tagAlias = 't' . $i;
index fcec3f3b2fba1ad15f11c55ba3d8d318fbc833c5..95c64501c0e94cca146c0cfe3a6f4c1244c8d24d 100644 (file)
@@ -308,6 +308,13 @@ class EntryRestControllerTest extends WallabagApiTestCase
         $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
     }
 
+    public function testGetTaggedEntriesWithBadParams()
+    {
+        $this->client->request('GET', '/api/entries', ['tags' => ['foo', 'bar']]);
+
+        $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+    }
+
     public function testGetDatedEntries()
     {
         $this->client->request('GET', '/api/entries', ['since' => 1443274283]);