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