[Web] update directorytree/ldaprecord
This commit is contained in:
@@ -62,7 +62,7 @@ class Connection
|
||||
$context = array_filter($context);
|
||||
$encodedPayload = base64_encode(serialize([$data, $context]))."\n";
|
||||
|
||||
set_error_handler([self::class, 'nullErrorHandler']);
|
||||
set_error_handler(static fn () => null);
|
||||
try {
|
||||
if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) {
|
||||
return true;
|
||||
@@ -82,16 +82,14 @@ class Connection
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function nullErrorHandler(int $t, string $m)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource|null
|
||||
*/
|
||||
private function createSocket()
|
||||
{
|
||||
set_error_handler([self::class, 'nullErrorHandler']);
|
||||
set_error_handler(static fn () => null);
|
||||
try {
|
||||
return stream_socket_client($this->host, $errno, $errstr, 3, \STREAM_CLIENT_CONNECT | \STREAM_CLIENT_ASYNC_CONNECT);
|
||||
return stream_socket_client($this->host, $errno, $errstr, 3) ?: null;
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
class DumpServer
|
||||
{
|
||||
private string $host;
|
||||
private $logger;
|
||||
private ?LoggerInterface $logger;
|
||||
|
||||
/**
|
||||
* @var resource|null
|
||||
*/
|
||||
private $socket;
|
||||
|
||||
public function __construct(string $host, LoggerInterface $logger = null)
|
||||
public function __construct(string $host, ?LoggerInterface $logger = null)
|
||||
{
|
||||
if (!str_contains($host, '://')) {
|
||||
$host = 'tcp://'.$host;
|
||||
@@ -56,25 +56,19 @@ class DumpServer
|
||||
}
|
||||
|
||||
foreach ($this->getMessages() as $clientId => $message) {
|
||||
if ($this->logger) {
|
||||
$this->logger->info('Received a payload from client {clientId}', ['clientId' => $clientId]);
|
||||
}
|
||||
$this->logger?->info('Received a payload from client {clientId}', ['clientId' => $clientId]);
|
||||
|
||||
$payload = @unserialize(base64_decode($message), ['allowed_classes' => [Data::class, Stub::class]]);
|
||||
|
||||
// Impossible to decode the message, give up.
|
||||
if (false === $payload) {
|
||||
if ($this->logger) {
|
||||
$this->logger->warning('Unable to decode a message from {clientId} client.', ['clientId' => $clientId]);
|
||||
}
|
||||
$this->logger?->warning('Unable to decode a message from {clientId} client.', ['clientId' => $clientId]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!\is_array($payload) || \count($payload) < 2 || !$payload[0] instanceof Data || !\is_array($payload[1])) {
|
||||
if ($this->logger) {
|
||||
$this->logger->warning('Invalid payload from {clientId} client. Expected an array of two elements (Data $data, array $context)', ['clientId' => $clientId]);
|
||||
}
|
||||
$this->logger?->warning('Invalid payload from {clientId} client. Expected an array of two elements (Data $data, array $context)', ['clientId' => $clientId]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user