aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-10-18 11:16:50 +0200
committerGitHub <noreply@github.com>2017-10-18 11:16:50 +0200
commit91f9bacf735e61072d6f0e9f47cc5ec6401193c7 (patch)
treea8837114af6a4aa86f3af36bc7b2f5e697de9ee9
parent7f5d03a98d59afa171ccc003a48715f13fa3b116 (diff)
parent0978bd849e77b1157b21f8e231965521e535bacd (diff)
downloadwallabag-91f9bacf735e61072d6f0e9f47cc5ec6401193c7.tar.gz
wallabag-91f9bacf735e61072d6f0e9f47cc5ec6401193c7.tar.zst
wallabag-91f9bacf735e61072d6f0e9f47cc5ec6401193c7.zip
Merge pull request #3362 from sviande/fix_3361_api_warning
Fix #3361 check type for tags in entry repository
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php2
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php2
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php7
3 files changed, 9 insertions, 2 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index 86e72335..6f161a08 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -102,7 +102,7 @@ class EntryRestController extends WallabagRestController
102 $order = $request->query->get('order', 'desc'); 102 $order = $request->query->get('order', 'desc');
103 $page = (int) $request->query->get('page', 1); 103 $page = (int) $request->query->get('page', 1);
104 $perPage = (int) $request->query->get('perPage', 30); 104 $perPage = (int) $request->query->get('perPage', 30);
105 $tags = $request->query->get('tags', ''); 105 $tags = is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', '');
106 $since = $request->query->get('since', 0); 106 $since = $request->query->get('since', 0);
107 107
108 /** @var \Pagerfanta\Pagerfanta $pager */ 108 /** @var \Pagerfanta\Pagerfanta $pager */
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 05f0e0ba..b5e35eff 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -151,7 +151,7 @@ class EntryRepository extends EntityRepository
151 $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since))); 151 $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since)));
152 } 152 }
153 153
154 if ('' !== $tags) { 154 if (is_string($tags) && '' !== $tags) {
155 foreach (explode(',', $tags) as $i => $tag) { 155 foreach (explode(',', $tags) as $i => $tag) {
156 $entryAlias = 'e' . $i; 156 $entryAlias = 'e' . $i;
157 $tagAlias = 't' . $i; 157 $tagAlias = 't' . $i;
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index fcec3f3b..95c64501 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -308,6 +308,13 @@ class EntryRestControllerTest extends WallabagApiTestCase
308 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); 308 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
309 } 309 }
310 310
311 public function testGetTaggedEntriesWithBadParams()
312 {
313 $this->client->request('GET', '/api/entries', ['tags' => ['foo', 'bar']]);
314
315 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
316 }
317
311 public function testGetDatedEntries() 318 public function testGetDatedEntries()
312 { 319 {
313 $this->client->request('GET', '/api/entries', ['since' => 1443274283]); 320 $this->client->request('GET', '/api/entries', ['since' => 1443274283]);