From 1fe730f51489d270d92f9bff0cb6ee3d3450359f Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 3 Dec 2024 20:36:29 +0000 Subject: [PATCH] Fix errors in Database namespace --- src/Database/DBA.php | 18 +++++++++--------- src/Database/Database.php | 12 +++++++----- src/Model/Attach.php | 4 ++-- src/Model/Photo.php | 4 ++-- src/Model/Post.php | 4 ++-- src/Model/Post/Content.php | 7 ++----- src/Model/Post/Origin.php | 7 ++----- src/Model/Post/Thread.php | 7 ++----- src/Model/Post/ThreadUser.php | 4 ++-- src/Model/Post/User.php | 7 ++----- src/Model/Post/UserNotification.php | 6 ++---- 11 files changed, 34 insertions(+), 46 deletions(-) diff --git a/src/Database/DBA.php b/src/Database/DBA.php index a357bd11d7..c001384f99 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -233,7 +233,7 @@ class DBA /** * Returns the number of columns of a statement * - * @param object Statement object + * @param object $stmt Statement object * @return int Number of columns */ public static function columnCount($stmt): int @@ -243,7 +243,7 @@ class DBA /** * Returns the number of rows of a statement * - * @param PDOStatement|mysqli_result|mysqli_stmt Statement object + * @param PDOStatement|mysqli_result|mysqli_stmt $stmt Statement object * @return int Number of rows */ public static function numRows($stmt): int @@ -364,9 +364,9 @@ class DBA * @return boolean was the delete successful? * @throws \Exception */ - public static function delete(string $table, array $conditions, array $options = []): bool + public static function delete(string $table, array $conditions): bool { - return DI::dba()->delete($table, $conditions, $options); + return DI::dba()->delete($table, $conditions); } /** @@ -756,7 +756,7 @@ class DBA /** * Returns the error number of the last query * - * @return string Error number (0 if no error) + * @return int Error number (0 if no error) */ public static function errorNo(): int { @@ -813,8 +813,8 @@ class DBA /** * Acquire a lock to prevent a table optimization * - * @return bool - * @throws LockPersistenceException + * @return bool + * @throws LockPersistenceException */ public static function acquireOptimizeLock(): bool { @@ -823,8 +823,8 @@ class DBA /** * Release the table optimization lock - * @return bool - * @throws LockPersistenceException + * @return bool + * @throws LockPersistenceException */ public static function releaseOptimizeLock(): bool { diff --git a/src/Database/Database.php b/src/Database/Database.php index 15bb84765a..6ee4394901 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -552,8 +552,10 @@ class Database break; } - /** @var $stmt mysqli_stmt|PDOStatement */ - if (!$stmt = $this->connection->prepare($sql)) { + /** @var mysqli_stmt|PDOStatement $stmt */ + $stmt = $this->connection->prepare($sql); + + if (!$stmt) { $errorInfo = $this->connection->errorInfo(); $this->error = (string)$errorInfo[2]; $this->errorno = (int)$errorInfo[1]; @@ -889,7 +891,7 @@ class Database /** * Returns the number of columns of a statement * - * @param object Statement object + * @param object $stmt Statement object * * @return int Number of columns */ @@ -910,7 +912,7 @@ class Database /** * Returns the number of rows of a statement * - * @param PDOStatement|mysqli_result|mysqli_stmt Statement object + * @param PDOStatement|mysqli_result|mysqli_stmt $stmt Statement object * * @return int Number of rows */ @@ -1652,7 +1654,7 @@ class Database /** * Returns the error number of the last query * - * @return string Error number (0 if no error) + * @return int Error number (0 if no error) */ public function errorNo(): int { diff --git a/src/Model/Attach.php b/src/Model/Attach.php index bd5bd940d0..bd78fcd80e 100644 --- a/src/Model/Attach.php +++ b/src/Model/Attach.php @@ -299,7 +299,7 @@ class Attach * @throws \Exception * @see \Friendica\Database\DBA::delete */ - public static function delete(array $conditions, array $options = []): bool + public static function delete(array $conditions): bool { // get items to delete data info $items = self::selectToArray(['backend-class', 'backend-ref'], $conditions); @@ -315,7 +315,7 @@ class Attach } } - return DBA::delete('attach', $conditions, $options); + return DBA::delete('attach', $conditions); } public static function setPermissionFromBody(array $post) diff --git a/src/Model/Photo.php b/src/Model/Photo.php index e2d38241d8..126edd379c 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -496,7 +496,7 @@ class Photo * @throws \Exception * @see \Friendica\Database\DBA::delete */ - public static function delete(array $conditions, array $options = []): bool + public static function delete(array $conditions): bool { // get photo to delete data info $photos = DBA::select('photo', ['id', 'backend-class', 'backend-ref'], $conditions); @@ -516,7 +516,7 @@ class Photo DBA::close($photos); - return DBA::delete('photo', $conditions, $options); + return DBA::delete('photo', $conditions); } /** diff --git a/src/Model/Post.php b/src/Model/Post.php index 3439ce4846..111cd77cc4 100644 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -774,8 +774,8 @@ class Post * @return boolean was the delete successful? * @throws \Exception */ - public static function delete(array $conditions, array $options = []): bool + public static function delete(array $conditions): bool { - return DBA::delete('post', $conditions, $options); + return DBA::delete('post', $conditions); } } diff --git a/src/Model/Post/Content.php b/src/Model/Post/Content.php index dcb7b9be7e..e0a037ad9d 100644 --- a/src/Model/Post/Content.php +++ b/src/Model/Post/Content.php @@ -69,16 +69,13 @@ class Content * Delete a row from the post-content table * * @param array $conditions Field condition(s) - * @param array $options - * - cascade: If true we delete records in other tables that depend on the one we're deleting through - * relations (default: true) * * @return boolean was the delete successful? * @throws \Exception */ - public static function delete(array $conditions, array $options = []) + public static function delete(array $conditions) { - return DBA::delete('post-content', $conditions, $options); + return DBA::delete('post-content', $conditions); } diff --git a/src/Model/Post/Origin.php b/src/Model/Post/Origin.php index dafe52be6f..b3451fee8e 100644 --- a/src/Model/Post/Origin.php +++ b/src/Model/Post/Origin.php @@ -65,15 +65,12 @@ class Origin * Delete a row from the post-origin table * * @param array $conditions Field condition(s) - * @param array $options - * - cascade: If true we delete records in other tables that depend on the one we're deleting through - * relations (default: true) * * @return boolean was the delete successful? * @throws \Exception */ - public static function delete(array $conditions, array $options = []) + public static function delete(array $conditions) { - return DBA::delete('post-origin', $conditions, $options); + return DBA::delete('post-origin', $conditions); } } diff --git a/src/Model/Post/Thread.php b/src/Model/Post/Thread.php index fc714a5a76..b7f51f920a 100644 --- a/src/Model/Post/Thread.php +++ b/src/Model/Post/Thread.php @@ -68,15 +68,12 @@ class Thread * Delete a row from the post-thread table * * @param array $conditions Field condition(s) - * @param array $options - * - cascade: If true we delete records in other tables that depend on the one we're deleting through - * relations (default: true) * * @return boolean was the delete successful? * @throws \Exception */ - public static function delete(array $conditions, array $options = []) + public static function delete(array $conditions) { - return DBA::delete('post-thread', $conditions, $options); + return DBA::delete('post-thread', $conditions); } } diff --git a/src/Model/Post/ThreadUser.php b/src/Model/Post/ThreadUser.php index 6e06879cd8..8a5baf51ff 100644 --- a/src/Model/Post/ThreadUser.php +++ b/src/Model/Post/ThreadUser.php @@ -79,9 +79,9 @@ class ThreadUser * @return boolean was the delete successful? * @throws \Exception */ - public static function delete(array $conditions, array $options = []) + public static function delete(array $conditions) { - return DBA::delete('post-thread-user', $conditions, $options); + return DBA::delete('post-thread-user', $conditions); } /** diff --git a/src/Model/Post/User.php b/src/Model/Post/User.php index c1a74427cc..ec7f6b2c0f 100644 --- a/src/Model/Post/User.php +++ b/src/Model/Post/User.php @@ -109,15 +109,12 @@ class User * Delete a row from the post-user table * * @param array $conditions Field condition(s) - * @param array $options - * - cascade: If true we delete records in other tables that depend on the one we're deleting through - * relations (default: true) * * @return boolean was the delete successful? * @throws \Exception */ - public static function delete(array $conditions, array $options = []) + public static function delete(array $conditions) { - return DBA::delete('post-user', $conditions, $options); + return DBA::delete('post-user', $conditions); } } diff --git a/src/Model/Post/UserNotification.php b/src/Model/Post/UserNotification.php index f20d947c07..35c3d7891c 100644 --- a/src/Model/Post/UserNotification.php +++ b/src/Model/Post/UserNotification.php @@ -95,15 +95,13 @@ class UserNotification * Delete a row from the post-user-notification table * * @param array $conditions Field condition(s) - * @param array $options - cascade: If true we delete records in other tables that depend on the one we're deleting through - * relations (default: true) * * @return boolean was the deletion successful? * @throws Exception */ - public static function delete(array $conditions, array $options = []): bool + public static function delete(array $conditions): bool { - return DBA::delete('post-user-notification', $conditions, $options); + return DBA::delete('post-user-notification', $conditions); } /**