From 905ccf38481a32adb15d2c0ff23ea10b0f77fbc9 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Jun 2024 10:50:53 +0300 Subject: [PATCH 01/15] delete worker function scope private to protected update --- src/Appwrite/Platform/Workers/Deletes.php | 58 +++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index d54f3f5079e..2755fbf4013 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -177,7 +177,7 @@ public function action(Message $message, Database $dbForConsole, callable $getPr * @throws Structure * @throws DatabaseException */ - private function deleteSchedules(Database $dbForConsole, callable $getProjectDB, string $datetime): void + protected function deleteSchedules(Database $dbForConsole, callable $getProjectDB, string $datetime): void { $this->listByGroup( 'schedules', @@ -228,7 +228,7 @@ function (Document $document) use ($dbForConsole, $getProjectDB) { * @param Document $topic * @throws Exception */ - private function deleteTopic(Document $project, callable $getProjectDB, Document $topic) + protected function deleteTopic(Document $project, callable $getProjectDB, Document $topic) { if ($topic->isEmpty()) { Console::error('Failed to delete subscribers. Topic not found'); @@ -250,7 +250,7 @@ private function deleteTopic(Document $project, callable $getProjectDB, Document * @param Document $target * @throws Exception */ - private function deleteTargetSubscribers(Document $project, callable $getProjectDB, Document $target): void + protected function deleteTargetSubscribers(Document $project, callable $getProjectDB, Document $target): void { /** @var Database */ $dbForProject = $getProjectDB($project); @@ -291,7 +291,7 @@ function (Document $subscriber) use ($dbForProject, $target) { * @return void * @throws Exception */ - private function deleteExpiredTargets(Document $project, callable $getProjectDB): void + protected function deleteExpiredTargets(Document $project, callable $getProjectDB): void { $this->deleteByGroup( 'targets', @@ -305,7 +305,7 @@ function (Document $target) use ($getProjectDB, $project) { ); } - private function deleteSessionTargets(Document $project, callable $getProjectDB, Document $session): void + protected function deleteSessionTargets(Document $project, callable $getProjectDB, Document $session): void { $this->deleteByGroup( 'targets', @@ -328,7 +328,7 @@ function (Document $target) use ($getProjectDB, $project) { * @param string|null $resourceType * @throws Exception */ - private function deleteCacheByResource(Document $project, callable $getProjectDB, string $resource, string $resourceType = null): void + protected function deleteCacheByResource(Document $project, callable $getProjectDB, string $resource, string $resourceType = null): void { $projectId = $project->getId(); $dbForProject = $getProjectDB($project); @@ -366,7 +366,7 @@ function (Document $document) use ($cache, $projectId) { * @return void * @throws Exception */ - private function deleteCacheByDate(Document $project, callable $getProjectDB, string $datetime): void + protected function deleteCacheByDate(Document $project, callable $getProjectDB, string $datetime): void { $projectId = $project->getId(); $dbForProject = $getProjectDB($project); @@ -402,7 +402,7 @@ function (Document $document) use ($cache, $projectId) { * @return void * @throws Exception */ - private function deleteUsageStats(Document $project, callable $getProjectDB, string $hourlyUsageRetentionDatetime): void + protected function deleteUsageStats(Document $project, callable $getProjectDB, string $hourlyUsageRetentionDatetime): void { $dbForProject = $getProjectDB($project); // Delete Usage stats @@ -419,7 +419,7 @@ private function deleteUsageStats(Document $project, callable $getProjectDB, str * @return void * @throws Exception */ - private function deleteMemberships(callable $getProjectDB, Document $document, Document $project): void + protected function deleteMemberships(callable $getProjectDB, Document $document, Document $project): void { $dbForProject = $getProjectDB($project); $teamInternalId = $document->getInternalId(); @@ -448,7 +448,7 @@ function (Document $membership) use ($dbForProject) { * @throws Restricted * @throws Structure */ - private function deleteProjectsByTeam(Database $dbForConsole, callable $getProjectDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, Document $document): void + protected function deleteProjectsByTeam(Database $dbForConsole, callable $getProjectDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, Document $document): void { $projects = $dbForConsole->find('projects', [ @@ -473,7 +473,7 @@ private function deleteProjectsByTeam(Database $dbForConsole, callable $getProje * @throws Authorization * @throws DatabaseException */ - private function deleteProject(Database $dbForConsole, callable $getProjectDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, Document $document): void + protected function deleteProject(Database $dbForConsole, callable $getProjectDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, Document $document): void { $projectInternalId = $document->getInternalId(); @@ -574,7 +574,7 @@ private function deleteProject(Database $dbForConsole, callable $getProjectDB, D * @return void * @throws Exception */ - private function deleteUser(callable $getProjectDB, Document $document, Document $project): void + protected function deleteUser(callable $getProjectDB, Document $document, Document $project): void { $userId = $document->getId(); $userInternalId = $document->getInternalId(); @@ -630,7 +630,7 @@ function (Document $target) use ($getProjectDB, $project) { * @return void * @throws Exception */ - private function deleteExecutionLogs(Document $project, callable $getProjectDB, string $datetime): void + protected function deleteExecutionLogs(Document $project, callable $getProjectDB, string $datetime): void { $dbForProject = $getProjectDB($project); // Delete Executions @@ -645,7 +645,7 @@ private function deleteExecutionLogs(Document $project, callable $getProjectDB, * @return void * @throws Exception|Throwable */ - private function deleteExpiredSessions(Document $project, callable $getProjectDB): void + protected function deleteExpiredSessions(Document $project, callable $getProjectDB): void { $dbForProject = $getProjectDB($project); $duration = $project->getAttribute('auths', [])['duration'] ?? Auth::TOKEN_EXPIRATION_LOGIN_LONG; @@ -663,7 +663,7 @@ private function deleteExpiredSessions(Document $project, callable $getProjectDB * @return void * @throws Exception */ - private function deleteRealtimeUsage(Database $dbForConsole, string $datetime): void + protected function deleteRealtimeUsage(Database $dbForConsole, string $datetime): void { // Delete Dead Realtime Logs $this->deleteByGroup('realtime', [ @@ -678,7 +678,7 @@ private function deleteRealtimeUsage(Database $dbForConsole, string $datetime): * @return void * @throws Exception */ - private function deleteAbuseLogs(Document $project, callable $getProjectDB, string $abuseRetention): void + protected function deleteAbuseLogs(Document $project, callable $getProjectDB, string $abuseRetention): void { $projectId = $project->getId(); $dbForProject = $getProjectDB($project); @@ -699,7 +699,7 @@ private function deleteAbuseLogs(Document $project, callable $getProjectDB, stri * @return void * @throws Exception */ - private function deleteAuditLogs(Document $project, callable $getProjectDB, string $auditRetention): void + protected function deleteAuditLogs(Document $project, callable $getProjectDB, string $auditRetention): void { $projectId = $project->getId(); $dbForProject = $getProjectDB($project); @@ -719,7 +719,7 @@ private function deleteAuditLogs(Document $project, callable $getProjectDB, stri * @return void * @throws Exception */ - private function deleteAuditLogsByResource(callable $getProjectDB, string $resource, Document $project): void + protected function deleteAuditLogsByResource(callable $getProjectDB, string $resource, Document $project): void { $dbForProject = $getProjectDB($project); @@ -737,7 +737,7 @@ private function deleteAuditLogsByResource(callable $getProjectDB, string $resou * @return void * @throws Exception */ - private function deleteFunction(Database $dbForConsole, callable $getProjectDB, Device $deviceForFunctions, Device $deviceForBuilds, Document $document, Document $project): void + protected function deleteFunction(Database $dbForConsole, callable $getProjectDB, Device $deviceForFunctions, Device $deviceForBuilds, Document $document, Document $project): void { $projectId = $project->getId(); $dbForProject = $getProjectDB($project); @@ -828,7 +828,7 @@ private function deleteFunction(Database $dbForConsole, callable $getProjectDB, * @param Document $deployment * @return void */ - private function deleteDeploymentFiles(Device $device, Document $deployment): void + protected function deleteDeploymentFiles(Device $device, Document $deployment): void { $deploymentId = $deployment->getId(); $deploymentPath = $deployment->getAttribute('path', ''); @@ -860,7 +860,7 @@ private function deleteDeploymentFiles(Device $device, Document $deployment): vo * @param Document $build * @return void */ - private function deleteBuildFiles(Device $device, Document $build): void + protected function deleteBuildFiles(Device $device, Document $build): void { $buildId = $build->getId(); $buildPath = $build->getAttribute('path', ''); @@ -894,7 +894,7 @@ private function deleteBuildFiles(Device $device, Document $build): void * @return void * @throws Exception */ - private function deleteDeployment(callable $getProjectDB, Device $deviceForFunctions, Device $deviceForBuilds, Document $document, Document $project): void + protected function deleteDeployment(callable $getProjectDB, Device $deviceForFunctions, Device $deviceForBuilds, Document $document, Document $project): void { $projectId = $project->getId(); $dbForProject = $getProjectDB($project); @@ -930,7 +930,7 @@ private function deleteDeployment(callable $getProjectDB, Device $deviceForFunct * @param callable|null $callback to perform after document is deleted * @return void */ - private function deleteById(Document $document, Database $database, callable $callback = null): void + protected function deleteById(Document $document, Database $database, callable $callback = null): void { if ($database->deleteDocument($document->getCollection(), $document->getId())) { Console::success('Deleted document "' . $document->getId() . '" successfully'); @@ -951,7 +951,7 @@ private function deleteById(Document $document, Database $database, callable $ca * @return void * @throws Exception */ - private function deleteByGroup(string $collection, array $queries, Database $database, callable $callback = null): void + protected function deleteByGroup(string $collection, array $queries, Database $database, callable $callback = null): void { $count = 0; $chunk = 0; @@ -993,7 +993,7 @@ private function deleteByGroup(string $collection, array $queries, Database $dat * @return void * @throws Exception */ - private function listByGroup(string $collection, array $queries, Database $database, callable $callback = null): void + protected function listByGroup(string $collection, array $queries, Database $database, callable $callback = null): void { $count = 0; $chunk = 0; @@ -1039,7 +1039,7 @@ private function listByGroup(string $collection, array $queries, Database $datab * @param Document $document rule document * @return void */ - private function deleteRule(Database $dbForConsole, Document $document): void + protected function deleteRule(Database $dbForConsole, Document $document): void { $domain = $document->getAttribute('domain'); @@ -1068,7 +1068,7 @@ private function deleteRule(Database $dbForConsole, Document $document): void * @param Document $project * @return void */ - private function deleteBucket(callable $getProjectDB, Device $deviceForFiles, Document $document, Document $project): void + protected function deleteBucket(callable $getProjectDB, Device $deviceForFiles, Document $document, Document $project): void { $dbForProject = $getProjectDB($project); @@ -1085,7 +1085,7 @@ private function deleteBucket(callable $getProjectDB, Device $deviceForFiles, Do * @return void * @throws Exception */ - private function deleteInstallation(Database $dbForConsole, callable $getProjectDB, Document $document, Document $project): void + protected function deleteInstallation(Database $dbForConsole, callable $getProjectDB, Document $document, Document $project): void { $dbForProject = $getProjectDB($project); @@ -1114,7 +1114,7 @@ private function deleteInstallation(Database $dbForConsole, callable $getProject * @return void * @throws Exception */ - private function deleteRuntimes(callable $getProjectDB, ?Document $function, Document $project): void + protected function deleteRuntimes(callable $getProjectDB, ?Document $function, Document $project): void { $executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST')); From afea698724cc869e542c4c5e94e37c2e8db50b61 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Jun 2024 11:17:55 +0300 Subject: [PATCH 02/15] platform lib downgrade --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 192b3118221..9ba8db0e097 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ "utopia-php/messaging": "0.12.*", "utopia-php/migration": "0.4.*", "utopia-php/orchestration": "0.9.*", - "utopia-php/platform": "0.7.*", + "utopia-php/platform": "0.5.*", "utopia-php/pools": "0.5.*", "utopia-php/preloader": "0.2.*", "utopia-php/queue": "0.7.*", From 729c8950ac4bce4236447f46a1a7bb05835c0156 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Jun 2024 11:24:14 +0300 Subject: [PATCH 03/15] platform lib downgrade --- composer.lock | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index aee6c86d535..5ee1aff322f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e002600539435ca8eaaace6e73b4004d", + "content-hash": "9ba1190efa21ae307532896397b3228d", "packages": [ { "name": "adhocore/jwt", @@ -2327,16 +2327,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.0", + "version": "0.5.2", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "beeea0f2c9bce14a6869fc5c87a1047cdecb5c52" + "reference": "b9feabc79b92dc2b05683a986ad43bce5c1583e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/beeea0f2c9bce14a6869fc5c87a1047cdecb5c52", - "reference": "beeea0f2c9bce14a6869fc5c87a1047cdecb5c52", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/b9feabc79b92dc2b05683a986ad43bce5c1583e3", + "reference": "b9feabc79b92dc2b05683a986ad43bce5c1583e3", "shasum": "" }, "require": { @@ -2344,8 +2344,7 @@ "ext-redis": "*", "php": ">=8.0", "utopia-php/cli": "0.15.*", - "utopia-php/framework": "0.33.*", - "utopia-php/queue": "0.7.*" + "utopia-php/framework": "0.33.*" }, "require-dev": { "laravel/pint": "1.2.*", @@ -2371,9 +2370,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.0" + "source": "https://github.com/utopia-php/platform/tree/0.5.2" }, - "time": "2024-05-08T17:00:55+00:00" + "time": "2024-05-22T12:50:35+00:00" }, { "name": "utopia-php/pools", @@ -5614,5 +5613,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } From 2463a946ac45e3eb2bdb28ae3e719e5c586ff6ff Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Jun 2024 11:33:11 +0300 Subject: [PATCH 04/15] platform lib downgrade --- composer.json | 2 +- composer.lock | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 9ba8db0e097..7bd47fc9e40 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ "utopia-php/messaging": "0.12.*", "utopia-php/migration": "0.4.*", "utopia-php/orchestration": "0.9.*", - "utopia-php/platform": "0.5.*", + "utopia-php/platform": "0.6.*", "utopia-php/pools": "0.5.*", "utopia-php/preloader": "0.2.*", "utopia-php/queue": "0.7.*", diff --git a/composer.lock b/composer.lock index 5ee1aff322f..191454cd5f9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9ba1190efa21ae307532896397b3228d", + "content-hash": "281a3b7e9ccda11cca5599c49d2b7b6a", "packages": [ { "name": "adhocore/jwt", @@ -2327,16 +2327,16 @@ }, { "name": "utopia-php/platform", - "version": "0.5.2", + "version": "0.6.1", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "b9feabc79b92dc2b05683a986ad43bce5c1583e3" + "reference": "48910f25a9746ed35e8c6952ac1f53ceef0213cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/b9feabc79b92dc2b05683a986ad43bce5c1583e3", - "reference": "b9feabc79b92dc2b05683a986ad43bce5c1583e3", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/48910f25a9746ed35e8c6952ac1f53ceef0213cb", + "reference": "48910f25a9746ed35e8c6952ac1f53ceef0213cb", "shasum": "" }, "require": { @@ -2344,7 +2344,8 @@ "ext-redis": "*", "php": ">=8.0", "utopia-php/cli": "0.15.*", - "utopia-php/framework": "0.33.*" + "utopia-php/framework": "0.33.*", + "utopia-php/queue": "0.7.*" }, "require-dev": { "laravel/pint": "1.2.*", @@ -2370,9 +2371,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.5.2" + "source": "https://github.com/utopia-php/platform/tree/0.6.1" }, - "time": "2024-05-22T12:50:35+00:00" + "time": "2024-04-08T05:15:31+00:00" }, { "name": "utopia-php/pools", From cc8dd800df5385580c59088478408f26883011d4 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Jun 2024 12:03:59 +0300 Subject: [PATCH 05/15] platform lib downgrade --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 7bd47fc9e40..192b3118221 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ "utopia-php/messaging": "0.12.*", "utopia-php/migration": "0.4.*", "utopia-php/orchestration": "0.9.*", - "utopia-php/platform": "0.6.*", + "utopia-php/platform": "0.7.*", "utopia-php/pools": "0.5.*", "utopia-php/preloader": "0.2.*", "utopia-php/queue": "0.7.*", diff --git a/composer.lock b/composer.lock index 191454cd5f9..3792163c999 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "281a3b7e9ccda11cca5599c49d2b7b6a", + "content-hash": "e002600539435ca8eaaace6e73b4004d", "packages": [ { "name": "adhocore/jwt", @@ -2327,16 +2327,16 @@ }, { "name": "utopia-php/platform", - "version": "0.6.1", + "version": "0.7.0", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "48910f25a9746ed35e8c6952ac1f53ceef0213cb" + "reference": "beeea0f2c9bce14a6869fc5c87a1047cdecb5c52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/48910f25a9746ed35e8c6952ac1f53ceef0213cb", - "reference": "48910f25a9746ed35e8c6952ac1f53ceef0213cb", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/beeea0f2c9bce14a6869fc5c87a1047cdecb5c52", + "reference": "beeea0f2c9bce14a6869fc5c87a1047cdecb5c52", "shasum": "" }, "require": { @@ -2371,9 +2371,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.6.1" + "source": "https://github.com/utopia-php/platform/tree/0.7.0" }, - "time": "2024-04-08T05:15:31+00:00" + "time": "2024-05-08T17:00:55+00:00" }, { "name": "utopia-php/pools", From 40197555ad835d82ba0975c616d47db4896d3171 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Jun 2024 13:10:35 +0300 Subject: [PATCH 06/15] deleteUser $dbForConsole = null --- src/Appwrite/Platform/Workers/Deletes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 2755fbf4013..d7a1e20419f 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -93,7 +93,7 @@ public function action(Message $message, Database $dbForConsole, callable $getPr $this->deleteDeployment($getProjectDB, $deviceForFunctions, $deviceForBuilds, $document, $project); break; case DELETE_TYPE_USERS: - $this->deleteUser($getProjectDB, $document, $project); + $this->deleteUser($getProjectDB, $document, $project, $dbForConsole = null); break; case DELETE_TYPE_TEAMS: $this->deleteMemberships($getProjectDB, $document, $project); From 532576d282db79e98aec1803a4053a160c412f7b Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Jun 2024 15:04:11 +0300 Subject: [PATCH 07/15] deleteUser $dbForConsole = null --- src/Appwrite/Platform/Workers/Deletes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index d7a1e20419f..31484c4c6aa 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -576,6 +576,7 @@ protected function deleteProject(Database $dbForConsole, callable $getProjectDB */ protected function deleteUser(callable $getProjectDB, Document $document, Document $project): void { + var_dump("in appwrite"); $userId = $document->getId(); $userInternalId = $document->getInternalId(); $dbForProject = $getProjectDB($project); From 7b296e07f7e502400968d6792d6cda95b7b0e13d Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Jun 2024 15:42:46 +0300 Subject: [PATCH 08/15] adding const for compatibility --- app/init.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/init.php b/app/init.php index a86156c7501..fc49c74b7ab 100644 --- a/app/init.php +++ b/app/init.php @@ -143,6 +143,9 @@ const APP_SOCIAL_YOUTUBE = 'https://www.youtube.com/c/appwrite?sub_confirmation=1'; const APP_HOSTNAME_INTERNAL = 'appwrite'; +// Databases +const DATABASE_SHARED_TABLES = 'database_db_fra1_self_hosted_16_0'; + // Database Reconnect const DATABASE_RECONNECT_SLEEP = 2; const DATABASE_RECONNECT_MAX_ATTEMPTS = 10; From 2bd5ac64fed3430040bf44442cf42cbd5260ffd2 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Jun 2024 21:08:11 +0300 Subject: [PATCH 09/15] adding const for compatibility --- src/Appwrite/Platform/Workers/Deletes.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 31484c4c6aa..eea53068378 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -93,7 +93,7 @@ public function action(Message $message, Database $dbForConsole, callable $getPr $this->deleteDeployment($getProjectDB, $deviceForFunctions, $deviceForBuilds, $document, $project); break; case DELETE_TYPE_USERS: - $this->deleteUser($getProjectDB, $document, $project, $dbForConsole = null); + $this->deleteUser($getProjectDB, $document, $project, $dbForConsole); break; case DELETE_TYPE_TEAMS: $this->deleteMemberships($getProjectDB, $document, $project); @@ -574,9 +574,9 @@ protected function deleteProject(Database $dbForConsole, callable $getProjectDB * @return void * @throws Exception */ - protected function deleteUser(callable $getProjectDB, Document $document, Document $project): void + protected function deleteUser(callable $getProjectDB, Document $document, Document $project, Database $dbForConsole): void { - var_dump("in appwrite"); + $userId = $document->getId(); $userInternalId = $document->getInternalId(); $dbForProject = $getProjectDB($project); From 65ec08a01883217fe161fdd09d026201fb6f7b79 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 13 Jun 2024 14:19:30 +0300 Subject: [PATCH 10/15] response fix --- src/Appwrite/Platform/Workers/Deletes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index eea53068378..b5e121604f5 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -93,7 +93,7 @@ public function action(Message $message, Database $dbForConsole, callable $getPr $this->deleteDeployment($getProjectDB, $deviceForFunctions, $deviceForBuilds, $document, $project); break; case DELETE_TYPE_USERS: - $this->deleteUser($getProjectDB, $document, $project, $dbForConsole); + $this->deleteUser($getProjectDB, $document, $project); break; case DELETE_TYPE_TEAMS: $this->deleteMemberships($getProjectDB, $document, $project); @@ -574,7 +574,7 @@ protected function deleteProject(Database $dbForConsole, callable $getProjectDB * @return void * @throws Exception */ - protected function deleteUser(callable $getProjectDB, Document $document, Document $project, Database $dbForConsole): void + protected function deleteUser(callable $getProjectDB, Document $document, Document $project): void { $userId = $document->getId(); From 5fefa405034222be5ff4b89c8fc3678546a04831 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 16 Jun 2024 11:10:49 +0300 Subject: [PATCH 11/15] Delete user update --- composer.lock | 27 ++++++++++++----------- src/Appwrite/Platform/Workers/Deletes.php | 7 ++++++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/composer.lock b/composer.lock index 3792163c999..d6672589098 100644 --- a/composer.lock +++ b/composer.lock @@ -2988,16 +2988,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.38.6", + "version": "0.38.7", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "d7016d6d72545e84709892faca972eb4bf5bd699" + "reference": "0a66c1149ef05ed9f45ce1c897c4a0ce9ee5e95a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/d7016d6d72545e84709892faca972eb4bf5bd699", - "reference": "d7016d6d72545e84709892faca972eb4bf5bd699", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/0a66c1149ef05ed9f45ce1c897c4a0ce9ee5e95a", + "reference": "0a66c1149ef05ed9f45ce1c897c4a0ce9ee5e95a", "shasum": "" }, "require": { @@ -3033,9 +3033,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.38.6" + "source": "https://github.com/appwrite/sdk-generator/tree/0.38.7" }, - "time": "2024-05-20T18:00:16+00:00" + "time": "2024-06-10T00:23:02+00:00" }, { "name": "doctrine/deprecations", @@ -3346,16 +3346,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -3363,11 +3363,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -3393,7 +3394,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -3401,7 +3402,7 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "nikic/php-parser", diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index b5e121604f5..db5ca949900 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -596,6 +596,13 @@ protected function deleteUser(callable $getProjectDB, Document $document, Docum $teamId = $document->getAttribute('teamId'); $team = $dbForProject->getDocument('teams', $teamId); if (!$team->isEmpty()) { + $total = $document->getAttribute('total'); + // Delete the team if the user is the last membership + if ($total === 1) { + $this->deleteById($team, $dbForProject); + return; + } + $dbForProject->decreaseDocumentAttribute('teams', $teamId, 'total', 1, 0); } } From 77daa30759eae526c8f2aa3392de972317f4e66f Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 16 Jun 2024 11:13:07 +0300 Subject: [PATCH 12/15] Delete user update --- app/init.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/init.php b/app/init.php index fc49c74b7ab..a86156c7501 100644 --- a/app/init.php +++ b/app/init.php @@ -143,9 +143,6 @@ const APP_SOCIAL_YOUTUBE = 'https://www.youtube.com/c/appwrite?sub_confirmation=1'; const APP_HOSTNAME_INTERNAL = 'appwrite'; -// Databases -const DATABASE_SHARED_TABLES = 'database_db_fra1_self_hosted_16_0'; - // Database Reconnect const DATABASE_RECONNECT_SLEEP = 2; const DATABASE_RECONNECT_MAX_ATTEMPTS = 10; From 8520a66fd9a0977e43a77a2aadf3dae46f3690e9 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 16 Jun 2024 15:56:04 +0300 Subject: [PATCH 13/15] Delete user update --- src/Appwrite/Platform/Workers/Deletes.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index db5ca949900..2a44dc80ff3 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -597,12 +597,14 @@ protected function deleteUser(callable $getProjectDB, Document $document, Docum $team = $dbForProject->getDocument('teams', $teamId); if (!$team->isEmpty()) { $total = $document->getAttribute('total'); + var_dump('$total='.$total); // Delete the team if the user is the last membership if ($total === 1) { + var_dump('Deleting team'); $this->deleteById($team, $dbForProject); return; } - + var_dump('decrease total'); $dbForProject->decreaseDocumentAttribute('teams', $teamId, 'total', 1, 0); } } From 8537e1ce32ae12e7b45e62a6208c2cf2b72a7a1a Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 16 Jun 2024 16:43:09 +0300 Subject: [PATCH 14/15] Delete user update --- src/Appwrite/Platform/Workers/Deletes.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 2a44dc80ff3..82b3096cef6 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -597,14 +597,11 @@ protected function deleteUser(callable $getProjectDB, Document $document, Docum $team = $dbForProject->getDocument('teams', $teamId); if (!$team->isEmpty()) { $total = $document->getAttribute('total'); - var_dump('$total='.$total); // Delete the team if the user is the last membership if ($total === 1) { - var_dump('Deleting team'); $this->deleteById($team, $dbForProject); return; } - var_dump('decrease total'); $dbForProject->decreaseDocumentAttribute('teams', $teamId, 'total', 1, 0); } } From 1d7c38512c9869fada92126cb0cebca5038d94c6 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 18 Jun 2024 18:12:29 +0300 Subject: [PATCH 15/15] Delete user update --- src/Appwrite/Platform/Workers/Deletes.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 82b3096cef6..6c269b4e87b 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -587,19 +587,22 @@ protected function deleteUser(callable $getProjectDB, Document $document, Docum ], $dbForProject); $dbForProject->purgeCachedDocument('users', $userId); - + var_dump('in delete worker'); // Delete Memberships and decrement team membership counts $this->deleteByGroup('memberships', [ Query::equal('userInternalId', [$userInternalId]) ], $dbForProject, function (Document $document) use ($dbForProject) { + var_dump($document->getAttribute('confirm')); if ($document->getAttribute('confirm')) { // Count only confirmed members $teamId = $document->getAttribute('teamId'); $team = $dbForProject->getDocument('teams', $teamId); if (!$team->isEmpty()) { $total = $document->getAttribute('total'); + var_dump('$total='.$total); // Delete the team if the user is the last membership if ($total === 1) { $this->deleteById($team, $dbForProject); + var_dump('delete team'); return; } $dbForProject->decreaseDocumentAttribute('teams', $teamId, 'total', 1, 0);