From 733e0498a7d685c495ae1fc42efdd6189f9f4185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 16 Apr 2025 11:50:42 +0200 Subject: [PATCH] AI-recommended changes --- .github/workflows/cleanup-cache.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/linter.yml | 2 +- .github/workflows/publish.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- app/views/install/compose.phtml | 2 +- app/worker.php | 2 +- .../Platform/Modules/Functions/Http/Deployments/Get.php | 4 ++-- .../Modules/Functions/Http/Deployments/Status/Update.php | 2 +- .../Platform/Modules/Functions/Http/Executions/Get.php | 2 +- .../Platform/Modules/Functions/Http/Templates/XList.php | 3 ++- .../Platform/Modules/Functions/Http/Variables/Update.php | 4 ---- .../Platform/Modules/Sites/Http/Deployments/Get.php | 6 +++--- .../Modules/Sites/Http/Deployments/Status/Update.php | 2 +- .../Platform/Modules/Sites/Http/Templates/XList.php | 4 ++-- .../Platform/Modules/Sites/Http/Variables/Update.php | 4 ---- 17 files changed, 20 insertions(+), 27 deletions(-) diff --git a/.github/workflows/cleanup-cache.yml b/.github/workflows/cleanup-cache.yml index 6e20b8f879..8f25fe5ef6 100644 --- a/.github/workflows/cleanup-cache.yml +++ b/.github/workflows/cleanup-cache.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cleanup run: | diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0c0482ca8f..a40f07ceda 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 899c27a135..02edd57923 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0ed82dd853..c78156ca04 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 submodules: recursive diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 712d30dac0..862d669466 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 48b77eb4f8..04f8c822c7 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Run CodeQL run: | diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 88ee96d121..85d20aa0ef 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -867,7 +867,7 @@ $image = $this->getParam('image', ''); <<: *x-logging restart: unless-stopped stop_signal: SIGINT - image: openruntimes/executor:0.7.0 + image: openruntimes/executor:0.7.13 networks: - appwrite - runtimes diff --git a/app/worker.php b/app/worker.php index bcd4d8767d..0792847235 100644 --- a/app/worker.php +++ b/app/worker.php @@ -396,7 +396,7 @@ Server::setResource('logError', function (Registry $register, Document $project) $log->addExtra('trace', $error->getTraceAsString()); - foreach ($extras as $key => $value) { + foreach (($extras ?? []) as $key => $value) { $log->addExtra($key, $value); } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Get.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Get.php index 9a532fcb86..4efc2bd8b4 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Get.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Get.php @@ -65,11 +65,11 @@ class Get extends Action $deployment = $dbForProject->getDocument('deployments', $deploymentId); - if ($deployment->getAttribute('resourceId') !== $function->getId()) { + if ($deployment->isEmpty()) { throw new Exception(Exception::DEPLOYMENT_NOT_FOUND); } - if ($deployment->isEmpty()) { + if ($deployment->getAttribute('resourceId') !== $function->getId()) { throw new Exception(Exception::DEPLOYMENT_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php index a17fe3a29c..ea7f67e9da 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php @@ -86,7 +86,7 @@ class Update extends Action throw new Exception(Exception::BUILD_ALREADY_COMPLETED); } - $startTime = new \DateTime($deployment->getAttribute('buildStartAt')); + $startTime = new \DateTime($deployment->getAttribute('buildStartAt', 'now')); $endTime = new \DateTime('now'); $duration = $endTime->getTimestamp() - $startTime->getTimestamp(); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Get.php b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Get.php index d0fee863d7..6a92794767 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Get.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Get.php @@ -71,7 +71,7 @@ class Get extends Base $execution = $dbForProject->getDocument('executions', $executionId); - if ($execution->getAttribute('resourceType') !== 'functions' && $execution->getAttribute('resourceInternalId') !== $function->getInternalId()) { + if ($execution->getAttribute('resourceType') !== 'functions' || $execution->getAttribute('resourceInternalId') !== $function->getInternalId()) { throw new Exception(Exception::EXECUTION_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php index cfd1f6cdb2..7a165e6348 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php @@ -75,10 +75,11 @@ class XList extends Base return $b['score'] <=> $a['score']; }); + $total = \count($templates); $templates = \array_slice($templates, $offset, $limit); $response->dynamic(new Document([ 'templates' => $templates, - 'total' => \count($templates), + 'total' => $total, ]), Response::MODEL_TEMPLATE_FUNCTION_LIST); } } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Variables/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Variables/Update.php index 7334ff6a4e..6f1bab8401 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Variables/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Variables/Update.php @@ -84,10 +84,6 @@ class Update extends Base throw new Exception(Exception::VARIABLE_NOT_FOUND); } - if ($variable === false || $variable->isEmpty()) { - throw new Exception(Exception::VARIABLE_NOT_FOUND); - } - if ($variable->getAttribute('secret') === true && $secret === false) { throw new Exception(Exception::VARIABLE_CANNOT_UNSET_SECRET); } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Get.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Get.php index 8c3beaf2c0..755780ab99 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Get.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Get.php @@ -61,11 +61,11 @@ class Get extends Action $deployment = $dbForProject->getDocument('deployments', $deploymentId); - if ($deployment->getAttribute('resourceId') !== $site->getId()) { + if ($deployment->isEmpty()) { throw new Exception(Exception::DEPLOYMENT_NOT_FOUND); } - - if ($deployment->isEmpty()) { + + if ($deployment->getAttribute('resourceId') !== $site->getId()) { throw new Exception(Exception::DEPLOYMENT_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php index 6fd2d77f6b..7aade4e7ff 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php @@ -84,7 +84,7 @@ class Update extends Action throw new Exception(Exception::BUILD_ALREADY_COMPLETED); } - $startTime = new \DateTime($deployment->getAttribute('buildStartAt')); + $startTime = new \DateTime($deployment->getAttribute('buildStartAt', 'now')); $endTime = new \DateTime('now'); $duration = $endTime->getTimestamp() - $startTime->getTimestamp(); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php index dd87a60dd0..e73f89d726 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php @@ -80,11 +80,11 @@ class XList extends Base return $b['score'] <=> $a['score']; }); + $total = \count($templates); $templates = \array_slice($templates, $offset, $limit); - $response->dynamic(new Document([ 'templates' => $templates, - 'total' => \count($templates), + 'total' => $total, ]), Response::MODEL_TEMPLATE_SITE_LIST); } } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php index bc4ba7f62c..fa37432b5c 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php @@ -80,10 +80,6 @@ class Update extends Base throw new Exception(Exception::VARIABLE_NOT_FOUND); } - if ($variable === false || $variable->isEmpty()) { - throw new Exception(Exception::VARIABLE_NOT_FOUND); - } - if ($variable->getAttribute('secret') === true && $secret === false) { throw new Exception(Exception::VARIABLE_CANNOT_UNSET_SECRET); }