Просмотр исходного кода

Fix bigint timestamps on 32-bit (#7375)

* Fix bigint timestamps on 32-bit
fix https://github.com/FreshRSS/FreshRSS/issues/7374
SQL requests for BIGINT fields may return a string on 32-bit systems instead of an integer

* Calculations may also be string
Alexandre Alapetite 1 год назад
Родитель
Сommit
5f6ef05ffc
4 измененных файлов с 25 добавлено и 7 удалено
  1. 8 2
      app/Models/Category.php
  2. 6 1
      app/Models/Entry.php
  3. 8 2
      app/Models/Feed.php
  4. 3 2
      app/Models/Tag.php

+ 8 - 2
app/Models/Category.php

@@ -58,9 +58,15 @@ class FreshRSS_Category extends Minz_Model {
 	public function lastUpdate(): int {
 		return $this->lastUpdate;
 	}
-	public function _lastUpdate(int $value): void {
-		$this->lastUpdate = $value;
+
+	/**
+	 * @param int|numeric-string $value
+	 * 32-bit systems provide a string and will fail in year 2038
+	 */
+	public function _lastUpdate(int|string $value): void {
+		$this->lastUpdate = (int)$value;
 	}
+
 	public function inError(): bool {
 		return $this->error;
 	}

+ 6 - 1
app/Models/Entry.php

@@ -546,7 +546,12 @@ HTML;
 		$this->date = $value > 1 ? $value : time();
 	}
 
-	public function _lastSeen(int $value): void {
+	/**
+	 * @param int|numeric-string $value
+	 * 32-bit systems provide a string and will fail in year 2038
+	 */
+	public function _lastSeen(int|string $value): void {
+		$value = (int)$value;
 		$this->lastSeen = $value > 0 ? $value : 0;
 	}
 

+ 8 - 2
app/Models/Feed.php

@@ -308,9 +308,15 @@ class FreshRSS_Feed extends Minz_Model {
 	public function _description(string $value): void {
 		$this->description = $value == '' ? '' : $value;
 	}
-	public function _lastUpdate(int $value): void {
-		$this->lastUpdate = $value;
+
+	/**
+	 * @param int|numeric-string $value
+	 * 32-bit systems provide a string and will fail in year 2038
+	 */
+	public function _lastUpdate(int|string $value): void {
+		$this->lastUpdate = (int)$value;
 	}
+
 	public function _priority(int $value): void {
 		$this->priority = $value;
 	}

+ 3 - 2
app/Models/Tag.php

@@ -49,7 +49,8 @@ class FreshRSS_Tag extends Minz_Model {
 		return $this->nbUnread;
 	}
 
-	public function _nbUnread(int $value): void {
-		$this->nbUnread = $value;
+	/** @param int|numeric-string $value */
+	public function _nbUnread(int|string $value): void {
+		$this->nbUnread = (int)$value;
 	}
 }