Kurzbeschreibung Versteckt die Rerun-Row-Action für archivierte (soft-deleted) RestoreRuns und verhindert damit fehlerhafte Neu-Starts aus dem Archiv; ergänzt einen Regressionstest. Änderungen Code: RestoreRunResource.php — Sichtbarkeit der rerun-Action geprüft auf ! $record->trashed() und defensive Abbruchprüfung im Action-Handler. Tests: RestoreRunRerunTest.php — neuer Test rerun action is hidden for archived restore runs. Warum Archivierte RestoreRuns durften nicht neu gestartet werden; UI zeigte trotzdem die Option. Das führte zu verwirrendem Verhalten und möglichen Fehlern beim Enqueueing. Verifikation / QA Unit/Feature: ./vendor/bin/sail artisan test tests/Feature/RestoreRunRerunTest.php Stil/format: ./vendor/bin/pint --dirty Manuell (UI): Als Tenant-Admin Filament → Restore Runs öffnen. Filter Archived aktivieren (oder Trashed filter auswählen). Sicherstellen, dass für archivierte Einträge die Rerun-Action nicht sichtbar ist. Auf einem aktiven (nicht-archivierten) Run prüfen, dass Rerun sichtbar bleibt und wie erwartet eine neue RestoreRun erzeugt. Wichtige Hinweise Kein DB-Migration required. Diese PR enthält nur den UI-/Filament-Fix; die zuvor gemachten operative Fixes für Queue/adapter-Reconciliation bleiben ebenfalls auf dem Branch (z. B. frühere commits während der Debugging-Session). T055 (Schema squash) wurde bewusst zurückgestellt und ist nicht Teil dieses PRs. Merge-Checklist Tests lokal laufen (RestoreRunRerunTest grünt) Pint läuft ohne ungepatchte Fehler Branch gepusht: 056-remove-legacy-bulkops (PR-URL: https://git.cloudarix.de/ahmido/TenantAtlas/compare/dev...056-remove-legacy-bulkops) Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #65
88 lines
2.0 KiB
PHP
88 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Operations;
|
|
|
|
final class BulkSelectionIdentity
|
|
{
|
|
/**
|
|
* @param array<int, mixed> $ids
|
|
* @return array{kind: 'ids', ids_hash: string, ids_count: int}
|
|
*/
|
|
public function fromIds(array $ids): array
|
|
{
|
|
$normalized = [];
|
|
|
|
foreach ($ids as $id) {
|
|
if (is_int($id)) {
|
|
$normalized[] = (string) $id;
|
|
|
|
continue;
|
|
}
|
|
|
|
if (! is_string($id)) {
|
|
continue;
|
|
}
|
|
|
|
$id = trim($id);
|
|
if ($id === '') {
|
|
continue;
|
|
}
|
|
|
|
$normalized[] = $id;
|
|
}
|
|
|
|
$normalized = array_values(array_unique($normalized));
|
|
sort($normalized);
|
|
|
|
$json = json_encode($normalized, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
|
|
|
return [
|
|
'kind' => 'ids',
|
|
'ids_hash' => hash('sha256', $json),
|
|
'ids_count' => count($normalized),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $queryPayload
|
|
* @return array{kind: 'query', query_hash: string}
|
|
*/
|
|
public function fromQuery(array $queryPayload): array
|
|
{
|
|
$json = $this->canonicalJson($queryPayload);
|
|
|
|
return [
|
|
'kind' => 'query',
|
|
'query_hash' => hash('sha256', $json),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $payload
|
|
*/
|
|
public function canonicalJson(array $payload): string
|
|
{
|
|
$normalized = $this->ksortRecursive($payload);
|
|
|
|
return (string) json_encode($normalized, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
private function ksortRecursive(mixed $value): mixed
|
|
{
|
|
if (! is_array($value)) {
|
|
return $value;
|
|
}
|
|
|
|
$isList = array_is_list($value);
|
|
if (! $isList) {
|
|
ksort($value);
|
|
}
|
|
|
|
foreach ($value as $key => $child) {
|
|
$value[$key] = $this->ksortRecursive($child);
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
}
|