From 89afad1a32ae304da2fa92f2823beb4bcd3cc9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 19 Sep 2022 11:58:41 +0000 Subject: [PATCH 1/3] Replace nulls with empty strings --- app/controllers/api/functions.php | 18 +++++++++--------- app/workers/functions.php | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index f42d1059e0..9c6e92d41e 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1066,21 +1066,21 @@ App::post('/v1/functions/:functionId/executions') } $vars = array_reduce($function['vars'] ?? [], function (array $carry, Document $var) { - $carry[$var->getAttribute('key')] = $var->getAttribute('value'); + $carry[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; return $carry; }, []); $vars = \array_merge($vars, [ - 'APPWRITE_FUNCTION_ID' => $function->getId(), + 'APPWRITE_FUNCTION_ID' => $function->getId() ?? '', 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), - 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(), + 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId() ?? '', 'APPWRITE_FUNCTION_TRIGGER' => 'http', - 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'], - 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'], - 'APPWRITE_FUNCTION_DATA' => $data, - 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(), - 'APPWRITE_FUNCTION_USER_ID' => $user->getId(), - 'APPWRITE_FUNCTION_JWT' => $jwt, + 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'] ?? '', + 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'] ?? '', + 'APPWRITE_FUNCTION_DATA' => $data ?? '', + 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId() ?? '', + 'APPWRITE_FUNCTION_USER_ID' => $user->getId() ?? '', + 'APPWRITE_FUNCTION_JWT' => $jwt ?? '', ]); /** Execute function */ diff --git a/app/workers/functions.php b/app/workers/functions.php index 31b74a11ca..e74c7a15b2 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -270,18 +270,18 @@ class FunctionsV1 extends Worker /** Collect environment variables */ $vars = \array_merge($vars, [ - 'APPWRITE_FUNCTION_ID' => $functionId, + 'APPWRITE_FUNCTION_ID' => $functionId ?? '', 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), - 'APPWRITE_FUNCTION_DEPLOYMENT' => $deploymentId, - 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'], - 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'], - 'APPWRITE_FUNCTION_TRIGGER' => $trigger, - 'APPWRITE_FUNCTION_EVENT' => $event, - 'APPWRITE_FUNCTION_EVENT_DATA' => $eventData, - 'APPWRITE_FUNCTION_DATA' => $data, - 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(), - 'APPWRITE_FUNCTION_USER_ID' => $user->getId(), - 'APPWRITE_FUNCTION_JWT' => $jwt, + 'APPWRITE_FUNCTION_DEPLOYMENT' => $deploymentId ?? '', + 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'] ?? '', + 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'] ?? '', + 'APPWRITE_FUNCTION_TRIGGER' => $trigger ?? '', + 'APPWRITE_FUNCTION_EVENT' => $event ?? '', + 'APPWRITE_FUNCTION_EVENT_DATA' => $eventData ?? '', + 'APPWRITE_FUNCTION_DATA' => $data ?? '', + 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId() ?? '', + 'APPWRITE_FUNCTION_USER_ID' => $user->getId() ?? '', + 'APPWRITE_FUNCTION_JWT' => $jwt ?? '', ]); /** Execute function */ From 65b4c9f9319388c527d245b150206ffe4626e5d5 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 30 Sep 2022 11:52:35 +0200 Subject: [PATCH 2/3] fix: default value for optional function vars --- app/controllers/api/functions.php | 8 ++++---- app/workers/functions.php | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 9c6e92d41e..c8f07cf61d 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1071,14 +1071,14 @@ App::post('/v1/functions/:functionId/executions') }, []); $vars = \array_merge($vars, [ - 'APPWRITE_FUNCTION_ID' => $function->getId() ?? '', - 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), - 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId() ?? '', + 'APPWRITE_FUNCTION_ID' => $function->getId(), + 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name'), + 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(), + 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(), 'APPWRITE_FUNCTION_TRIGGER' => 'http', 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'] ?? '', 'APPWRITE_FUNCTION_DATA' => $data ?? '', - 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId() ?? '', 'APPWRITE_FUNCTION_USER_ID' => $user->getId() ?? '', 'APPWRITE_FUNCTION_JWT' => $jwt ?? '', ]); diff --git a/app/workers/functions.php b/app/workers/functions.php index e74c7a15b2..1df776383f 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -270,16 +270,16 @@ class FunctionsV1 extends Worker /** Collect environment variables */ $vars = \array_merge($vars, [ - 'APPWRITE_FUNCTION_ID' => $functionId ?? '', - 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), - 'APPWRITE_FUNCTION_DEPLOYMENT' => $deploymentId ?? '', + 'APPWRITE_FUNCTION_ID' => $functionId, + 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name'), + 'APPWRITE_FUNCTION_DEPLOYMENT' => $deploymentId, + 'APPWRITE_FUNCTION_TRIGGER' => $trigger, + 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(), 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'] ?? '', - 'APPWRITE_FUNCTION_TRIGGER' => $trigger ?? '', 'APPWRITE_FUNCTION_EVENT' => $event ?? '', 'APPWRITE_FUNCTION_EVENT_DATA' => $eventData ?? '', 'APPWRITE_FUNCTION_DATA' => $data ?? '', - 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId() ?? '', 'APPWRITE_FUNCTION_USER_ID' => $user->getId() ?? '', 'APPWRITE_FUNCTION_JWT' => $jwt ?? '', ]); From f8bd3299a310c603f608b0bbc593113873349a0b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 30 Sep 2022 12:03:08 +0200 Subject: [PATCH 3/3] chore: add changelog --- CHANGES.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 68ca4abd17..18a9f8a2f2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,10 @@ +# Version 1.0.2 +## Bugs +- Fixed nullable values in functions variables [#3885](https://github.com/appwrite/appwrite/pull/3885) + # Version 1.0.1 ## Bugs -- Fixed migration for abuse by migrating the `time` attribute [3839](https://github.com/appwrite/appwrite/pull/3839) +- Fixed migration for abuse by migrating the `time` attribute [#3839](https://github.com/appwrite/appwrite/pull/3839) # Version 1.0.0 ## BREAKING CHANGES