ソースを参照

Fix newest articles not shown (#7577)

* Fix newest articles not shown
Case when processing was faster than 1 second.
fix https://github.com/FreshRSS/FreshRSS/issues/7412
Regression from https://github.com/FreshRSS/FreshRSS/pull/7149

* Simplify uTimeString()
PHPStan has become a bit smarter
Alexandre Alapetite 11 ヶ月 前
コミット
532d229d33

+ 1 - 1
app/Controllers/indexController.php

@@ -63,7 +63,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
 		FreshRSS_View::prependTitle($title . ' · ');
 
 		if (FreshRSS_Context::$id_max === '0') {
-			FreshRSS_Context::$id_max = time() . '000000';
+			FreshRSS_Context::$id_max = uTimeString();
 		}
 
 		$this->view->callbackBeforeFeeds = static function (FreshRSS_View $view) {

+ 4 - 4
app/Models/EntryDAO.php

@@ -493,7 +493,7 @@ SQL;
 		?FreshRSS_BooleanSearch $filters = null, int $state = 0, bool $is_read = true) {
 		FreshRSS_UserDAO::touch();
 		if ($idMax == '0') {
-			$idMax = time() . '000000';
+			$idMax = uTimeString();
 			Minz_Log::debug('Calling markReadEntries(0) is deprecated!');
 		}
 
@@ -544,7 +544,7 @@ SQL;
 	public function markReadCat(int $id, string $idMax = '0', ?FreshRSS_BooleanSearch $filters = null, int $state = 0, bool $is_read = true): int|false {
 		FreshRSS_UserDAO::touch();
 		if ($idMax == '0') {
-			$idMax = time() . '000000';
+			$idMax = uTimeString();
 			Minz_Log::debug('Calling markReadCat(0) is deprecated!');
 		}
 
@@ -585,7 +585,7 @@ SQL;
 	public function markReadFeed(int $id_feed, string $idMax = '0', ?FreshRSS_BooleanSearch $filters = null, int $state = 0, bool $is_read = true): int|false {
 		FreshRSS_UserDAO::touch();
 		if ($idMax == '0') {
-			$idMax = time() . '000000';
+			$idMax = uTimeString();
 			Minz_Log::debug('Calling markReadFeed(0) is deprecated!');
 		}
 		$hadTransaction = $this->pdo->inTransaction();
@@ -640,7 +640,7 @@ SQL;
 		int $state = 0, bool $is_read = true) {
 		FreshRSS_UserDAO::touch();
 		if ($idMax == '0') {
-			$idMax = time() . '000000';
+			$idMax = uTimeString();
 			Minz_Log::debug('Calling markReadTag(0) is deprecated!');
 		}
 

+ 1 - 1
app/Models/EntryDAOSQLite.php

@@ -155,7 +155,7 @@ SQL;
 	public function markReadTag(int $id = 0, string $idMax = '0', ?FreshRSS_BooleanSearch $filters = null, int $state = 0, bool $is_read = true): int|false {
 		FreshRSS_UserDAO::touch();
 		if ($idMax == 0) {
-			$idMax = time() . '000000';
+			$idMax = uTimeString();
 			Minz_Log::debug('Calling markReadTag(0) is deprecated!');
 		}
 

+ 3 - 5
lib/lib_rss.php

@@ -647,11 +647,9 @@ function lazyimg(string $content): string {
 
 /** @return numeric-string */
 function uTimeString(): string {
-	$t = @gettimeofday();
-	$sec = is_numeric($t['sec']) ? (int)$t['sec'] : 0;
-	$usec = is_numeric($t['usec']) ? (int)$t['usec'] : 0;
-	$result = ((string)$sec) . str_pad((string)$usec, 6, '0', STR_PAD_LEFT);
-	return ctype_digit($result) ? $result : '0';
+	$t = gettimeofday();
+	// @phpstan-ignore return.type
+	return ((string)$t['sec']) . str_pad((string)$t['usec'], 6, '0', STR_PAD_LEFT);
 }
 
 function invalidateHttpCache(string $username = ''): bool {