From 8630a3a4275e237228393b33c2b121ba74546048 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 22 Jul 2020 17:36:39 +0300 Subject: [PATCH] Reset default tag on delete --- app/controllers/api/functions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index c7517b7e6b..11c30c4789 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -507,6 +507,16 @@ App::delete('/v1/functions/:functionId/tags/:tagId') } } + if($function->getAttribute('tag') === $tag->getId()) { // Reset function tag + $function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [ + 'tag' => '', + ])); + + if (false === $function) { + throw new Exception('Failed saving function to DB', 500); + } + } + $usage ->setParam('storage', $tag->getAttribute('codeSize', 0) * -1) ;