This commit is contained in:
2026-02-03 23:59:17 +01:00
parent e282004786
commit b7729be6d9
3 changed files with 180 additions and 31 deletions

View File

@@ -2987,6 +2987,9 @@ class ApiKernel
case 'debug.logs.read':
$this->handleDebugLogsRead();
break;
case 'debug.log.write':
$this->handleDebugLogWrite();
break;
case 'placeholders.status':
$this->handlePlaceholderStatus();
break;
@@ -4249,6 +4252,35 @@ class ApiKernel
$this->respond(['ok' => true, 'content' => $content]);
}
private function handleDebugLogWrite(): void
{
$user = $this->requireAuth();
$this->ensureDebugUser($user);
$this->ensureDebugEnv();
$name = trim((string)($this->in['name'] ?? 'ui_editor_dirty.log'));
$line = $this->in['line'] ?? '';
$append = (int)($this->in['append'] ?? 1) === 1;
if ($name === '') {
$this->fail('Log name required', null, 422);
}
$name = preg_replace('/[^a-zA-Z0-9_\.\-]/', '', $name) ?: 'debug.log';
if (strpos($name, '..') !== false) {
$this->fail('Invalid log name', null, 422);
}
$payload = $line;
if (is_array($payload) || is_object($payload)) {
$payload = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
} else {
$payload = (string)$payload;
}
debug_log_write($name, $payload, [
'append' => $append,
'json' => false,
'newline' => true,
]);
$this->respond(['ok' => true, 'name' => $name]);
}
private function resolveBridgeConfig(?int $customerId): array
{
$fileConf = $this->conf['placeholders']['bridge'] ?? [];