X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Flabels.php;h=973732b991246559638950cf4114118e3f8a2272;hb=c949a9282e1102e82cca5bb158e84f742e8f1456;hp=9c6f22f5177989fe173959ac4d83284f1c864d4b;hpb=4102eb843ff11a4aae0cc890cf700b7e3b4e72e2;p=tt-rss.git diff --git a/classes/labels.php b/classes/labels.php index 9c6f22f5..973732b9 100644 --- a/classes/labels.php +++ b/classes/labels.php @@ -131,8 +131,13 @@ class Labels if (!$owner_uid) $owner_uid = $_SESSION["uid"]; $pdo = Db::pdo(); + $tr_in_progress = false; - $pdo->beginTransaction(); + try { + $pdo->beginTransaction(); + } catch (Exception $e) { + $tr_in_progress = true; + } $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 WHERE id = ?"); @@ -163,7 +168,7 @@ class Labels } - $pdo->commit(); + if (!$tr_in_progress) $pdo->commit(); } static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) { @@ -172,7 +177,13 @@ class Labels $pdo = Db::pdo(); - $pdo->beginTransaction(); + $tr_in_progress = false; + + try { + $pdo->beginTransaction(); + } catch (Exception $e) { + $tr_in_progress = true; + } $sth = $pdo->prepare("SELECT id FROM ttrss_labels2 WHERE caption = ? AND owner_uid = ?"); @@ -187,7 +198,7 @@ class Labels $result = $sth->rowCount(); } - $pdo->commit(); + if (!$tr_in_progress) $pdo->commit(); return $result; }