summaryrefslogtreecommitdiff
path: root/classes/prefs.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-25 19:21:29 +0300
committerAndrew Dolgov <[email protected]>2021-02-25 19:21:29 +0300
commit281f2efeb8a8fca6e145a816b77303373c200ace (patch)
tree873e1b1e5b6f301acf40a5dba63186af114ac855 /classes/prefs.php
parent89ad25405ed4058d6d8f9dce7daab415f74483c2 (diff)
wrap prefs->migrate() into a transaction block
Diffstat (limited to 'classes/prefs.php')
-rw-r--r--classes/prefs.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/classes/prefs.php b/classes/prefs.php
index 29e315c22..fbe2d33d8 100644
--- a/classes/prefs.php
+++ b/classes/prefs.php
@@ -162,6 +162,9 @@ class Prefs {
$owner_uid = (int) $_SESSION["uid"];
$profile_id = $_SESSION["profile"] ?? null;
+
+ $in_nested_tr = false;
+
$this->migrate($owner_uid, $profile_id);
$this->cache_all($owner_uid, $profile_id);
};
@@ -352,6 +355,14 @@ class Prefs {
if (!$this->_get(Prefs::_PREFS_MIGRATED, $owner_uid, $profile_id)) {
+ $in_nested_tr = false;
+
+ try {
+ $this->pdo->beginTransaction();
+ } catch (PDOException $e) {
+ $in_nested_tr = true;
+ }
+
$sth = $this->pdo->prepare("SELECT pref_name, value FROM ttrss_user_prefs
WHERE owner_uid = :uid AND
(profile = :profile OR (:profile IS NULL AND profile IS NULL))");
@@ -370,6 +381,11 @@ class Prefs {
}
$this->_set(Prefs::_PREFS_MIGRATED, "1", $owner_uid, $profile_id);
+
+ if (!$in_nested_tr)
+ $this->pdo->commit();
+
+ Logger::log(E_USER_NOTICE, sprintf("Migrated preferences of user %d (profile %d)", $owner_uid, $profile_id));
}
}