From 813424aa3cba2d62f81d5a771d3c5376a6e55ff8 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 20 Mar 2025 20:37:32 +0530 Subject: [PATCH] Split params across multiple lines where overflowing --- .../Modules/Functions/Workers/Builds.php | 76 +++++++++++++++++-- .../Platform/Workers/Certificates.php | 51 +++++++++++-- src/Appwrite/Platform/Workers/Databases.php | 11 ++- src/Appwrite/Platform/Workers/Deletes.php | 18 ++++- src/Appwrite/Platform/Workers/Functions.php | 14 +++- src/Appwrite/Platform/Workers/StatsUsage.php | 6 +- 6 files changed, 153 insertions(+), 23 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 16b2e08be1..1fac6d7f36 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -91,8 +91,23 @@ class Builds extends Action * @return void * @throws \Utopia\Database\Exception */ - public function action(Message $message, Document $project, Database $dbForPlatform, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, StatsUsage $queueForStatsUsage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Device $deviceForSites, callable $isResourceBlocked, Device $deviceForFiles, Log $log): void - { + public function action( + Message $message, + Document $project, + Database $dbForPlatform, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + StatsUsage $queueForStatsUsage, + Cache $cache, + Database $dbForProject, + Device $deviceForFunctions, + Device $deviceForSites, + callable $isResourceBlocked, + Device $deviceForFiles, + Log $log + ): void { $payload = $message->getPayload() ?? []; if (empty($payload)) { @@ -112,7 +127,25 @@ class Builds extends Action case BUILD_TYPE_RETRY: Console::info('Creating build for deployment: ' . $deployment->getId()); $github = new GitHub($cache); - $this->buildDeployment($deviceForFunctions, $deviceForSites, $deviceForFiles, $queueForWebhooks, $queueForFunctions, $queueForRealtime, $queueForEvents, $queueForStatsUsage, $dbForPlatform, $dbForProject, $github, $project, $resource, $deployment, $template, $isResourceBlocked, $log); + $this->buildDeployment( + $deviceForFunctions, + $deviceForSites, + $deviceForFiles, + $queueForWebhooks, + $queueForFunctions, + $queueForRealtime, + $queueForEvents, + $queueForStatsUsage, + $dbForPlatform, + $dbForProject, + $github, + $project, + $resource, + $deployment, + $template, + $isResourceBlocked, + $log + ); break; default: @@ -142,9 +175,26 @@ class Builds extends Action * * @throws Exception */ - protected function buildDeployment(Device $deviceForFunctions, Device $deviceForSites, Device $deviceForFiles, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, Event $queueForEvents, StatsUsage $queueForStatsUsage, Database $dbForPlatform, Database $dbForProject, GitHub $github, Document $project, Document $resource, Document $deployment, Document $template, callable $isResourceBlocked, Log $log): void - { - $resourceKey = match($resource->getCollection()) { + protected function buildDeployment( + Device $deviceForFunctions, + Device $deviceForSites, + Device $deviceForFiles, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + Event $queueForEvents, + StatsUsage $queueForStatsUsage, + Database $dbForPlatform, + Database $dbForProject, + GitHub $github, + Document $project, + Document $resource, + Document $deployment, + Document $template, + callable $isResourceBlocked, + Log $log + ): void { + $resourceKey = match ($resource->getCollection()) { 'functions' => 'functionId', 'sites' => 'siteId', default => throw new \Exception('Invalid resource type') @@ -1170,8 +1220,18 @@ class Builds extends Action * @throws Conflict * @throws Restricted */ - protected function runGitAction(string $status, GitHub $github, string $providerCommitHash, string $owner, string $repositoryName, Document $project, Document $resource, string $deploymentId, Database $dbForProject, Database $dbForPlatform): void - { + protected function runGitAction( + string $status, + GitHub $github, + string $providerCommitHash, + string $owner, + string $repositoryName, + Document $project, + Document $resource, + string $deploymentId, + Database $dbForProject, + Database $dbForPlatform + ): void { if ($resource->getAttribute('providerSilentMode', false) === true) { return; } diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 552f617656..712196fc72 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -69,8 +69,17 @@ class Certificates extends Action * @throws Throwable * @throws \Utopia\Database\Exception */ - public function action(Message $message, Database $dbForPlatform, Mail $queueForMails, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, Log $log, CertificatesAdapter $certificates): void - { + public function action( + Message $message, + Database $dbForPlatform, + Mail $queueForMails, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + Log $log, + CertificatesAdapter $certificates + ): void { $payload = $message->getPayload() ?? []; if (empty($payload)) { @@ -99,8 +108,18 @@ class Certificates extends Action * @throws Throwable * @throws \Utopia\Database\Exception */ - private function execute(Domain $domain, Database $dbForPlatform, Mail $queueForMails, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, Log $log, CertificatesAdapter $certificates, bool $skipRenewCheck = false): void - { + private function execute( + Domain $domain, + Database $dbForPlatform, + Mail $queueForMails, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + Log $log, + CertificatesAdapter $certificates, + bool $skipRenewCheck = false + ): void { /** * 1. Read arguments and validate domain * 2. Get main domain @@ -209,8 +228,16 @@ class Certificates extends Action * @throws Conflict * @throws Structure */ - private function saveCertificateDocument(string $domain, Document $certificate, bool $success, Database $dbForPlatform, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime): void - { + private function saveCertificateDocument( + string $domain, + Document $certificate, + bool $success, + Database $dbForPlatform, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime + ): void { // Check if update or insert required $certificateDocument = $dbForPlatform->findOne('certificates', [Query::equal('domain', [$domain])]); if (!$certificateDocument->isEmpty()) { @@ -342,8 +369,16 @@ class Certificates extends Action * * @return void */ - private function updateDomainDocuments(string $certificateId, string $domain, bool $success, Database $dbForPlatform, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime): void - { + private function updateDomainDocuments( + string $certificateId, + string $domain, + bool $success, + Database $dbForPlatform, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime + ): void { // TODO: @christyjacob remove once we migrate the rules in 1.7.x if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { $rule = $dbForPlatform->getDocument('rules', md5($domain)); diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index e8edb1c0a3..010973519c 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -98,8 +98,15 @@ class Databases extends Action * @throws \Exception * @throws \Throwable */ - private function createAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForPlatform, Database $dbForProject, Realtime $queueForRealtime): void - { + private function createAttribute( + Document $database, + Document $collection, + Document $attribute, + Document $project, + Database $dbForPlatform, + Database $dbForProject, + Realtime $queueForRealtime + ): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); } diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 7be3cba7ad..4b5b11bce7 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -65,8 +65,22 @@ class Deletes extends Action * @throws Exception * @throws Throwable */ - public function action(Message $message, Document $project, Database $dbForPlatform, callable $getProjectDB, callable $getLogsDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForSites, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log): void - { + public function action( + Message $message, + Document $project, + Database $dbForPlatform, + callable $getProjectDB, + callable $getLogsDB, + Device $deviceForFiles, + Device $deviceForFunctions, + Device $deviceForSites, + Device $deviceForBuilds, + Device $deviceForCache, + CertificatesAdapter $certificates, + string $executionRetention, + string $auditRetention, + Log $log + ): void { $payload = $message->getPayload() ?? []; if (empty($payload)) { diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index 1bc67f2e0e..99dbea43b2 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -55,8 +55,18 @@ class Functions extends Action ->callback([$this, 'action']); } - public function action(Document $project, Message $message, Database $dbForProject, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, Event $queueForEvents, StatsUsage $queueForStatsUsage, Log $log, callable $isResourceBlocked): void - { + public function action( + Document $project, + Message $message, + Database $dbForProject, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + Event $queueForEvents, + StatsUsage $queueForStatsUsage, + Log $log, + callable $isResourceBlocked + ): void { $payload = $message->getPayload() ?? []; if (empty($payload)) { diff --git a/src/Appwrite/Platform/Workers/StatsUsage.php b/src/Appwrite/Platform/Workers/StatsUsage.php index a755f723a0..1d270fcd04 100644 --- a/src/Appwrite/Platform/Workers/StatsUsage.php +++ b/src/Appwrite/Platform/Workers/StatsUsage.php @@ -152,7 +152,11 @@ class StatsUsage extends Action case str_starts_with($document->getCollection(), 'database_') && !str_contains($document->getCollection(), 'collection'): //collections $parts = explode('_', $document->getCollection()); $databaseInternalId = $parts[1] ?? 0; - $documents = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace(['{databaseInternalId}', '{collectionInternalId}'], [$databaseInternalId, $document->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS))); + $documents = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace( + ['{databaseInternalId}', '{collectionInternalId}'], + [$databaseInternalId, $document->getInternalId()], + METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS + ))); if (!empty($documents['value'])) { $metrics[] = [