From 44815f9c95a71808e2d0e0aa66f3ebc07dacc4c8 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Sat, 2 May 2026 02:06:52 +0200 Subject: [PATCH] adsads --- modules/mining-checker/assets/js/app.js | 1 + modules/mining-checker/src/Api/Router.php | 32 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/modules/mining-checker/assets/js/app.js b/modules/mining-checker/assets/js/app.js index 43e6d42..4711231 100644 --- a/modules/mining-checker/assets/js/app.js +++ b/modules/mining-checker/assets/js/app.js @@ -1229,6 +1229,7 @@ const data = await request(`${apiBase}/projects/${encodeURIComponent(projectKey)}/ocr-preview`, { method: 'POST', body, + timeoutMs: 45000, }); setOcrPreview(normalizeOcrPreview(data)); setMessage('OCR-Ergebnis geladen. Bei Bedarf direkt speichern.'); diff --git a/modules/mining-checker/src/Api/Router.php b/modules/mining-checker/src/Api/Router.php index 494e7bb..8a9c69b 100644 --- a/modules/mining-checker/src/Api/Router.php +++ b/modules/mining-checker/src/Api/Router.php @@ -102,6 +102,7 @@ final class Router $projectKey = $matches[1]; $resource = trim((string) ($matches[2] ?? ''), '/'); + $this->applyRouteRuntimeGuards($resource); if ($resource === 'schema-status' && $method === 'GET') { $this->respond(['data' => $this->simpleSchemaStatus()]); @@ -188,7 +189,19 @@ final class Router throw new ApiException('Feld image fehlt.', 422); } + $ocrStartedAt = microtime(true); + $this->debug->add('ocr.preview.start', [ + 'project_key' => $projectKey, + 'file_name' => $_FILES['image']['name'] ?? null, + 'file_size' => $_FILES['image']['size'] ?? null, + ]); $preview = $this->ocr->preview($_FILES['image'], array_merge($_POST, ['project_key' => $projectKey])); + $this->debug->add('ocr.preview.end', [ + 'project_key' => $projectKey, + 'duration_ms' => round((microtime(true) - $ocrStartedAt) * 1000, 2), + 'confidence' => $preview['confidence'] ?? null, + 'flags' => is_array($preview['flags'] ?? null) ? $preview['flags'] : [], + ]); Http::json(['data' => $preview], 201); } @@ -2352,6 +2365,25 @@ final class Router ]); } + private function applyRouteRuntimeGuards(string $resource): void + { + $normalized = trim(strtolower($resource)); + $timeLimit = match ($normalized) { + 'ocr-preview' => 45, + 'measurements-import', 'legacy-fx-migrate', 'sql-import' => 60, + default => 15, + }; + + if (function_exists('set_time_limit')) { + @set_time_limit($timeLimit); + } + + $this->debug->add('runtime.route_guards', [ + 'resource' => $resource, + 'time_limit_sec' => $timeLimit, + ]); + } + private function releaseSessionLock(): void { if (PHP_SAPI === 'cli') {