Refactor FileAttachmentManager to use PDO directly for fetching records

This commit is contained in:
netkas 2025-05-29 21:21:47 -04:00
parent 7f596b3d2b
commit 1d43524679
Signed by: netkas
GPG key ID: 4D8629441B76E4CC

View file

@ -6,6 +6,7 @@
use FederationServer\Exceptions\DatabaseOperationException; use FederationServer\Exceptions\DatabaseOperationException;
use FederationServer\Objects\FileAttachmentRecord; use FederationServer\Objects\FileAttachmentRecord;
use InvalidArgumentException; use InvalidArgumentException;
use PDO;
use PDOException; use PDOException;
class FileAttachmentManager class FileAttachmentManager
@ -63,7 +64,7 @@
$stmt->bindParam(':uuid', $uuid); $stmt->bindParam(':uuid', $uuid);
$stmt->execute(); $stmt->execute();
$result = $stmt->fetch(\PDO::FETCH_ASSOC); $result = $stmt->fetch(PDO::FETCH_ASSOC);
if($result === false) if($result === false)
{ {
return null; // No record found return null; // No record found
@ -92,7 +93,7 @@
$stmt->bindParam(':evidence', $evidence); $stmt->bindParam(':evidence', $evidence);
$stmt->execute(); $stmt->execute();
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC); $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
return array_map(fn($data) => new FileAttachmentRecord($data), $results); return array_map(fn($data) => new FileAttachmentRecord($data), $results);
} }
catch (PDOException $e) catch (PDOException $e)