From 79af0f21fc359269e91fa1485675ecab7a4500a4 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 13 Aug 2026 15:56:07 +0530 Subject: [PATCH] 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. --- .../Modules/Functions/Http/Templates/XList.php | 5 +---- .../Platform/Modules/Sites/Http/Frameworks/XList.php | 10 +--------- .../Platform/Modules/Sites/Http/Templates/XList.php | 5 +---- src/Appwrite/Utopia/Response.php | 6 ++++++ 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php index 3b1f24c1d2..f334351fef 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php @@ -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, diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php index 52ddc1d53e..e49ace4486 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php @@ -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); } } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php index 56f7eb0fee..722cf986f8 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php @@ -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, diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index aa261a320b..7d48dfd766 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -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;