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');