mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Use a read transaction when computing filter rules
This commit is contained in:
parent
cca4b205e4
commit
a646ad77b7
1 changed files with 5 additions and 1 deletions
|
@ -963,7 +963,7 @@ class Database {
|
||||||
}
|
}
|
||||||
$out = (bool) $this->db->prepare("UPDATE arsse_subscriptions set $setClause, modified = CURRENT_TIMESTAMP where owner = ? and id = ?", $setTypes, "str", "int")->run($setValues, $user, $id)->changes();
|
$out = (bool) $this->db->prepare("UPDATE arsse_subscriptions set $setClause, modified = CURRENT_TIMESTAMP where owner = ? and id = ?", $setTypes, "str", "int")->run($setValues, $user, $id)->changes();
|
||||||
$tr->commit();
|
$tr->commit();
|
||||||
// if filter rules were changed, apply them
|
// if filter rules were changed, apply them; this is done outside the transaction because it may take some time
|
||||||
if (array_key_exists("keep_rule", $data) || array_key_exists("block_rule", $data)) {
|
if (array_key_exists("keep_rule", $data) || array_key_exists("block_rule", $data)) {
|
||||||
$this->subscriptionRulesApply($user, $id);
|
$this->subscriptionRulesApply($user, $id);
|
||||||
}
|
}
|
||||||
|
@ -1030,6 +1030,8 @@ class Database {
|
||||||
* @param integer $id The identifier of the subscription whose rules are to be evaluated
|
* @param integer $id The identifier of the subscription whose rules are to be evaluated
|
||||||
*/
|
*/
|
||||||
protected function subscriptionRulesApply(string $user, int $id): void {
|
protected function subscriptionRulesApply(string $user, int $id): void {
|
||||||
|
// start a transaction for read isolation
|
||||||
|
$tr = $this->begin();
|
||||||
$sub = $this->db->prepare("SELECT feed, coalesce(keep_rule, '') as keep, coalesce(block_rule, '') as block from arsse_subscriptions where owner = ? and id = ?", "str", "int")->run($user, $id)->getRow();
|
$sub = $this->db->prepare("SELECT feed, coalesce(keep_rule, '') as keep, coalesce(block_rule, '') as block from arsse_subscriptions where owner = ? and id = ?", "str", "int")->run($user, $id)->getRow();
|
||||||
try {
|
try {
|
||||||
$keep = Rule::prep($sub['keep']);
|
$keep = Rule::prep($sub['keep']);
|
||||||
|
@ -1053,6 +1055,8 @@ class Database {
|
||||||
$hide[] = $r['id'];
|
$hide[] = $r['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// roll back the read transation
|
||||||
|
$tr->rollback();
|
||||||
// apply any marks
|
// apply any marks
|
||||||
if ($hide) {
|
if ($hide) {
|
||||||
$this->articleMark($user, ['hidden' => true], (new Context)->articles($hide), false);
|
$this->articleMark($user, ['hidden' => true], (new Context)->articles($hide), false);
|
||||||
|
|
Loading…
Reference in a new issue