mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user