From 3f05ac1736de680b525357e4a4ee5e66c4fe755a Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 13 Aug 2026 15:05:53 +0530 Subject: [PATCH] Stop the template lists shipping their ranking score Both template lists hand raw config rows to dynamic(), so score - internal ranking used only to sort the list - went out with them. The single-template endpoints already build a Document and were unaffected. Site templates also gain demoUrl, which the model declares and the config omits, so it now reports its default rather than being absent. --- .../Platform/Modules/Functions/Http/Templates/XList.php | 5 ++++- src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php | 5 ++++- tests/e2e/Services/Sites/SitesCustomClientTest.php | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php index f334351fef..3b1f24c1d2 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php @@ -81,7 +81,10 @@ class XList extends Base }); $total = $includeTotal ? \count($templates) : 0; - $templates = \array_slice($templates, $offset, $limit); + $templates = \array_map( + fn (array $template) => new Document($template), + \array_slice($templates, $offset, $limit) + ); $response->dynamic(new Document([ 'templates' => $templates, 'total' => $total, diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php index 722cf986f8..56f7eb0fee 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php @@ -84,7 +84,10 @@ class XList extends Base }); $total = \count($templates); - $templates = \array_slice($templates, $offset, $limit); + $templates = \array_map( + fn (array $template) => new Document($template), + \array_slice($templates, $offset, $limit) + ); $response->dynamic(new Document([ 'templates' => $templates, 'total' => $total, diff --git a/tests/e2e/Services/Sites/SitesCustomClientTest.php b/tests/e2e/Services/Sites/SitesCustomClientTest.php index 1e9abcb411..c498ea024e 100644 --- a/tests/e2e/Services/Sites/SitesCustomClientTest.php +++ b/tests/e2e/Services/Sites/SitesCustomClientTest.php @@ -117,7 +117,7 @@ final class SitesCustomClientTest extends Scope $this->assertEquals(400, $templates['headers']['status-code']); } - public function testListTemplatesHidesStartCommand() + public function testListTemplatesHidesInternalFields() { $templates = $this->client->call(Client::METHOD_GET, '/sites/templates', array_merge([ 'content-type' => 'application/json', @@ -130,6 +130,7 @@ final class SitesCustomClientTest extends Scope $this->assertGreaterThan(0, $templates['body']['total']); $this->assertStringNotContainsString('startCommand', (string) json_encode($templates['body'])); + $this->assertStringNotContainsString('score', (string) json_encode($templates['body'])); $template = $this->getTemplate('starter-for-nextjs');