From 1a6530fb577f98154adbd94fe201605b9e14dca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 5 Sep 2023 10:21:36 +0200 Subject: [PATCH 1/6] Fix project variables --- app/config/collections.php | 11 +++++++++++ app/controllers/api/functions.php | 13 ++++++------- app/init.php | 1 - app/workers/builds.php | 18 ++++++------------ app/workers/functions.php | 15 ++++++--------- src/Appwrite/Migration/Version/V19.php | 1 + 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 1d452f4b3a..db229ce87a 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1944,6 +1944,17 @@ $projectCollections = array_merge([ 'array' => false, 'filters' => ['subQueryVariables'], ], + [ + '$id' => ID::custom('varsProject'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['subQueryProjectVariables'], + ], [ '$id' => ID::custom('events'), 'type' => Database::VAR_STRING, diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 5c8499cdf3..bde5b6bf51 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1661,15 +1661,14 @@ App::post('/v1/functions/:functionId/executions') $vars = []; // Shared vars - foreach ($project->getAttribute('variables', []) as $var) { + foreach ($function->getAttribute('varsProject', []) as $var) { $vars[$var->getAttribute('key')] = $var->getAttribute('value', ''); } // Function vars - $vars = \array_merge($vars, array_reduce($function->getAttribute('vars', []), function (array $carry, Document $var) { - $carry[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; - return $carry; - }, [])); + foreach ($function->getAttribute('vars', []) as $var) { + $vars[$var->getAttribute('key')] = $var->getAttribute('value', ''); + } // Appwrite vars $vars = \array_merge($vars, [ @@ -1976,8 +1975,8 @@ App::get('/v1/functions/:functionId/variables') } $response->dynamic(new Document([ - 'variables' => $function->getAttribute('vars'), - 'total' => \count($function->getAttribute('vars')), + 'variables' => $function->getAttribute('vars', []), + 'total' => \count($function->getAttribute('vars', [])), ]), Response::MODEL_VARIABLE_LIST); }); diff --git a/app/init.php b/app/init.php index 439cef7a80..6a2ce67f53 100644 --- a/app/init.php +++ b/app/init.php @@ -492,7 +492,6 @@ Database::addFilter( } ); -// READ-ONLY! TO update, write directly to 'variables' collection. After update to vars, make sure to deleteCachedDocument() Database::addFilter( 'subQueryProjectVariables', function (mixed $value) { diff --git a/app/workers/builds.php b/app/workers/builds.php index 41867a5dd3..0bad5ae72d 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -320,21 +320,15 @@ class BuildsV1 extends Worker $vars = []; - // Global vars - $varsFromProject = $dbForProject->find('variables', [ - Query::equal('resourceType', ['project']), - Query::limit(APP_LIMIT_SUBQUERY) - ]); - - foreach ($varsFromProject as $var) { - $vars[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; + // Shared vars + foreach ($function->getAttribute('varsProject', []) as $var) { + $vars[$var->getAttribute('key')] = $var->getAttribute('value', ''); } // Function vars - $vars = \array_merge($vars, array_reduce($function->getAttribute('vars', []), function (array $carry, Document $var) { - $carry[$var->getAttribute('key')] = $var->getAttribute('value'); - return $carry; - }, [])); + foreach ($function->getAttribute('vars', []) as $var) { + $vars[$var->getAttribute('key')] = $var->getAttribute('value', ''); + } // Appwrite vars $vars = \array_merge($vars, [ diff --git a/app/workers/functions.php b/app/workers/functions.php index 38923b5129..303b574e23 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -142,17 +142,14 @@ Server::setResource('execute', function () { $vars = []; // Shared vars - $varsShared = $project->getAttribute('variables', []); - $vars = \array_merge($vars, \array_reduce($varsShared, function (array $carry, Document $var) { - $carry[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; - return $carry; - }, [])); + foreach ($function->getAttribute('varsProject', []) as $var) { + $vars[$var->getAttribute('key')] = $var->getAttribute('value', ''); + } // Function vars - $vars = \array_merge($vars, array_reduce($function->getAttribute('vars', []), function (array $carry, Document $var) { - $carry[$var->getAttribute('key')] = $var->getAttribute('value'); - return $carry; - }, [])); + foreach ($function->getAttribute('vars', []) as $var) { + $vars[$var->getAttribute('key')] = $var->getAttribute('value', ''); + } // Appwrite vars $vars = \array_merge($vars, [ diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index 33c0fceb9f..601f122ad9 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -408,6 +408,7 @@ class V19 extends Migration 'version', 'entrypoint', 'commands', + 'varsProject' ]; foreach ($attributesToCreate as $attribute) { try { From 1b9236ba3f5ec54adb7446f97de839a0554041d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 5 Sep 2023 11:48:23 +0200 Subject: [PATCH 2/6] Improve VCS error when creating repository --- src/Appwrite/Auth/OAuth2/Exception.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2/Exception.php b/src/Appwrite/Auth/OAuth2/Exception.php index 28d8d652f9..c3b574fb71 100644 --- a/src/Appwrite/Auth/OAuth2/Exception.php +++ b/src/Appwrite/Auth/OAuth2/Exception.php @@ -17,14 +17,17 @@ class Exception extends AppwriteException $decoded = json_decode($response, true); if (\is_array($decoded)) { if (\is_array($decoded['error'] ?? '')) { - $this->error = $decoded['error']['status']; - $this->errorDescription = $decoded['error']['message']; - $this->message = $this->error . ': ' . $this->errorDescription; + $this->error = $decoded['error']['status'] ?? 'Unknown error'; + $this->errorDescription = $decoded['error']['message'] ?? 'No description'; + } else if (\is_array($decoded['errors'] ?? '')) { + $this->error = $decoded['error'] ?? $decoded['message'] ?? 'Unknown error'; + $this->errorDescription = $decoded['errors'][0]['message'] ?? 'No description'; } else { $this->error = $decoded['error'] ?? $decoded['message'] ?? 'Unknown error'; $this->errorDescription = $decoded['error_description'] ?? 'No description'; - $this->message = $this->error . ': ' . $this->errorDescription; } + + $this->message = $this->error . ': ' . $this->errorDescription; } $type = match ($code) { 400 => AppwriteException::USER_OAUTH2_BAD_REQUEST, From 5538c47b3fa5406ef1e4c7ac2e13fed02bebe6d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 5 Sep 2023 12:14:43 +0200 Subject: [PATCH 3/6] Improve installation exception when missconfigured --- app/controllers/api/vcs.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 543a7e6b8b..894e083dfb 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -228,6 +228,7 @@ App::get('/v1/vcs/github/authorize') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') ->label('sdk.namespace', 'vcs') + ->label('error', __DIR__ . '/../../views/general/error.phtml') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.method', 'createGitHubInstallation') ->label('sdk.description', '') @@ -248,6 +249,11 @@ App::get('/v1/vcs/github/authorize') ]); $appName = App::getEnv('_APP_VCS_GITHUB_APP_NAME'); + + if(empty($appName)) { + throw new Exception(Exception::GENERAL_SERVER_ERROR, 'GitHub App name is not configured. Please configure VCS (Version Control System) variables in .env file.'); + } + $url = "https://github.com/apps/$appName/installations/new?" . \http_build_query([ 'state' => $state, 'redirect_uri' => $request->getProtocol() . '://' . $request->getHostname() . "/v1/vcs/github/callback" From 79726dbfb64c756fcd13d4c5605b4f529ea2d0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 5 Sep 2023 13:16:20 +0200 Subject: [PATCH 4/6] Fix formatting --- app/controllers/api/vcs.php | 2 +- src/Appwrite/Auth/OAuth2/Exception.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 894e083dfb..fc352e4809 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -250,7 +250,7 @@ App::get('/v1/vcs/github/authorize') $appName = App::getEnv('_APP_VCS_GITHUB_APP_NAME'); - if(empty($appName)) { + if (empty($appName)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'GitHub App name is not configured. Please configure VCS (Version Control System) variables in .env file.'); } diff --git a/src/Appwrite/Auth/OAuth2/Exception.php b/src/Appwrite/Auth/OAuth2/Exception.php index c3b574fb71..df5054ae9a 100644 --- a/src/Appwrite/Auth/OAuth2/Exception.php +++ b/src/Appwrite/Auth/OAuth2/Exception.php @@ -19,7 +19,7 @@ class Exception extends AppwriteException if (\is_array($decoded['error'] ?? '')) { $this->error = $decoded['error']['status'] ?? 'Unknown error'; $this->errorDescription = $decoded['error']['message'] ?? 'No description'; - } else if (\is_array($decoded['errors'] ?? '')) { + } elseif (\is_array($decoded['errors'] ?? '')) { $this->error = $decoded['error'] ?? $decoded['message'] ?? 'Unknown error'; $this->errorDescription = $decoded['errors'][0]['message'] ?? 'No description'; } else { From 8e509efcec592530593716b04f52b436ab158143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 5 Sep 2023 13:55:02 +0200 Subject: [PATCH 5/6] Add global env var test --- app/controllers/api/functions.php | 21 ++++++------------- app/controllers/api/project.php | 14 +++++-------- .../Functions/FunctionsCustomServerTest.php | 19 +++++++++++++++++ tests/resources/functions/php/index.php | 3 ++- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index bde5b6bf51..4dd2c18c3d 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -927,10 +927,9 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId') ->param('deploymentId', '', new UID(), 'Deployment ID.') ->inject('response') ->inject('dbForProject') - ->inject('project') ->inject('events') ->inject('dbForConsole') - ->action(function (string $functionId, string $deploymentId, Response $response, Database $dbForProject, Document $project, Event $events, Database $dbForConsole) { + ->action(function (string $functionId, string $deploymentId, Response $response, Database $dbForProject, Event $events, Database $dbForConsole) { $function = $dbForProject->getDocument('functions', $functionId); $deployment = $dbForProject->getDocument('deployments', $deploymentId); @@ -990,9 +989,8 @@ App::delete('/v1/functions/:functionId') ->inject('dbForProject') ->inject('deletes') ->inject('events') - ->inject('project') ->inject('dbForConsole') - ->action(function (string $functionId, Response $response, Database $dbForProject, Delete $deletes, Event $events, Document $project, Database $dbForConsole) { + ->action(function (string $functionId, Response $response, Database $dbForProject, Delete $deletes, Event $events, Database $dbForConsole) { $function = $dbForProject->getDocument('functions', $functionId); @@ -1434,11 +1432,9 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId') ->inject('request') ->inject('response') ->inject('dbForProject') - ->inject('dbForConsole') ->inject('project') - ->inject('gitHub') ->inject('events') - ->action(function (string $functionId, string $deploymentId, string $buildId, Request $request, Response $response, Database $dbForProject, Database $dbForConsole, Document $project, GitHub $github, Event $events) use ($redeployVcs) { + ->action(function (string $functionId, string $deploymentId, string $buildId, Request $request, Response $response, Database $dbForProject, Document $project, Event $events) use ($redeployVcs) { $function = $dbForProject->getDocument('functions', $functionId); @@ -1901,11 +1897,10 @@ App::post('/v1/functions/:functionId/variables') ->param('functionId', '', new UID(), 'Function unique ID.', false) ->param('key', null, new Text(Database::LENGTH_KEY), 'Variable key. Max length: ' . Database::LENGTH_KEY . ' chars.', false) ->param('value', null, new Text(8192, 0), 'Variable value. Max length: 8192 chars.', false) - ->inject('project') ->inject('response') ->inject('dbForProject') ->inject('dbForConsole') - ->action(function (string $functionId, string $key, string $value, Document $project, Response $response, Database $dbForProject, Database $dbForConsole) { + ->action(function (string $functionId, string $key, string $value, Response $response, Database $dbForProject, Database $dbForConsole) { $function = $dbForProject->getDocument('functions', $functionId); if ($function->isEmpty()) { @@ -1934,7 +1929,6 @@ App::post('/v1/functions/:functionId/variables') } catch (DuplicateException $th) { throw new Exception(Exception::VARIABLE_ALREADY_EXISTS); } - $dbForConsole->deleteCachedDocument('projects', $project->getId()); $dbForProject->updateDocument('functions', $function->getId(), $function->setAttribute('live', false)); @@ -2036,11 +2030,10 @@ App::put('/v1/functions/:functionId/variables/:variableId') ->param('variableId', '', new UID(), 'Variable unique ID.', false) ->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.', false) ->param('value', null, new Text(8192, 0), 'Variable value. Max length: 8192 chars.', true) - ->inject('project') ->inject('response') ->inject('dbForProject') ->inject('dbForConsole') - ->action(function (string $functionId, string $variableId, string $key, ?string $value, Document $project, Response $response, Database $dbForProject, Database $dbForConsole) { + ->action(function (string $functionId, string $variableId, string $key, ?string $value, Response $response, Database $dbForProject, Database $dbForConsole) { $function = $dbForProject->getDocument('functions', $functionId); @@ -2067,7 +2060,6 @@ App::put('/v1/functions/:functionId/variables/:variableId') } catch (DuplicateException $th) { throw new Exception(Exception::VARIABLE_ALREADY_EXISTS); } - $dbForConsole->deleteCachedDocument('projects', $project->getId()); $dbForProject->updateDocument('functions', $function->getId(), $function->setAttribute('live', false)); @@ -2098,11 +2090,10 @@ App::delete('/v1/functions/:functionId/variables/:variableId') ->label('sdk.response.model', Response::MODEL_NONE) ->param('functionId', '', new UID(), 'Function unique ID.', false) ->param('variableId', '', new UID(), 'Variable unique ID.', false) - ->inject('project') ->inject('response') ->inject('dbForProject') ->inject('dbForConsole') - ->action(function (string $functionId, string $variableId, Document $project, Response $response, Database $dbForProject, Database $dbForConsole) { + ->action(function (string $functionId, string $variableId, Response $response, Database $dbForProject, Database $dbForConsole) { $function = $dbForProject->getDocument('functions', $functionId); if ($function->isEmpty()) { diff --git a/app/controllers/api/project.php b/app/controllers/api/project.php index 0f0a296185..4a9903b0b7 100644 --- a/app/controllers/api/project.php +++ b/app/controllers/api/project.php @@ -161,7 +161,6 @@ App::post('/v1/project/variables') } catch (DuplicateException $th) { throw new Exception(Exception::VARIABLE_ALREADY_EXISTS); } - $dbForConsole->deleteCachedDocument('projects', $project->getId()); $functions = $dbForProject->find('functions', [ Query::limit(APP_LIMIT_SUBQUERY) @@ -169,10 +168,9 @@ App::post('/v1/project/variables') foreach ($functions as $function) { $dbForProject->updateDocument('functions', $function->getId(), $function->setAttribute('live', false)); + $dbForProject->deleteCachedDocument('functions', $function->getId()); } - $dbForProject->deleteCachedDocument('projects', $project->getId()); - $response ->setStatusCode(Response::STATUS_CODE_CREATED) ->dynamic($variable, Response::MODEL_VARIABLE); @@ -261,7 +259,6 @@ App::put('/v1/project/variables/:variableId') } catch (DuplicateException $th) { throw new Exception(Exception::VARIABLE_ALREADY_EXISTS); } - $dbForConsole->deleteCachedDocument('projects', $project->getId()); $functions = $dbForProject->find('functions', [ Query::limit(APP_LIMIT_SUBQUERY) @@ -269,10 +266,9 @@ App::put('/v1/project/variables/:variableId') foreach ($functions as $function) { $dbForProject->updateDocument('functions', $function->getId(), $function->setAttribute('live', false)); + $dbForProject->deleteCachedDocument('functions', $function->getId()); } - $dbForProject->deleteCachedDocument('projects', $project->getId()); - $response->dynamic($variable, Response::MODEL_VARIABLE); }); @@ -296,16 +292,16 @@ App::delete('/v1/project/variables/:variableId') throw new Exception(Exception::VARIABLE_NOT_FOUND); } + $dbForProject->deleteDocument('variables', $variable->getId()); + $functions = $dbForProject->find('functions', [ Query::limit(APP_LIMIT_SUBQUERY) ]); foreach ($functions as $function) { $dbForProject->updateDocument('functions', $function->getId(), $function->setAttribute('live', false)); + $dbForProject->deleteCachedDocument('functions', $function->getId()); } - $dbForProject->deleteDocument('variables', $variable->getId()); - $dbForProject->deleteCachedDocument('projects', $project->getId()); - $response->noContent(); }); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 052c3ca936..4d567e3687 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -343,6 +343,24 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals('0 0 1 1 *', $response1['body']['schedule']); $this->assertEquals(15, $response1['body']['timeout']); + /** + * Create global variable to test in execution later + */ + $headers = [ + 'content-type' => 'application/json', + 'origin' => 'http://localhost', + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-mode' => 'admin', + ]; + + $variable = $this->client->call(Client::METHOD_POST, '/project/variables', $headers, [ + 'key' => 'GLOBAL_VARIABLE', + 'value' => 'Global Variable Value', + ]); + + $this->assertEquals(201, $variable['headers']['status-code']); + /** * Test for FAILURE */ @@ -640,6 +658,7 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString('http', $execution['body']['responseBody']); $this->assertStringContainsString('PHP', $execution['body']['responseBody']); $this->assertStringContainsString('8.0', $execution['body']['responseBody']); + $this->assertStringContainsString('Global Variable Value', $execution['body']['responseBody']); // $this->assertStringContainsString('êä', $execution['body']['responseBody']); // tests unknown utf-8 chars $this->assertEquals('', $execution['body']['errors']); $this->assertEquals('', $execution['body']['logs']); diff --git a/tests/resources/functions/php/index.php b/tests/resources/functions/php/index.php index 5a9666488e..ac7b85a43a 100644 --- a/tests/resources/functions/php/index.php +++ b/tests/resources/functions/php/index.php @@ -8,6 +8,7 @@ return function ($context) { 'APPWRITE_FUNCTION_TRIGGER' => $context->req->headers['x-appwrite-trigger'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_NAME' => \getenv('APPWRITE_FUNCTION_RUNTIME_NAME') ?: '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => \getenv('APPWRITE_FUNCTION_RUNTIME_VERSION') ?: '', - 'UNICODE_TEST' => "êä" + 'UNICODE_TEST' => "êä", + 'GLOBAL_VARIABLE' => \getenv('GLOBAL_VARIABLE') ?: '' ]); }; From 9060aa1ba76fb99ae690d180f603354442a62382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 6 Sep 2023 09:53:02 +0200 Subject: [PATCH 6/6] Remove unnessessary cache clear --- app/controllers/api/functions.php | 6 ------ app/controllers/api/project.php | 3 --- 2 files changed, 9 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 4dd2c18c3d..d885219f96 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1940,8 +1940,6 @@ App::post('/v1/functions/:functionId/variables') ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment'))); Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule)); - $dbForProject->deleteCachedDocument('functions', $function->getId()); - $response ->setStatusCode(Response::STATUS_CODE_CREATED) ->dynamic($variable, Response::MODEL_VARIABLE); @@ -2071,8 +2069,6 @@ App::put('/v1/functions/:functionId/variables/:variableId') ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment'))); Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule)); - $dbForProject->deleteCachedDocument('functions', $function->getId()); - $response->dynamic($variable, Response::MODEL_VARIABLE); }); @@ -2121,7 +2117,5 @@ App::delete('/v1/functions/:functionId/variables/:variableId') ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment'))); Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule)); - $dbForProject->deleteCachedDocument('functions', $function->getId()); - $response->noContent(); }); diff --git a/app/controllers/api/project.php b/app/controllers/api/project.php index 4a9903b0b7..bd8d9d5f73 100644 --- a/app/controllers/api/project.php +++ b/app/controllers/api/project.php @@ -168,7 +168,6 @@ App::post('/v1/project/variables') foreach ($functions as $function) { $dbForProject->updateDocument('functions', $function->getId(), $function->setAttribute('live', false)); - $dbForProject->deleteCachedDocument('functions', $function->getId()); } $response @@ -266,7 +265,6 @@ App::put('/v1/project/variables/:variableId') foreach ($functions as $function) { $dbForProject->updateDocument('functions', $function->getId(), $function->setAttribute('live', false)); - $dbForProject->deleteCachedDocument('functions', $function->getId()); } $response->dynamic($variable, Response::MODEL_VARIABLE); @@ -300,7 +298,6 @@ App::delete('/v1/project/variables/:variableId') foreach ($functions as $function) { $dbForProject->updateDocument('functions', $function->getId(), $function->setAttribute('live', false)); - $dbForProject->deleteCachedDocument('functions', $function->getId()); } $response->noContent();