aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAO.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-06-16 16:11:16 +0200
committerGravatar GitHub <noreply@github.com> 2023-06-16 16:11:16 +0200
commit723f7577d0a388a90779930754c5aacb9f66b168 (patch)
treeaa863f67592d0795be83b533de981082e0713601 /app/Models/EntryDAO.php
parent228d7adfdb90c3fdd179f80fbfde565eb06e0cec (diff)
Refactor lastSeen and markReadAsGone (#5470)
* Refactor lastSeen and markReadAsGone Make the logic a bit more robust and explicit * Remove forgotten SQL param * Add test inTransaction * More robust transaction * Add a debug log * Add max timestamp to markAsReadUponGone * Reduce number of debug lines * typing * Better detection of when feed is empty * More explicit case for push
Diffstat (limited to 'app/Models/EntryDAO.php')
-rw-r--r--app/Models/EntryDAO.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 9ea7bd261..f9bdd7be2 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -120,7 +120,7 @@ SQL;
*/
private $addEntryPrepared = false;
- /** @param array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'hash':string,
+ /** @param array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'lastSeen':int,'hash':string,
* 'is_read':bool|int|null,'is_favorite':bool|int|null,'id_feed':int,'tags':string,'attributes':array<string,mixed>} $valuesTmp */
public function addEntry(array $valuesTmp, bool $useTmpTable = true): bool {
if ($this->addEntryPrepared == null) {
@@ -556,7 +556,10 @@ SQL;
$idMax = time() . '000000';
Minz_Log::debug('Calling markReadFeed(0) is deprecated!');
}
- $this->pdo->beginTransaction();
+ $hadTransaction = $this->pdo->inTransaction();
+ if (!$hadTransaction) {
+ $this->pdo->beginTransaction();
+ }
$sql = 'UPDATE `_entry` '
. 'SET is_read=? '
@@ -589,7 +592,9 @@ SQL;
}
}
- $this->pdo->commit();
+ if (!$hadTransaction) {
+ $this->pdo->commit();
+ }
return $affected;
}
@@ -698,7 +703,7 @@ SQL;
}
}
- /** @return Traversable<array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,
+ /** @return Traversable<array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'lastSeen':int,
* 'hash':string,'is_read':?bool,'is_favorite':?bool,'id_feed':int,'tags':string,'attributes':array<string,mixed>}> */
public function selectAll(): Traversable {
$content = static::isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content';