Simplify sanitizeErrors now that jsonSerialize doesn't emit trace

With Migration\Exception::jsonSerialize() no longer including the stack
trace, sanitizeErrors no longer needs to decode/strip/re-encode each
entry. Reduce it to a single json_encode pass.
This commit is contained in:
Prem Palanisamy
2026-05-04 07:27:27 +01:00
parent 4703e4ba14
commit c2e4bc2ae3
+5 -15
View File
@@ -857,7 +857,7 @@ class Migrations extends Action
}
/**
* Sanitize migration errors, removing sensitive information like stack traces
* Encode migration errors as JSON strings for storage on the migration document.
*
* @param array $sourceErrors
* @param array $destinationErrors
@@ -867,20 +867,10 @@ class Migrations extends Action
array $sourceErrors,
array $destinationErrors,
): array {
$errors = [];
foreach ([...$sourceErrors, ...$destinationErrors] as $error) {
$encoded = \json_decode(\json_encode($error), true);
if (\is_array($encoded)) {
if (isset($encoded['trace'])) {
unset($encoded['trace']);
}
$errors[] = \json_encode($encoded);
} else {
$errors[] = \json_encode($error);
}
}
return $errors;
return \array_map(
fn ($error) => \json_encode($error),
[...$sourceErrors, ...$destinationErrors],
);
}
private function processMigrationResourceStats(array $resources, Context $usage, Document $projectDocument, UsagePublisher $publisherForUsage, string $source, Authorization $authorization, ?string $resourceId)