From c67feb8d8d388e3b16603b2253ad7f86d8d72fd9 Mon Sep 17 00:00:00 2001 From: anoy Date: Fri, 15 Jan 2021 21:47:18 +0100 Subject: fix TypeError caused by type conversion in controller Signed-off-by: anoy --- CHANGELOG.md | 1 + lib/Controller/ItemApiController.php | 4 ++-- lib/Service/ItemService.php | 2 +- tests/Unit/Controller/ItemApiControllerTest.php | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 101e76299..238c535b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is almost based on [Keep a Changelog](https://keepachangelog.com/en/1 ### Fixed - opened state of folders is not restored (#1040) - Argument 3 passed to OCA\News\Db\ItemMapper::makeSelectQuery() must be of the type bool, array given (#1044) +- Argument 2 passed to OCA\News\Db\ItemMapper::findAllNewFeed() must be of the type int, string given (#1049) ## [15.2.0-beta1] - 2021-01-11 diff --git a/lib/Controller/ItemApiController.php b/lib/Controller/ItemApiController.php index c958324af..af36b87f0 100644 --- a/lib/Controller/ItemApiController.php +++ b/lib/Controller/ItemApiController.php @@ -93,14 +93,14 @@ class ItemApiController extends ApiController { // needs to be turned into a millisecond timestamp to work properly if (strlen((string) $lastModified) <= 10) { - $paddedLastModified = $lastModified . '000000'; + $paddedLastModified = $lastModified * 1000000; } else { $paddedLastModified = $lastModified; } $items = $this->oldItemService->findAllNew( $id, $type, - $paddedLastModified, + (int) $paddedLastModified, true, $this->getUserId() ); diff --git a/lib/Service/ItemService.php b/lib/Service/ItemService.php index 62a319346..8ba0a4b73 100644 --- a/lib/Service/ItemService.php +++ b/lib/Service/ItemService.php @@ -73,7 +73,7 @@ class ItemService extends Service * * @return array of items */ - public function findAllNew(?int $id, $type, $updatedSince, $showAll, $userId) + public function findAllNew(?int $id, $type, int $updatedSince, bool $showAll, string $userId) { switch ($type) { case FeedType::FEED: diff --git a/tests/Unit/Controller/ItemApiControllerTest.php b/tests/Unit/Controller/ItemApiControllerTest.php index 8177bb0a2..91181333a 100644 --- a/tests/Unit/Controller/ItemApiControllerTest.php +++ b/tests/Unit/Controller/ItemApiControllerTest.php @@ -150,7 +150,7 @@ class ItemApiControllerTest extends TestCase ->with( $this->equalTo(2), $this->equalTo(1), - $this->equalTo('30000000'), + $this->equalTo(30000000), $this->equalTo(true), $this->equalTo($this->user->getUID()) ) -- cgit v1.2.3