web/api/ki: Soft Deletes wieder wirksam, Caches bei Firmenwechsel, KI-Ergebnis an Inhalt gebunden (Audit Block 3+4, Deploy D)
Block 3 — Sichtbarkeit, Löschung, Cache, Eingaben F04: withoutGlobalScopes() ohne Argument entfernte neben dem PortalScope auch den Soft-Delete-Filter. Öffentliche, Kunden-, API-, Vorschau- und Medienpfade sowie die PressRelease-Helfer schreiben jetzt withoutGlobalScope(PortalScope::class). Zwei Stellen, die der Audit nicht kannte: die öffentliche Meldungsseite zeigte gelöschte Firmenkontakte mit Name, Mail und Telefon; das Pressefach listete gelöschte Kontakte weiter und ließ sie bearbeiten. Ein Architekturtest friert die 39 bewusst verbliebenen Stellen (Admin, Importer, Befehle, Slug-Eindeutigkeit) ein. Der Vorschau-Test prüfte bisher forceDelete statt delete. F22: LOWER(email) machte auf companies (110k Zeilen) bei jedem Login einen Vollscan; die Kollation ist ohnehin case-insensitiv. EmailQuery vergleicht auf MySQL direkt über den Index, auf SQLite (Tests) weiter per LOWER. Neuer Index contacts_email_idx. F13: Firmen-Observer verwirft die öffentlichen Seiten-Caches bei Löschung, Wiederherstellung und is_active-Wechsel auf jedem Weg; die Newsroom-Seite prüft Sichtbarkeit vor dem Cache-Treffer; Kontakt- Änderungen im Pressefach flushen. Der Tombstone-Test wärmte den Cache vorher nicht und traf den Fehler nie. F12: Gemeldete URLs werden über Host, Ausgabe und Slug aufgelöst (ReportedUrlResolver); fremde Hosts zählen nicht, bei Doppelveröffentlichung gewinnt die Erstquelle. F11: per_page 1–100, status als Enum, language nur de/en, Kategorie muss aktiv sein und zum Ziel-Portal passen. Legacy-Aliasse behalten ihren Vertrag. F23: Rückgabewert von put() wird geprüft; Logo erst speichern, dann Datenbank, dann altes Logo löschen. Fehler enden als Feldfehler, nicht als verlorenes Logo. Block 4 — KI-Prüfung und Scheduler F07: Klassifikation und Score tragen die Prüfsumme des Inhalts bei Einplanung. Weicht sie beim Speichern ab, wird das Ergebnis verworfen (ki_audits.discarded_at) und ein neuer Lauf eingeplant. Der Scheduler veröffentlicht keine Meldung, deren jüngste Klassifikation nicht zum aktuellen Text passt, sondern plant eine Prüfung mit Routing ein. F18: Kontingent an den Kalendermonat gebunden (users.press_release_quota_period). Verbrauch aus einem früheren Monat zählt null, auch ohne Reset-Cron; der Reset ist idempotent und lässt den laufenden Monat in Ruhe. F20: Der Publikations-Scheduler liefert bei technischen Fehlern einen Fehler-Exit-Code, damit der Failure-Hook greift. F17: KI-Jobs mit $timeout = 120, retry_after 150; Runbook ergänzt. F19: Aggregation der Aufrufe unter einem Cache-Lock für alle Einstiege. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
301bca3a90
commit
72432fdb82
73 changed files with 1746 additions and 170 deletions
|
|
@ -145,41 +145,68 @@ new #[Layout('components.layouts.app'), Title('Firma bearbeiten')] class extends
|
|||
}
|
||||
|
||||
$slug = $company->generateUniqueSlug($this->company_name, ['portal' => $this->portal]);
|
||||
$logoPath = $company->logo_path;
|
||||
$logoVariants = $company->logo_variants;
|
||||
$previousLogoPath = $company->logo_path;
|
||||
$previousLogoVariants = $company->logo_variants;
|
||||
$logoPath = $previousLogoPath;
|
||||
$logoVariants = $previousLogoVariants;
|
||||
$discardPreviousLogo = false;
|
||||
$stored = null;
|
||||
|
||||
if ($this->remove_logo) {
|
||||
$imageService->deleteCompanyLogo($company->logo_path, $company->logo_variants);
|
||||
$logoPath = null;
|
||||
$logoVariants = null;
|
||||
$discardPreviousLogo = true;
|
||||
}
|
||||
|
||||
if ($this->logo) {
|
||||
$imageService->deleteCompanyLogo($logoPath, $logoVariants);
|
||||
// Erst die neue Datei speichern, dann die DB-Referenz wechseln, das
|
||||
// alte Logo erst danach löschen: Scheitert der Storage, bleiben
|
||||
// bisheriges Logo und Datensatz unangetastet (F23).
|
||||
try {
|
||||
$stored = $imageService->storeCompanyLogo(
|
||||
$this->logo,
|
||||
$this->portal === Portal::Both->value ? Portal::Presseecho->value : $this->portal,
|
||||
$company->id,
|
||||
);
|
||||
} catch (\RuntimeException $exception) {
|
||||
report($exception);
|
||||
|
||||
$stored = $imageService->storeCompanyLogo(
|
||||
$this->logo,
|
||||
$this->portal === Portal::Both->value ? Portal::Presseecho->value : $this->portal,
|
||||
$company->id,
|
||||
);
|
||||
throw ValidationException::withMessages([
|
||||
'logo' => __('Das Logo konnte nicht gespeichert werden. Bitte versuchen Sie es erneut.'),
|
||||
]);
|
||||
}
|
||||
|
||||
$logoPath = $stored['path'];
|
||||
$logoVariants = $stored['variants'];
|
||||
$discardPreviousLogo = true;
|
||||
}
|
||||
|
||||
$company->update([
|
||||
'portal' => $this->portal,
|
||||
'name' => $this->company_name,
|
||||
'slug' => $slug,
|
||||
'address' => $this->composeAddress(),
|
||||
'country_code' => strtoupper($this->country),
|
||||
'phone' => $this->phone ?: null,
|
||||
'email' => $this->email ?: null,
|
||||
'website' => $this->website ?: null,
|
||||
'logo_path' => $logoPath,
|
||||
'logo_variants' => $logoVariants,
|
||||
'is_active' => $this->is_active,
|
||||
]);
|
||||
try {
|
||||
$company->update([
|
||||
'portal' => $this->portal,
|
||||
'name' => $this->company_name,
|
||||
'slug' => $slug,
|
||||
'address' => $this->composeAddress(),
|
||||
'country_code' => strtoupper($this->country),
|
||||
'phone' => $this->phone ?: null,
|
||||
'email' => $this->email ?: null,
|
||||
'website' => $this->website ?: null,
|
||||
'logo_path' => $logoPath,
|
||||
'logo_variants' => $logoVariants,
|
||||
'is_active' => $this->is_active,
|
||||
]);
|
||||
} catch (\Throwable $exception) {
|
||||
// Ohne DB-Referenz wäre die neue Datei verwaist.
|
||||
if ($stored !== null) {
|
||||
$imageService->deleteCompanyLogo($stored['path'], $stored['variants']);
|
||||
}
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
if ($discardPreviousLogo && $previousLogoPath !== null && $previousLogoPath !== $logoPath) {
|
||||
$imageService->deleteCompanyLogo($previousLogoPath, $previousLogoVariants);
|
||||
}
|
||||
|
||||
session()->flash('success', 'Firma erfolgreich aktualisiert.');
|
||||
$this->redirect(route('admin.companies.index'), navigate: true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue