summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Tom Willemse2024-06-11 00:11:58 -0700
committerGravatar Tom Willemse2024-06-11 00:11:58 -0700
commit85cca718e308779a56dbf302140ce9088fc0727a (patch)
treeac0db2fa23482c6ef5caedd21079bf2f8c9be368
parentdec3464bffa14245b2cea076f2aac3a55283230d (diff)
downloadscuttle-sqlite-fixes.tar.gz
scuttle-sqlite-fixes.zip
Throw an error when changes can't be committed to the databasesqlite-fixes
I was testing and another process had the database open, so it couldn't commit changes. This wasn't apparent from the UI because it would just silently assume a commit went fine.
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php16
-rw-r--r--src/SemanticScuttle/Service/Bookmark2Tag.php11
-rw-r--r--src/SemanticScuttle/Service/Tag.php8
-rw-r--r--src/SemanticScuttle/Service/Tag2Tag.php10
-rw-r--r--src/SemanticScuttle/Service/TagCache.php15
-rw-r--r--src/SemanticScuttle/Service/User.php37
6 files changed, 86 insertions, 11 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index f617059..7eb1174 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -661,7 +661,13 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
);
}
- $this->db->sql_transaction('commit');
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit bookmark update',
+ '', __LINE__, __FILE__, $sql, $this->db
+ );
+ }
// Everything worked out, so return true.
return true;
}
@@ -1011,7 +1017,13 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
);
}
- $this->db->sql_transaction('commit');
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit deleting votes for bookmark',
+ '', __LINE__, __FILE__, $query, $this->db
+ );
+ }
return true;
}
diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php
index 2b95bd8..232fc80 100644
--- a/src/SemanticScuttle/Service/Bookmark2Tag.php
+++ b/src/SemanticScuttle/Service/Bookmark2Tag.php
@@ -208,7 +208,16 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
return false;
}
}
- $this->db->sql_transaction('commit');
+
+ if ($this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit attaching tags',
+ '', __LINE__, __FILE__, $sql, $this->db
+ );
+ return false;
+ }
+
return true;
}
diff --git a/src/SemanticScuttle/Service/Tag.php b/src/SemanticScuttle/Service/Tag.php
index 17acae7..087a004 100644
--- a/src/SemanticScuttle/Service/Tag.php
+++ b/src/SemanticScuttle/Service/Tag.php
@@ -119,7 +119,13 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService
message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db);
return false;
}
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(GENERAL_ERROR, 'Could not commit deleting bookmarks', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
return true;
}
diff --git a/src/SemanticScuttle/Service/Tag2Tag.php b/src/SemanticScuttle/Service/Tag2Tag.php
index 9a5d0f2..d404bb5 100644
--- a/src/SemanticScuttle/Service/Tag2Tag.php
+++ b/src/SemanticScuttle/Service/Tag2Tag.php
@@ -94,7 +94,15 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
);
return false;
}
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit attaching tag to tag',
+ '', __LINE__, __FILE__, $query, $this->db
+ );
+ return false;
+ }
// Update stats and cache
$this->update($tag1, $tag2, $relationType, $uId);
diff --git a/src/SemanticScuttle/Service/TagCache.php b/src/SemanticScuttle/Service/TagCache.php
index f8a28af..fb3c99a 100644
--- a/src/SemanticScuttle/Service/TagCache.php
+++ b/src/SemanticScuttle/Service/TagCache.php
@@ -106,7 +106,12 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
message_die(GENERAL_ERROR, 'Could not add tag cache inference', '', __LINE__, __FILE__, $query, $this->db);
return false;
}
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(GENERAL_ERROR, 'Could not commit adding tag cache inference', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
}
function removeChild($tag1, $tag2, $uId) {
@@ -220,7 +225,13 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
message_die(GENERAL_ERROR, 'Could not add tag cache synonymy', '', __LINE__, __FILE__, $query, $this->db);
return false;
}
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(GENERAL_ERROR, 'Could not commit adding tag cache synonymy', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
break;
}
}
diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php
index d527031..dbbb202 100644
--- a/src/SemanticScuttle/Service/User.php
+++ b/src/SemanticScuttle/Service/User.php
@@ -202,7 +202,15 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
);
return false;
}
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit user update', '',
+ __LINE__, __FILE__, $sql, $this->db
+ );
+ return false;
+ }
// Everything worked out, so return true.
return true;
@@ -707,7 +715,12 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
}
}
- $this->db->sql_transaction('commit');
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(GENERAL_ERROR, 'Could not commit adding user to watch list', '', __LINE__, __FILE__, $sql, $this->db);
+ return false;
+ }
+
return true;
}
@@ -751,7 +764,15 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
return false;
}
$uId = $this->db->sql_nextid($dbresult);
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit user',
+ '', __LINE__, __FILE__, $sql, $this->db
+ );
+ return false;
+ }
return $uId;
}
@@ -833,7 +854,15 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
);
return false;
}
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit user update', '',
+ __LINE__, __FILE__, $sql, $this->db
+ );
+ return false;
+ }
// Everything worked out, so return true.
return true;