From c0efc232ad2b625711fbd9154633f42d25443493 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 14 Jul 2024 11:31:02 +0545 Subject: [PATCH] Fix warning when optional attribute doesn't exist When an attribute required is set to `false` and the attribute doesn't exist in the response, we get warning `undefined array key "attribute"` in the console, this update prevents that error --- src/Appwrite/Utopia/Response.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 6601a36075..5b7ac04db2 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -590,6 +590,10 @@ class Response extends SwooleResponse } } + if(!$data->isSet($key) && !$rule['required']) { // skip attribute in response if not required and values does not exist + continue; + } + if ($rule['array']) { if (!is_array($data[$key])) { throw new Exception($key . ' must be an array of type ' . $rule['type']);