Add getEntry method to AuditLogManager for retrieving audit log entries by UUID
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions

This commit is contained in:
netkas 2025-06-03 17:23:47 -04:00
parent 13e128591f
commit 1b7d11e009
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
2 changed files with 36 additions and 0 deletions

View file

@ -75,6 +75,41 @@
}
}
/**
* Retrieves a specific audit log entry by its UUID.
*
* @param string $uuid The UUID of the audit log entry to retrieve.
* @return AuditLogRecord|null An AuditLogRecord object representing the entry, or null if not found.
* @throws InvalidArgumentException If the UUID is empty.
* @throws DatabaseOperationException If there is an error preparing or executing the SQL statement.
*/
public static function getEntry(string $uuid): ?AuditLogRecord
{
if(strlen($uuid) === 0)
{
throw new InvalidArgumentException("UUID cannot be empty.");
}
try
{
$stmt = DatabaseConnection::getConnection()->prepare("SELECT * FROM audit_log WHERE uuid = :uuid");
$stmt->bindParam(':uuid', $uuid);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if ($result === false)
{
return null; // No entry found
}
return new AuditLogRecord($result);
}
catch (PDOException $e)
{
throw new DatabaseOperationException("Failed to retrieve audit log entry: " . $e->getMessage(), 0, $e);
}
}
/**
* Retrieves audit log entries with optional pagination and filtering.
*

View file

@ -6,6 +6,7 @@
use FederationServer\Classes\Managers\EntitiesManager;
use FederationServer\Classes\Managers\OperatorManager;
use FederationServer\Classes\RequestHandler;
use FederationServer\Classes\Validate;
use FederationServer\Exceptions\DatabaseOperationException;
use FederationServer\Exceptions\RequestException;
use FederationServer\FederationServer;