Merge pull request #3362 from sviande/fix_3361_api_warning

Fix #3361 check type for tags in entry repository
This commit is contained in:
Jérémy Benoist 2017-10-18 11:16:50 +02:00 committed by GitHub
commit 91f9bacf73
3 changed files with 9 additions and 2 deletions

View 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 */

View 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;

View 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]);