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;