Refactor date handling to use DateTime directly and improve PDO usage consistency
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 / test (push) Blocked by required conditions
CI / generate-phpdoc (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
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 / test (push) Blocked by required conditions
CI / generate-phpdoc (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:
parent
e42505873c
commit
14ed24049e
10 changed files with 29 additions and 17 deletions
9
main
9
main
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
|
||||
if (PHP_SAPI !== 'cli')
|
||||
use FederationServer\Program;
|
||||
use ncc\Classes\Runtime;
|
||||
|
||||
if (PHP_SAPI !== 'cli')
|
||||
{
|
||||
print('net.nosial.federation must be run from the command line.' . PHP_EOL);
|
||||
exit(1);
|
||||
|
@ -20,5 +23,5 @@
|
|||
}
|
||||
|
||||
require('ncc');
|
||||
\ncc\Classes\Runtime::import('net.nosial.federation', 'latest');
|
||||
exit(\FederationServer\Program::main($argv));
|
||||
Runtime::import('net.nosial.federation', 'latest');
|
||||
exit(Program::main($argv));
|
|
@ -6,6 +6,7 @@
|
|||
use FederationServer\Exceptions\DatabaseOperationException;
|
||||
use FederationServer\Objects\EvidenceRecord;
|
||||
use InvalidArgumentException;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
|
||||
class EvidenceManager
|
||||
|
@ -91,7 +92,7 @@
|
|||
$stmt->bindParam(':uuid', $uuid);
|
||||
$stmt->execute();
|
||||
|
||||
$data = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$data = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if($data)
|
||||
{
|
||||
return new EvidenceRecord($data);
|
||||
|
@ -124,7 +125,7 @@
|
|||
$stmt->bindParam(':entity', $entity);
|
||||
$stmt->execute();
|
||||
|
||||
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$evidenceRecords = [];
|
||||
foreach ($results as $data)
|
||||
{
|
||||
|
@ -160,7 +161,7 @@
|
|||
$stmt->bindParam(':operator', $operator);
|
||||
$stmt->execute();
|
||||
|
||||
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$evidenceRecords = [];
|
||||
foreach ($results as $data)
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
use FederationServer\Exceptions\DatabaseOperationException;
|
||||
use FederationServer\Objects\OperatorRecord;
|
||||
use InvalidArgumentException;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
|
@ -251,7 +252,7 @@
|
|||
try
|
||||
{
|
||||
$stmt = DatabaseConnection::getConnection()->prepare("UPDATE operators SET manage_operators=:manage_operators WHERE uuid=:uuid");
|
||||
$stmt->bindParam(':manage_operators', $canManageOperators, \PDO::PARAM_BOOL);
|
||||
$stmt->bindParam(':manage_operators', $canManageOperators, PDO::PARAM_BOOL);
|
||||
$stmt->bindParam(':uuid', $uuid);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
@ -279,7 +280,7 @@
|
|||
try
|
||||
{
|
||||
$stmt = DatabaseConnection::getConnection()->prepare("UPDATE operators SET manage_blacklist=:manage_blacklist WHERE uuid=:uuid");
|
||||
$stmt->bindParam(':manage_blacklist', $canManageBlacklist, \PDO::PARAM_BOOL);
|
||||
$stmt->bindParam(':manage_blacklist', $canManageBlacklist, PDO::PARAM_BOOL);
|
||||
$stmt->bindParam(':uuid', $uuid);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
@ -307,7 +308,7 @@
|
|||
try
|
||||
{
|
||||
$stmt = DatabaseConnection::getConnection()->prepare("UPDATE operators SET is_client=:is_client WHERE uuid=:uuid");
|
||||
$stmt->bindParam(':is_client', $isClient, \PDO::PARAM_BOOL);
|
||||
$stmt->bindParam(':is_client', $isClient, PDO::PARAM_BOOL);
|
||||
$stmt->bindParam(':uuid', $uuid);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
use Redis;
|
||||
use FederationServer\Classes\Configuration;
|
||||
use FederationServer\Classes\Configuration\RedisConfiguration;
|
||||
use RedisException;
|
||||
|
||||
class RedisConnection
|
||||
{
|
||||
|
@ -14,7 +15,7 @@
|
|||
* Get the Redis connection instance. If it does not exist, create it using the configuration.
|
||||
*
|
||||
* @return Redis|null Returns Redis instance if enabled, otherwise null.
|
||||
* @throws \RedisException
|
||||
* @throws RedisException
|
||||
*/
|
||||
public static function getConnection(): ?Redis
|
||||
{
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
namespace FederationServer\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class DatabaseOperationException extends \Exception
|
||||
class DatabaseOperationException extends Exception
|
||||
{
|
||||
/**
|
||||
* DatabaseOperationException constructor.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace FederationServer\Objects;
|
||||
|
||||
use DateTime;
|
||||
use FederationServer\Classes\Enums\AuditLogType;
|
||||
use FederationServer\Interfaces\SerializableInterface;
|
||||
|
||||
|
@ -115,7 +116,7 @@
|
|||
{
|
||||
$array['timestamp'] = strtotime($array['timestamp']);
|
||||
}
|
||||
elseif($array['timestamp'] instanceof \DateTime)
|
||||
elseif($array['timestamp'] instanceof DateTime)
|
||||
{
|
||||
$array['timestamp'] = $array['timestamp']->getTimestamp();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace FederationServer\Objects;
|
||||
|
||||
use DateTime;
|
||||
use FederationServer\Classes\Enums\BlacklistType;
|
||||
use FederationServer\Interfaces\SerializableInterface;
|
||||
|
||||
|
@ -127,7 +128,7 @@
|
|||
{
|
||||
$array['expires'] = strtotime($array['expires']);
|
||||
}
|
||||
elseif($array['expires'] instanceof \DateTime)
|
||||
elseif($array['expires'] instanceof DateTime)
|
||||
{
|
||||
$array['expires'] = $array['expires']->getTimestamp();
|
||||
}
|
||||
|
@ -139,7 +140,7 @@
|
|||
{
|
||||
$array['created'] = strtotime($array['created']);
|
||||
}
|
||||
elseif($array['created'] instanceof \DateTime)
|
||||
elseif($array['created'] instanceof DateTime)
|
||||
{
|
||||
$array['created'] = $array['created']->getTimestamp();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace FederationServer\Objects;
|
||||
|
||||
use DateTime;
|
||||
use FederationServer\Interfaces\SerializableInterface;
|
||||
|
||||
class EntityRecord implements SerializableInterface
|
||||
|
@ -92,7 +93,7 @@
|
|||
{
|
||||
$array['created'] = strtotime($array['created']);
|
||||
}
|
||||
elseif($array['created'] instanceof \DateTime)
|
||||
elseif($array['created'] instanceof DateTime)
|
||||
{
|
||||
$array['created'] = $array['created']->getTimestamp();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace FederationServer\Objects;
|
||||
|
||||
use DateTime;
|
||||
use FederationServer\Interfaces\SerializableInterface;
|
||||
|
||||
class EvidenceRecord implements SerializableInterface
|
||||
|
@ -128,7 +129,7 @@
|
|||
{
|
||||
$array['created'] = strtotime($array['created']);
|
||||
}
|
||||
elseif($array['created'] instanceof \DateTime)
|
||||
elseif($array['created'] instanceof DateTime)
|
||||
{
|
||||
$array['created'] = $array['created']->getTimestamp();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace FederationServer\Objects;
|
||||
|
||||
use DateTime;
|
||||
use FederationServer\Interfaces\SerializableInterface;
|
||||
|
||||
class FileAttachmentRecord implements SerializableInterface
|
||||
|
@ -107,7 +108,7 @@
|
|||
{
|
||||
$array['created'] = strtotime($array['created']);
|
||||
}
|
||||
elseif($array['created'] instanceof \DateTime)
|
||||
elseif($array['created'] instanceof DateTime)
|
||||
{
|
||||
$array['created'] = $array['created']->getTimestamp();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue