mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Filter model rules handed raw arrays, in one place
The three endpoints wrapping their own rows were fixing the same thing three times, and the next config-backed list would have leaked again. Coerce in output() instead, restricted to array rules naming one model. That covers every list fed from config while leaving the single-value branch alone, so hashOptions keeps passing through as it does today - filtering it would rename memory_cost to an empty memoryCost. Unions stay excluded: only the branch below can pick their model per item.
This commit is contained in:
1 parent
3f05ac1736
commit
79af0f21fc
4 files changed
+9
-17
No files matched your search
@@ -81,10 +81,7 @@ class XList extends Base
|
||||
});
|
||||
|
||||
$total = $includeTotal ? \count($templates) : 0;
|
||||
$templates = \array_map(
|
||||
fn (array $template) => new Document($template),
|
||||
\array_slice($templates, $offset, $limit)
|
||||
);
|
||||
$templates = \array_slice($templates, $offset, $limit);
|
||||
$response->dynamic(new Document([
|
||||
'templates' => $templates,
|
||||
'total' => $total,
|
||||
|
||||
@@ -79,17 +79,9 @@ class XList extends Base
|
||||
}
|
||||
}
|
||||
|
||||
// Response models only filter nested Documents; plain arrays ship every key they carry.
|
||||
$frameworks = \array_map(fn (array $framework) => new Document(\array_replace($framework, [
|
||||
'adapters' => \array_map(
|
||||
fn (array $adapter) => new Document($adapter),
|
||||
$framework['adapters'] ?? []
|
||||
),
|
||||
])), \array_values($frameworks));
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'total' => count($frameworks),
|
||||
'frameworks' => $frameworks
|
||||
'frameworks' => \array_values($frameworks)
|
||||
]), Response::MODEL_FRAMEWORK_LIST);
|
||||
}
|
||||
}
|
||||
@@ -84,10 +84,7 @@ class XList extends Base
|
||||
});
|
||||
|
||||
$total = \count($templates);
|
||||
$templates = \array_map(
|
||||
fn (array $template) => new Document($template),
|
||||
\array_slice($templates, $offset, $limit)
|
||||
);
|
||||
$templates = \array_slice($templates, $offset, $limit);
|
||||
$response->dynamic(new Document([
|
||||
'templates' => $templates,
|
||||
'total' => $total,
|
||||
|
||||
@@ -562,6 +562,12 @@ class Response extends SwooleResponse
|
||||
}
|
||||
|
||||
foreach ($data[$key] as $index => $item) {
|
||||
// Config rows arrive as plain arrays and would ship every key they carry.
|
||||
// Unions are skipped: only the branch below can pick their model per item.
|
||||
if (\is_array($item) && !\is_array($rule['type']) && self::hasModel($rule['type'])) {
|
||||
$item = new Document($item);
|
||||
}
|
||||
|
||||
if ($item instanceof Document) {
|
||||
$ruleType = null;
|
||||
|
||||
|
||||
Reference in new issue
Block a user