Enable Discovery debug logging for production troubleshooting

- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
2025-08-11 20:13:26 +02:00
parent 59fd3dd3b1
commit 55a330b223
3683 changed files with 2956207 additions and 16948 deletions

View File

@@ -1,7 +1,11 @@
<?php
declare(strict_types=1);
namespace App\Framework\Http;
use App\Framework\UserAgent\UserAgent;
/**
* Kapselt Server-Environment-Daten aus $_SERVER
*/
@@ -9,7 +13,8 @@ final readonly class ServerEnvironment
{
public function __construct(
private array $serverData = []
) {}
) {
}
public static function fromGlobals(): self
{
@@ -18,7 +23,7 @@ final readonly class ServerEnvironment
public function get(string|ServerKey $key, mixed $default = null): mixed
{
if($key instanceof ServerKey) {
if ($key instanceof ServerKey) {
$key = $key->value;
}
@@ -27,7 +32,7 @@ final readonly class ServerEnvironment
public function has(string|ServerKey $key): bool
{
!$key instanceof ServerKey ?: $key = $key->value;
! $key instanceof ServerKey ?: $key = $key->value;
return array_key_exists($key, $this->serverData);
}
@@ -36,12 +41,15 @@ final readonly class ServerEnvironment
public function getRemoteAddr(): IpAddress
{
$ip = $this->get(ServerKey::REMOTE_ADDR, '0.0.0.0');
return new IpAddress($ip);
}
public function getUserAgent(): string
public function getUserAgent(): UserAgent
{
return $this->get(ServerKey::HTTP_USER_AGENT, '');
$userAgentString = $this->get(ServerKey::HTTP_USER_AGENT, '');
return UserAgent::fromString($userAgentString);
}
public function getServerName(): string
@@ -57,6 +65,7 @@ final readonly class ServerEnvironment
public function getRequestUri(): Uri
{
$uriString = $this->get(ServerKey::REQUEST_URI, '/');
return new Uri($uriString);
}
@@ -80,6 +89,7 @@ final readonly class ServerEnvironment
public function getRequestMethod(): Method
{
$methodString = $this->get(ServerKey::REQUEST_METHOD, 'GET');
return Method::tryFrom($methodString) ?? Method::GET;
}
@@ -97,6 +107,12 @@ final readonly class ServerEnvironment
public function getProtocol(): ServerProtocol
{
$protocol = $this->get(ServerKey::SERVER_PROTOCOL);
// Handle null values in CLI context
if ($protocol === null) {
return ServerProtocol::HTTP_1_0;
}
return ServerProtocol::tryFrom($protocol) ?? ServerProtocol::HTTP_1_0;
}
@@ -106,7 +122,7 @@ final readonly class ServerEnvironment
$candidates = [
ServerKey::HTTP_X_REAL_IP,
ServerKey::HTTP_X_FORWARDED_FOR,
ServerKey::REMOTE_ADDR
ServerKey::REMOTE_ADDR,
];
foreach ($candidates as $key) {
@@ -115,8 +131,10 @@ final readonly class ServerEnvironment
// Bei X-Forwarded-For kann es mehrere IPs geben
if ($key === ServerKey::HTTP_X_FORWARDED_FOR) {
$ips = explode(',', $ip);
return trim($ips[0]);
}
return $ip;
}
}
@@ -141,7 +159,7 @@ final readonly class ServerEnvironment
*/
public function hasReferer(): bool
{
return !empty($this->get(ServerKey::HTTP_REFERER, null));
return ! empty($this->get(ServerKey::HTTP_REFERER, null));
}
/**
@@ -174,11 +192,10 @@ final readonly class ServerEnvironment
}
// Nur interne Referer erlauben (CSRF-Schutz)
if (!$this->isRefererSameDomain()) {
if (! $this->isRefererSameDomain()) {
return $fallback;
}
return $referer;
}
}