summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranoy <anoymouserver+github@mailbox.org>2021-05-04 17:57:07 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2021-05-05 12:11:13 +0200
commitd530500a5b61cf969fe4631cff9571c023517415 (patch)
treef0333a06b1a5912080c7ff9e5862476bf5cdea22
parentea074d0ee5c2d8e44de405aff5f5a849887adc21 (diff)
mitigate 32-bit issues with microseconds
Signed-off-by: anoy <anoymouserver+github@mailbox.org>
-rw-r--r--CHANGELOG.md2
-rw-r--r--lib/Db/ItemMapperV2.php25
-rw-r--r--lib/Service/ItemServiceV2.php12
3 files changed, 23 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14a27fa31..6c196bb81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,7 +20,7 @@ The format is almost based on [Keep a Changelog](https://keepachangelog.com/en/1
### Changed
### Fixed
-
+- mitigate 32-bit issues by using `float` instead of `int` for microseconds (#1320)
# Releases
## [15.4.2] - 2021-05-03
diff --git a/lib/Db/ItemMapperV2.php b/lib/Db/ItemMapperV2.php
index 6e50a5fb5..be80a6c64 100644
--- a/lib/Db/ItemMapperV2.php
+++ b/lib/Db/ItemMapperV2.php
@@ -312,7 +312,7 @@ class ItemMapperV2 extends NewsMapperV2
/**
* @param string $userId
* @param int $feedId
- * @param int $updatedSince
+ * @param float $updatedSince
* @param bool $hideRead
*
* @return Item[]
@@ -320,7 +320,7 @@ class ItemMapperV2 extends NewsMapperV2
public function findAllInFeedAfter(
string $userId,
int $feedId,
- int $updatedSince,
+ float $updatedSince,
bool $hideRead
): array {
$builder = $this->db->getQueryBuilder();
@@ -333,7 +333,7 @@ class ItemMapperV2 extends NewsMapperV2
->andWhere('feeds.id = :feedId')
->andWhere('feeds.deleted_at = 0')
->setParameters([
- 'updatedSince' => $updatedSince,
+ 'updatedSince' => number_format($updatedSince, 0, '.', ''),
'feedId' => $feedId,
'userId'=> $userId,
])
@@ -351,7 +351,7 @@ class ItemMapperV2 extends NewsMapperV2
/**
* @param string $userId
* @param int|null $folderId
- * @param int $updatedSince
+ * @param float $updatedSince
* @param bool $hideRead
*
* @return Item[]
@@ -359,7 +359,7 @@ class ItemMapperV2 extends NewsMapperV2
public function findAllInFolderAfter(
string $userId,
?int $folderId,
- int $updatedSince,
+ float $updatedSince,
bool $hideRead
): array {
$builder = $this->db->getQueryBuilder();
@@ -372,7 +372,11 @@ class ItemMapperV2 extends NewsMapperV2
->andWhere('feeds.user_id = :userId')
->andWhere('feeds.deleted_at = 0')
->andWhere('folders.id = :folderId')
- ->setParameters(['updatedSince' => $updatedSince, 'folderId' => $folderId, 'userId' => $userId])
+ ->setParameters([
+ 'updatedSince' => number_format($updatedSince, 0, '.', ''),
+ 'folderId' => $folderId,
+ 'userId' => $userId,
+ ])
->orderBy('items.last_modified', 'DESC')
->addOrderBy('items.id', 'DESC');
@@ -386,13 +390,13 @@ class ItemMapperV2 extends NewsMapperV2
/**
* @param string $userId
- * @param int $updatedSince
+ * @param float $updatedSince
* @param int $feedType
*
* @return Item[]|Entity[]
* @throws ServiceValidationException
*/
- public function findAllAfter(string $userId, int $feedType, int $updatedSince): array
+ public function findAllAfter(string $userId, int $feedType, float $updatedSince): array
{
$builder = $this->db->getQueryBuilder();
@@ -402,7 +406,10 @@ class ItemMapperV2 extends NewsMapperV2
->andWhere('items.last_modified >= :updatedSince')
->andWhere('feeds.deleted_at = 0')
->andWhere('feeds.user_id = :userId')
- ->setParameters(['updatedSince' => $updatedSince, 'userId' => $userId])
+ ->setParameters([
+ 'updatedSince' => number_format($updatedSince, 0, '.', ''),
+ 'userId' => $userId,
+ ])
->orderBy('items.last_modified', 'DESC')
->addOrderBy('items.id', 'DESC');
diff --git a/lib/Service/ItemServiceV2.php b/lib/Service/ItemServiceV2.php
index 57804a8c3..c69571b1c 100644
--- a/lib/Service/ItemServiceV2.php
+++ b/lib/Service/ItemServiceV2.php
@@ -271,12 +271,12 @@ class ItemServiceV2 extends Service
* Returns all new items in a feed
* @param string $userId the name of the user
* @param int $feedId the id of the feed
- * @param int $updatedSince a timestamp with the minimal modification date
+ * @param float $updatedSince a timestamp with the minimal modification date
* @param boolean $hideRead if unread items should also be returned
*
* @return array of items
*/
- public function findAllInFeedAfter(string $userId, int $feedId, int $updatedSince, bool $hideRead): array
+ public function findAllInFeedAfter(string $userId, int $feedId, float $updatedSince, bool $hideRead): array
{
return $this->mapper->findAllInFeedAfter($userId, $feedId, $updatedSince, $hideRead);
}
@@ -285,12 +285,12 @@ class ItemServiceV2 extends Service
* Returns all new items in a folder
* @param string $userId the name of the user
* @param int|null $folderId the id of the folder
- * @param int $updatedSince a timestamp with the minimal modification date
+ * @param float $updatedSince a timestamp with the minimal modification date
* @param boolean $hideRead if unread items should also be returned
*
* @return array of items
*/
- public function findAllInFolderAfter(string $userId, ?int $folderId, int $updatedSince, bool $hideRead): array
+ public function findAllInFolderAfter(string $userId, ?int $folderId, float $updatedSince, bool $hideRead): array
{
return $this->mapper->findAllInFolderAfter($userId, $folderId, $updatedSince, $hideRead);
}
@@ -300,13 +300,13 @@ class ItemServiceV2 extends Service
*
* @param string $userId the name of the user
* @param int $feedType the type of feed items to fetch. (starred || unread)
- * @param int $updatedSince a timestamp with the minimal modification date
+ * @param float $updatedSince a timestamp with the minimal modification date
*
* @return array of items
*
* @throws ServiceValidationException
*/
- public function findAllAfter(string $userId, int $feedType, int $updatedSince): array
+ public function findAllAfter(string $userId, int $feedType, float $updatedSince): array
{
if (!in_array($feedType, [ListType::STARRED, ListType::UNREAD, ListType::ALL_ITEMS], true)) {
throw new ServiceValidationException('Trying to find in unknown type');