diff options
author | Tom Willemse | 2024-06-11 00:13:48 -0700 |
---|---|---|
committer | Tom Willemse | 2024-06-11 00:13:48 -0700 |
commit | a959a69a1dd781caa33829db161859c88455911d (patch) | |
tree | ac0db2fa23482c6ef5caedd21079bf2f8c9be368 /src/SemanticScuttle/Service/User.php | |
parent | 9bcc5827388491d37591a86a175f63fa9cd38d41 (diff) | |
parent | 85cca718e308779a56dbf302140ce9088fc0727a (diff) | |
download | scuttle-a959a69a1dd781caa33829db161859c88455911d.tar.gz scuttle-a959a69a1dd781caa33829db161859c88455911d.zip |
Merge branch 'sqlite-fixes' into oni
Diffstat (limited to 'src/SemanticScuttle/Service/User.php')
-rw-r--r-- | src/SemanticScuttle/Service/User.php | 72 |
1 files changed, 41 insertions, 31 deletions
diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index 68e8c11..dbbb202 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -103,15 +103,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService GENERAL_ERROR, 'Could not get user', '', __LINE__, __FILE__, $query, $this->db ); - return [ 'uId' => 0, - 'username' => '', - 'name' => '', - 'email' => '', - 'homepage' => '', - 'content' => '', - 'datetime' => NULL, - 'isAdmin' => false, - 'privateKeey' => '' ]; + return false; } $row = $this->db->sql_fetchrow($dbresult); @@ -119,15 +111,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService if ($row) { return $row; } else { - return [ 'uId' => 0, - 'username' => '', - 'name' => '', - 'email' => '', - 'homepage' => '', - 'content' => '', - 'datetime' => NULL, - 'isAdmin' => false, - 'privateKeey' => '' ]; + return false; } } @@ -218,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; @@ -411,7 +403,12 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService { if (is_numeric($user)) { $user = $this->getUser($user); - $user = $user['username']; + if ($user) { + $user = $user['username']; + } + else { + $user = 'unknown'; + } } else if (is_array($user)) { $user = $user['username']; } @@ -620,10 +617,6 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService } $arrWatch = array(); - if ($this->db->sql_numrows($dbresult) == 0) { - $this->db->sql_freeresult($dbresult); - return $arrWatch; - } while ($row = $this->db->sql_fetchrow($dbresult)) { $arrWatch[] = $row['watched']; } @@ -670,10 +663,6 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService } $arrWatch = array(); - if ($this->db->sql_numrows($dbresult) == 0) { - $this->db->sql_freeresult($dbresult); - return $arrWatch; - } while ($row = $this->db->sql_fetchrow($dbresult)) { $arrWatch[] = $row[$this->getFieldName('username')]; } @@ -726,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; } @@ -770,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; } @@ -852,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; |