From 03d33601b07b1545841bf466a254fc91b5a7b212 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 14 Jun 2024 13:08:30 +1200 Subject: [PATCH 001/144] Override find --- app/cli.php | 2 +- app/config/collections.php | 2 +- app/controllers/api/account.php | 2 +- app/controllers/api/avatars.php | 2 +- app/controllers/api/databases.php | 2 +- app/controllers/api/functions.php | 2 +- app/controllers/api/messaging.php | 2 +- app/controllers/api/migrations.php | 2 +- app/controllers/api/project.php | 2 +- app/controllers/api/projects.php | 2 +- app/controllers/api/proxy.php | 2 +- app/controllers/api/storage.php | 2 +- app/controllers/api/teams.php | 2 +- app/controllers/api/users.php | 2 +- app/controllers/api/vcs.php | 2 +- app/controllers/general.php | 2 +- app/controllers/mock.php | 2 +- app/controllers/shared/api.php | 2 +- app/http.php | 4 +- app/init.php | 8 ++-- app/realtime.php | 2 +- app/worker.php | 2 +- src/Appwrite/Migration/Migration.php | 6 +-- src/Appwrite/Migration/Version/V15.php | 2 +- src/Appwrite/Migration/Version/V16.php | 2 +- src/Appwrite/Migration/Version/V17.php | 2 +- src/Appwrite/Migration/Version/V18.php | 2 +- src/Appwrite/Migration/Version/V19.php | 2 +- src/Appwrite/Migration/Version/V20.php | 2 +- src/Appwrite/Platform/Tasks/Maintenance.php | 2 +- src/Appwrite/Platform/Tasks/Migrate.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleBase.php | 2 +- .../Platform/Tasks/ScheduleFunctions.php | 2 +- .../Platform/Tasks/ScheduleMessages.php | 2 +- src/Appwrite/Platform/Tasks/Specs.php | 2 +- src/Appwrite/Platform/Workers/Audits.php | 2 +- src/Appwrite/Platform/Workers/Builds.php | 2 +- .../Platform/Workers/Certificates.php | 2 +- src/Appwrite/Platform/Workers/Databases.php | 2 +- src/Appwrite/Platform/Workers/Deletes.php | 2 +- src/Appwrite/Platform/Workers/Functions.php | 2 +- src/Appwrite/Platform/Workers/Messaging.php | 2 +- src/Appwrite/Platform/Workers/Migrations.php | 2 +- src/Appwrite/Platform/Workers/Webhooks.php | 2 +- src/Appwrite/Utopia/Database/Database.php | 42 +++++++++++++++++++ .../Database/Validator/Queries/Base.php | 2 +- .../e2e/Services/Databases/DatabasesBase.php | 2 +- .../Databases/DatabasesCustomClientTest.php | 2 +- .../Databases/DatabasesCustomServerTest.php | 2 +- .../Services/GraphQL/DatabaseServerTest.php | 2 +- 50 files changed, 97 insertions(+), 55 deletions(-) create mode 100644 src/Appwrite/Utopia/Database/Database.php diff --git a/app/cli.php b/app/cli.php index 87bb711daa..4fb846e023 100644 --- a/app/cli.php +++ b/app/cli.php @@ -7,12 +7,12 @@ use Appwrite\Event\Certificate; use Appwrite\Event\Delete; use Appwrite\Event\Func; use Appwrite\Platform\Appwrite; +use Appwrite\Utopia\Database\Database; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\CLI; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; use Utopia\DSN\DSN; diff --git a/app/config/collections.php b/app/config/collections.php index 72d126e343..ecc1a7815c 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1,8 +1,8 @@ on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg try { $attempts++; $dbForConsole = $app->getResource('dbForConsole'); - /** @var Utopia\Database\Database $dbForConsole */ + /** @var Appwrite\Utopia\Database\Database $dbForConsole */ break; // leave the do-while if successful } catch (\Throwable $e) { Console::warning("Database not ready. Retrying connection ({$attempts})..."); diff --git a/app/init.php b/app/init.php index a86156c750..786e894fa8 100644 --- a/app/init.php +++ b/app/init.php @@ -40,6 +40,7 @@ use Appwrite\Network\Validator\Email; use Appwrite\Network\Validator\Origin; use Appwrite\OpenSSL\OpenSSL; use Appwrite\URL\URL as AppwriteURL; +use Appwrite\Utopia\Database\Database; use MaxMind\Db\Reader; use PHPMailer\PHPMailer\PHPMailer; use Swoole\Database\PDOProxy; @@ -52,7 +53,6 @@ use Utopia\Config\Config; use Utopia\Database\Adapter\MariaDB; use Utopia\Database\Adapter\MySQL; use Utopia\Database\Adapter\SQL; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; @@ -1124,8 +1124,8 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons /** @var Appwrite\Utopia\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Document $project */ - /** @var Utopia\Database\Database $dbForProject */ - /** @var Utopia\Database\Database $dbForConsole */ + /** @var Appwrite\Utopia\Database\Database $dbForProject */ + /** @var Appwrite\Utopia\Database\Database $dbForConsole */ /** @var string $mode */ Authorization::setDefaultStatus(true); @@ -1229,7 +1229,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons App::setResource('project', function ($dbForConsole, $request, $console) { /** @var Appwrite\Utopia\Request $request */ - /** @var Utopia\Database\Database $dbForConsole */ + /** @var Appwrite\Utopia\Database\Database $dbForConsole */ /** @var Utopia\Database\Document $console */ $projectId = $request->getParam('project', $request->getHeader('x-appwrite-project', '')); diff --git a/app/realtime.php b/app/realtime.php index cde4327417..5a2fa7b55d 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -5,6 +5,7 @@ use Appwrite\Extend\Exception; use Appwrite\Extend\Exception as AppwriteException; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Network\Validator\Origin; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; use Swoole\Http\Request as SwooleRequest; @@ -19,7 +20,6 @@ use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; diff --git a/app/worker.php b/app/worker.php index bca92c433f..7ac679a02a 100644 --- a/app/worker.php +++ b/app/worker.php @@ -15,13 +15,13 @@ use Appwrite\Event\Migration; use Appwrite\Event\Usage; use Appwrite\Event\UsageDump; use Appwrite\Platform\Appwrite; +use Appwrite\Utopia\Database\Database; use Swoole\Runtime; use Utopia\App; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 15c14daf51..9ccea5bdb6 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -2,11 +2,11 @@ namespace Appwrite\Migration; +use Appwrite\Utopia\Database\Database; use Exception; use Swoole\Runtime; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; @@ -293,7 +293,7 @@ abstract class Migration /** * Creates attribute from collections.php * - * @param \Utopia\Database\Database $database + * @param \Appwrite\Utopia\Database\Database $database * @param string $collectionId * @param string $attributeId * @return void @@ -350,7 +350,7 @@ abstract class Migration /** * Creates index from collections.php * - * @param \Utopia\Database\Database $database + * @param \Appwrite\Utopia\Database\Database $database * @param string $collectionId * @param string $indexId * @param string|null $from diff --git a/src/Appwrite/Migration/Version/V15.php b/src/Appwrite/Migration/Version/V15.php index ca20b6d7b3..756553b1ba 100644 --- a/src/Appwrite/Migration/Version/V15.php +++ b/src/Appwrite/Migration/Version/V15.php @@ -4,9 +4,9 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; use Appwrite\OpenSSL\OpenSSL; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; diff --git a/src/Appwrite/Migration/Version/V16.php b/src/Appwrite/Migration/Version/V16.php index 49f244598e..28a3369c58 100644 --- a/src/Appwrite/Migration/Version/V16.php +++ b/src/Appwrite/Migration/Version/V16.php @@ -4,9 +4,9 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; class V16 extends Migration diff --git a/src/Appwrite/Migration/Version/V17.php b/src/Appwrite/Migration/Version/V17.php index 96c890c65d..6c82c34aef 100644 --- a/src/Appwrite/Migration/Version/V17.php +++ b/src/Appwrite/Migration/Version/V17.php @@ -4,8 +4,8 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; class V17 extends Migration diff --git a/src/Appwrite/Migration/Version/V18.php b/src/Appwrite/Migration/Version/V18.php index ac4093aaca..429ac9aeab 100644 --- a/src/Appwrite/Migration/Version/V18.php +++ b/src/Appwrite/Migration/Version/V18.php @@ -3,8 +3,8 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index bb887e40f7..0ecc9c9612 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -3,9 +3,9 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception; diff --git a/src/Appwrite/Migration/Version/V20.php b/src/Appwrite/Migration/Version/V20.php index 1a599d32f2..d89acb4980 100644 --- a/src/Appwrite/Migration/Version/V20.php +++ b/src/Appwrite/Migration/Version/V20.php @@ -4,11 +4,11 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Exception; use PDOException; use Throwable; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index cfbc4b200a..d3343f10fc 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -4,8 +4,8 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Certificate; use Appwrite\Event\Delete; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Query; diff --git a/src/Appwrite/Platform/Tasks/Migrate.php b/src/Appwrite/Platform/Tasks/Migrate.php index 6e4fe38eb7..d0796c636a 100644 --- a/src/Appwrite/Platform/Tasks/Migrate.php +++ b/src/Appwrite/Platform/Tasks/Migrate.php @@ -3,10 +3,10 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\App; use Utopia\Cache\Cache; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index a50fbb2403..ea06109f48 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -2,9 +2,9 @@ namespace Appwrite\Platform\Tasks; +use Appwrite\Utopia\Database\Database; use Swoole\Timer; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception; diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index e2c278714f..f081f6ac0d 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -3,9 +3,9 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Func; +use Appwrite\Utopia\Database\Database; use Cron\CronExpression; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Pools\Group; diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 8e52973a0c..98c5c7a540 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -3,7 +3,7 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Messaging; -use Utopia\Database\Database; +use Appwrite\Utopia\Database\Database; use Utopia\Pools\Group; class ScheduleMessages extends ScheduleBase diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index 114e12ac85..945f718417 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -5,6 +5,7 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Specification\Format\OpenAPI3; use Appwrite\Specification\Format\Swagger2; use Appwrite\Specification\Specification; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response; use Exception; use Swoole\Http\Response as HttpResponse; @@ -14,7 +15,6 @@ use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Adapter\MySQL; -use Utopia\Database\Database; use Utopia\Platform\Action; use Utopia\Registry\Registry; use Utopia\Request; diff --git a/src/Appwrite/Platform/Workers/Audits.php b/src/Appwrite/Platform/Workers/Audits.php index 86ca59d3fd..69747c8c9b 100644 --- a/src/Appwrite/Platform/Workers/Audits.php +++ b/src/Appwrite/Platform/Workers/Audits.php @@ -2,10 +2,10 @@ namespace Appwrite\Platform\Workers; +use Appwrite\Utopia\Database\Database; use Exception; use Throwable; use Utopia\Audit\Audit; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Structure; diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 8bb9dbb390..3ab17c45b1 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -6,6 +6,7 @@ use Appwrite\Event\Event; use Appwrite\Event\Func; use Appwrite\Event\Usage; use Appwrite\Messaging\Adapter\Realtime; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response\Model\Deployment; use Appwrite\Vcs\Comment; use Executor\Executor; @@ -13,7 +14,6 @@ use Swoole\Coroutine as Co; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Conflict; diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 1fbbd3b2ec..ca7179850b 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -8,12 +8,12 @@ use Appwrite\Event\Mail; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Network\Validator\CNAME; use Appwrite\Template\Template; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response\Model\Rule; use Exception; use Throwable; use Utopia\App; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 56f5f012e8..9f32398c3d 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -4,10 +4,10 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Event; use Appwrite\Messaging\Adapter\Realtime; +use Appwrite\Utopia\Database\Database; use Exception; use Utopia\Audit\Audit; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception as DatabaseException; use Utopia\Database\Exception\Authorization; diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index d54f3f5079..e00a0c824c 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -4,6 +4,7 @@ namespace Appwrite\Platform\Workers; use Appwrite\Auth\Auth; use Appwrite\Extend\Exception; +use Appwrite\Utopia\Database\Database; use Executor\Executor; use Throwable; use Utopia\Abuse\Abuse; @@ -13,7 +14,6 @@ use Utopia\Cache\Adapter\Filesystem; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception as DatabaseException; diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index b071a79bfd..75a82f385d 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -6,12 +6,12 @@ use Appwrite\Event\Event; use Appwrite\Event\Func; use Appwrite\Event\Usage; use Appwrite\Messaging\Adapter\Realtime; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response\Model\Execution; use Exception; use Executor\Executor; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Conflict; diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 6f642fabb7..72c81ad2a5 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -4,10 +4,10 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Usage; use Appwrite\Messaging\Status as MessageStatus; +use Appwrite\Utopia\Database\Database; use Swoole\Runtime; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 8e4aa5216d..04935b806f 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -6,9 +6,9 @@ use Appwrite\Event\Event; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Permission; use Appwrite\Role; +use Appwrite\Utopia\Database\Database; use Exception; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Conflict; diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index d60946f709..de9d46147f 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -4,8 +4,8 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Mail; use Appwrite\Template\Template; +use Appwrite\Utopia\Database\Database; use Exception; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Logger\Log; diff --git a/src/Appwrite/Utopia/Database/Database.php b/src/Appwrite/Utopia/Database/Database.php new file mode 100644 index 0000000000..3e0a59b394 --- /dev/null +++ b/src/Appwrite/Utopia/Database/Database.php @@ -0,0 +1,42 @@ +getMethod() === Query::TYPE_SEARCH || $query->getMethod() === Query::TYPE_EQUAL) { + $attribute = $query->getAttribute(); + + if ($collectionCache === null) { + $collectionCache = $this->silent(fn () => $this->getCollection($collection)); + } + + $attributeMetadata = null; + foreach ($collectionCache->getAttribute('attributes', []) as $attributeDocument) { + if ($attributeDocument->getId() === $attribute) { + $attributeMetadata = $attributeDocument; + break; + } + } + + if ($attributeMetadata !== null) { + if ($attributeMetadata->getAttribute('array', false) === true) { + $query->setMethod(Query::TYPE_CONTAINS); + } + } + } + } + } catch (\Throwable $err) { + // Ignore error, to not do any harm + } + + return parent::find($collection, $queries); + } +} diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index a3555c08dd..1f3f0effda 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -2,8 +2,8 @@ namespace Appwrite\Utopia\Database\Validator\Queries; +use Appwrite\Utopia\Database\Database; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Queries; use Utopia\Database\Validator\Query\Cursor; diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 6f65552f1c..492253f74f 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -3,8 +3,8 @@ namespace Tests\E2E\Services\Databases; use Appwrite\Extend\Exception; +use Appwrite\Utopia\Database\Database; use Tests\E2E\Client; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; diff --git a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php index 8484996058..bff3c44d47 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php @@ -2,11 +2,11 @@ namespace Tests\E2E\Services\Databases; +use Appwrite\Utopia\Database\Database; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideClient; -use Utopia\Database\Database; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; diff --git a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php index 085d3ca01b..558443c249 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php @@ -3,11 +3,11 @@ namespace Tests\E2E\Services\Databases; use Appwrite\Extend\Exception as AppwriteException; +use Appwrite\Utopia\Database\Database; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception; use Utopia\Database\Helpers\ID; diff --git a/tests/e2e/Services/GraphQL/DatabaseServerTest.php b/tests/e2e/Services/GraphQL/DatabaseServerTest.php index 87006a1bea..ba0bec9549 100644 --- a/tests/e2e/Services/GraphQL/DatabaseServerTest.php +++ b/tests/e2e/Services/GraphQL/DatabaseServerTest.php @@ -2,12 +2,12 @@ namespace Tests\E2E\Services\GraphQL; +use Appwrite\Utopia\Database\Database; use Exception; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\Database\Database; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; From 5f7aae0e6098d1ad21ba17e4386374051728934c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 21 Jun 2024 13:43:01 +1200 Subject: [PATCH 002/144] Add missing import --- app/controllers/api/databases.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index c4a5025a2f..9ed71300a9 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -15,6 +15,7 @@ use Appwrite\Utopia\Database\Validator\Queries\Databases; use Appwrite\Utopia\Database\Validator\Queries\Indexes; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; +use Couchbase\QueryException; use MaxMind\Db\Reader; use Utopia\App; use Utopia\Audit\Audit; From 10adfc5124146237be8d4a08d70f48557dbd9300 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 2 Jul 2024 14:55:13 +1200 Subject: [PATCH 003/144] Add mirror override --- composer.json | 6 +- composer.lock | 81 ++++++++++++--------- src/Appwrite/Platform/Workers/Databases.php | 1 - src/Appwrite/Utopia/Database/Mirror.php | 16 ++++ 4 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 src/Appwrite/Utopia/Database/Mirror.php diff --git a/composer.json b/composer.json index 192b311822..5cf1b577f1 100644 --- a/composer.json +++ b/composer.json @@ -44,13 +44,13 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.13.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "0.37.*", + "utopia-php/abuse": "0.38.*", "utopia-php/analytics": "0.10.*", - "utopia-php/audit": "0.39.*", + "utopia-php/audit": "0.40.*", "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.49.*", + "utopia-php/database": "dev-feat-migrations as 0.50.0", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index de23f2cbb0..e22a4d3336 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": "6e3cf9eae3ab957e66198445f7fd7381", "packages": [ { "name": "adhocore/jwt", @@ -1208,16 +1208,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", "shasum": "" }, "require": { @@ -1268,7 +1268,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" }, "funding": [ { @@ -1284,7 +1284,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "thecodingmachine/safe", @@ -1427,23 +1427,23 @@ }, { "name": "utopia-php/abuse", - "version": "0.37.1", + "version": "0.38.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "4dfcff4754c7804d1a70039792c0f2d59a5cc981" + "reference": "b7be9086c9d9b4561d810cbd42fdda798742f56c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/4dfcff4754c7804d1a70039792c0f2d59a5cc981", - "reference": "4dfcff4754c7804d1a70039792c0f2d59a5cc981", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/b7be9086c9d9b4561d810cbd42fdda798742f56c", + "reference": "b7be9086c9d9b4561d810cbd42fdda798742f56c", "shasum": "" }, "require": { "ext-curl": "*", "ext-pdo": "*", "php": ">=8.0", - "utopia-php/database": "0.49.*" + "utopia-php/database": "0.50.*" }, "require-dev": { "laravel/pint": "1.5.*", @@ -1470,9 +1470,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.37.1" + "source": "https://github.com/utopia-php/abuse/tree/0.38.0" }, - "time": "2024-06-05T18:03:59+00:00" + "time": "2024-06-24T00:52:02+00:00" }, { "name": "utopia-php/analytics", @@ -1522,21 +1522,21 @@ }, { "name": "utopia-php/audit", - "version": "0.39.1", + "version": "0.40.0", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "7ea91e0ceea7b94293612fea94022b73315677c2" + "reference": "735ae211ce5fee5b52b736731571b4030b1d7cdc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/7ea91e0ceea7b94293612fea94022b73315677c2", - "reference": "7ea91e0ceea7b94293612fea94022b73315677c2", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/735ae211ce5fee5b52b736731571b4030b1d7cdc", + "reference": "735ae211ce5fee5b52b736731571b4030b1d7cdc", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "0.49.*" + "utopia-php/database": "0.50.*" }, "require-dev": { "laravel/pint": "1.5.*", @@ -1563,22 +1563,22 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.39.1" + "source": "https://github.com/utopia-php/audit/tree/0.40.0" }, - "time": "2024-06-05T19:28:22+00:00" + "time": "2024-06-24T00:52:17+00:00" }, { "name": "utopia-php/cache", - "version": "0.10.1", + "version": "0.10.2", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "87ee4fc91e50d4ddfef650aa999ea12be3a99583" + "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cache/zipball/87ee4fc91e50d4ddfef650aa999ea12be3a99583", - "reference": "87ee4fc91e50d4ddfef650aa999ea12be3a99583", + "url": "https://api.github.com/repos/utopia-php/cache/zipball/b22c6eb6d308de246b023efd0fc9758aee8b8247", + "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247", "shasum": "" }, "require": { @@ -1613,9 +1613,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cache/issues", - "source": "https://github.com/utopia-php/cache/tree/0.10.1" + "source": "https://github.com/utopia-php/cache/tree/0.10.2" }, - "time": "2024-06-18T13:20:25+00:00" + "time": "2024-06-25T20:36:35+00:00" }, { "name": "utopia-php/cli", @@ -1719,16 +1719,16 @@ }, { "name": "utopia-php/database", - "version": "0.49.13", + "version": "dev-feat-migrations", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "fff42e0bd1db5a03d8c5df4302d72443bde3b860" + "reference": "28e41327874f849427a2b9c2f02d9d1a70d6b0cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/fff42e0bd1db5a03d8c5df4302d72443bde3b860", - "reference": "fff42e0bd1db5a03d8c5df4302d72443bde3b860", + "url": "https://api.github.com/repos/utopia-php/database/zipball/28e41327874f849427a2b9c2f02d9d1a70d6b0cb", + "reference": "28e41327874f849427a2b9c2f02d9d1a70d6b0cb", "shasum": "" }, "require": { @@ -1769,9 +1769,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.49.13" + "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-06-18T14:33:55+00:00" + "time": "2024-07-02T01:48:23+00:00" }, { "name": "utopia-php/domains", @@ -5589,9 +5589,18 @@ "time": "2023-11-21T18:54:41+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-feat-migrations", + "alias": "0.50.0", + "alias_normalized": "0.50.0.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -5615,5 +5624,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 9f32398c3d..e92370e806 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -135,7 +135,6 @@ class Databases extends Action $options = $attribute->getAttribute('options', []); $project = $dbForConsole->getDocument('projects', $projectId); - try { switch ($type) { case Database::VAR_RELATIONSHIP: diff --git a/src/Appwrite/Utopia/Database/Mirror.php b/src/Appwrite/Utopia/Database/Mirror.php new file mode 100644 index 0000000000..2ad1665958 --- /dev/null +++ b/src/Appwrite/Utopia/Database/Mirror.php @@ -0,0 +1,16 @@ + Date: Tue, 2 Jul 2024 19:10:02 +1200 Subject: [PATCH 004/144] Revert to utopia database instead of extension --- app/cli.php | 2 +- app/config/collections.php | 2 +- app/controllers/api/account.php | 2 +- app/controllers/api/avatars.php | 2 +- app/controllers/api/databases.php | 2 +- app/controllers/api/functions.php | 2 +- app/controllers/api/messaging.php | 2 +- app/controllers/api/migrations.php | 2 +- app/controllers/api/project.php | 2 +- app/controllers/api/projects.php | 2 +- app/controllers/api/proxy.php | 2 +- app/controllers/api/storage.php | 2 +- app/controllers/api/teams.php | 2 +- app/controllers/api/users.php | 2 +- app/controllers/api/vcs.php | 2 +- app/controllers/general.php | 2 +- app/controllers/mock.php | 2 +- app/controllers/shared/api.php | 2 +- app/http.php | 4 ++-- app/init.php | 8 ++++---- app/realtime.php | 2 +- app/worker.php | 2 +- src/Appwrite/Migration/Migration.php | 6 +++--- src/Appwrite/Migration/Version/V15.php | 2 +- src/Appwrite/Migration/Version/V16.php | 2 +- src/Appwrite/Migration/Version/V17.php | 2 +- src/Appwrite/Migration/Version/V18.php | 2 +- src/Appwrite/Migration/Version/V19.php | 2 +- src/Appwrite/Migration/Version/V20.php | 2 +- src/Appwrite/Platform/Tasks/Maintenance.php | 2 +- src/Appwrite/Platform/Tasks/Migrate.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleBase.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleFunctions.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleMessages.php | 2 +- src/Appwrite/Platform/Tasks/Specs.php | 2 +- src/Appwrite/Platform/Workers/Audits.php | 2 +- src/Appwrite/Platform/Workers/Builds.php | 2 +- src/Appwrite/Platform/Workers/Certificates.php | 2 +- src/Appwrite/Platform/Workers/Databases.php | 2 +- src/Appwrite/Platform/Workers/Deletes.php | 2 +- src/Appwrite/Platform/Workers/Functions.php | 2 +- src/Appwrite/Platform/Workers/Messaging.php | 2 +- src/Appwrite/Platform/Workers/Migrations.php | 2 +- src/Appwrite/Platform/Workers/Webhooks.php | 2 +- src/Appwrite/Utopia/Database/Validator/Queries/Base.php | 2 +- tests/e2e/Services/Databases/DatabasesBase.php | 2 +- .../e2e/Services/Databases/DatabasesCustomClientTest.php | 2 +- .../e2e/Services/Databases/DatabasesCustomServerTest.php | 2 +- tests/e2e/Services/GraphQL/DatabaseServerTest.php | 2 +- 49 files changed, 55 insertions(+), 55 deletions(-) diff --git a/app/cli.php b/app/cli.php index 4fb846e023..87bb711daa 100644 --- a/app/cli.php +++ b/app/cli.php @@ -7,12 +7,12 @@ use Appwrite\Event\Certificate; use Appwrite\Event\Delete; use Appwrite\Event\Func; use Appwrite\Platform\Appwrite; -use Appwrite\Utopia\Database\Database; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\CLI; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; use Utopia\DSN\DSN; diff --git a/app/config/collections.php b/app/config/collections.php index ecc1a7815c..72d126e343 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1,8 +1,8 @@ on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg try { $attempts++; $dbForConsole = $app->getResource('dbForConsole'); - /** @var Appwrite\Utopia\Database\Database $dbForConsole */ + /** @var Utopia\Database\Database $dbForConsole */ break; // leave the do-while if successful } catch (\Throwable $e) { Console::warning("Database not ready. Retrying connection ({$attempts})..."); diff --git a/app/init.php b/app/init.php index 786e894fa8..a86156c750 100644 --- a/app/init.php +++ b/app/init.php @@ -40,7 +40,6 @@ use Appwrite\Network\Validator\Email; use Appwrite\Network\Validator\Origin; use Appwrite\OpenSSL\OpenSSL; use Appwrite\URL\URL as AppwriteURL; -use Appwrite\Utopia\Database\Database; use MaxMind\Db\Reader; use PHPMailer\PHPMailer\PHPMailer; use Swoole\Database\PDOProxy; @@ -53,6 +52,7 @@ use Utopia\Config\Config; use Utopia\Database\Adapter\MariaDB; use Utopia\Database\Adapter\MySQL; use Utopia\Database\Adapter\SQL; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; @@ -1124,8 +1124,8 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons /** @var Appwrite\Utopia\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Document $project */ - /** @var Appwrite\Utopia\Database\Database $dbForProject */ - /** @var Appwrite\Utopia\Database\Database $dbForConsole */ + /** @var Utopia\Database\Database $dbForProject */ + /** @var Utopia\Database\Database $dbForConsole */ /** @var string $mode */ Authorization::setDefaultStatus(true); @@ -1229,7 +1229,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons App::setResource('project', function ($dbForConsole, $request, $console) { /** @var Appwrite\Utopia\Request $request */ - /** @var Appwrite\Utopia\Database\Database $dbForConsole */ + /** @var Utopia\Database\Database $dbForConsole */ /** @var Utopia\Database\Document $console */ $projectId = $request->getParam('project', $request->getHeader('x-appwrite-project', '')); diff --git a/app/realtime.php b/app/realtime.php index 5a2fa7b55d..cde4327417 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -5,7 +5,6 @@ use Appwrite\Extend\Exception; use Appwrite\Extend\Exception as AppwriteException; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Network\Validator\Origin; -use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; use Swoole\Http\Request as SwooleRequest; @@ -20,6 +19,7 @@ use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; diff --git a/app/worker.php b/app/worker.php index 7ac679a02a..bca92c433f 100644 --- a/app/worker.php +++ b/app/worker.php @@ -15,13 +15,13 @@ use Appwrite\Event\Migration; use Appwrite\Event\Usage; use Appwrite\Event\UsageDump; use Appwrite\Platform\Appwrite; -use Appwrite\Utopia\Database\Database; use Swoole\Runtime; use Utopia\App; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 9ccea5bdb6..15c14daf51 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -2,11 +2,11 @@ namespace Appwrite\Migration; -use Appwrite\Utopia\Database\Database; use Exception; use Swoole\Runtime; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; @@ -293,7 +293,7 @@ abstract class Migration /** * Creates attribute from collections.php * - * @param \Appwrite\Utopia\Database\Database $database + * @param \Utopia\Database\Database $database * @param string $collectionId * @param string $attributeId * @return void @@ -350,7 +350,7 @@ abstract class Migration /** * Creates index from collections.php * - * @param \Appwrite\Utopia\Database\Database $database + * @param \Utopia\Database\Database $database * @param string $collectionId * @param string $indexId * @param string|null $from diff --git a/src/Appwrite/Migration/Version/V15.php b/src/Appwrite/Migration/Version/V15.php index 756553b1ba..ca20b6d7b3 100644 --- a/src/Appwrite/Migration/Version/V15.php +++ b/src/Appwrite/Migration/Version/V15.php @@ -4,9 +4,9 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; use Appwrite\OpenSSL\OpenSSL; -use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; diff --git a/src/Appwrite/Migration/Version/V16.php b/src/Appwrite/Migration/Version/V16.php index 28a3369c58..49f244598e 100644 --- a/src/Appwrite/Migration/Version/V16.php +++ b/src/Appwrite/Migration/Version/V16.php @@ -4,9 +4,9 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; -use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\Document; class V16 extends Migration diff --git a/src/Appwrite/Migration/Version/V17.php b/src/Appwrite/Migration/Version/V17.php index 6c82c34aef..96c890c65d 100644 --- a/src/Appwrite/Migration/Version/V17.php +++ b/src/Appwrite/Migration/Version/V17.php @@ -4,8 +4,8 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; -use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\Document; class V17 extends Migration diff --git a/src/Appwrite/Migration/Version/V18.php b/src/Appwrite/Migration/Version/V18.php index 429ac9aeab..ac4093aaca 100644 --- a/src/Appwrite/Migration/Version/V18.php +++ b/src/Appwrite/Migration/Version/V18.php @@ -3,8 +3,8 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; -use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index 0ecc9c9612..bb887e40f7 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -3,9 +3,9 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; -use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception; diff --git a/src/Appwrite/Migration/Version/V20.php b/src/Appwrite/Migration/Version/V20.php index d89acb4980..1a599d32f2 100644 --- a/src/Appwrite/Migration/Version/V20.php +++ b/src/Appwrite/Migration/Version/V20.php @@ -4,11 +4,11 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; -use Appwrite\Utopia\Database\Database; use Exception; use PDOException; use Throwable; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index db5e02a474..1da8a58ebe 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -4,8 +4,8 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Certificate; use Appwrite\Event\Delete; -use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Query; diff --git a/src/Appwrite/Platform/Tasks/Migrate.php b/src/Appwrite/Platform/Tasks/Migrate.php index d0796c636a..6e4fe38eb7 100644 --- a/src/Appwrite/Platform/Tasks/Migrate.php +++ b/src/Appwrite/Platform/Tasks/Migrate.php @@ -3,10 +3,10 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Migration\Migration; -use Appwrite\Utopia\Database\Database; use Utopia\App; use Utopia\Cache\Cache; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index ea06109f48..a50fbb2403 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -2,9 +2,9 @@ namespace Appwrite\Platform\Tasks; -use Appwrite\Utopia\Database\Database; use Swoole\Timer; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception; diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index f081f6ac0d..e2c278714f 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -3,9 +3,9 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Func; -use Appwrite\Utopia\Database\Database; use Cron\CronExpression; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Pools\Group; diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 98c5c7a540..8e52973a0c 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -3,7 +3,7 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Messaging; -use Appwrite\Utopia\Database\Database; +use Utopia\Database\Database; use Utopia\Pools\Group; class ScheduleMessages extends ScheduleBase diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index 945f718417..114e12ac85 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -5,7 +5,6 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Specification\Format\OpenAPI3; use Appwrite\Specification\Format\Swagger2; use Appwrite\Specification\Specification; -use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response; use Exception; use Swoole\Http\Response as HttpResponse; @@ -15,6 +14,7 @@ use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Adapter\MySQL; +use Utopia\Database\Database; use Utopia\Platform\Action; use Utopia\Registry\Registry; use Utopia\Request; diff --git a/src/Appwrite/Platform/Workers/Audits.php b/src/Appwrite/Platform/Workers/Audits.php index 69747c8c9b..86ca59d3fd 100644 --- a/src/Appwrite/Platform/Workers/Audits.php +++ b/src/Appwrite/Platform/Workers/Audits.php @@ -2,10 +2,10 @@ namespace Appwrite\Platform\Workers; -use Appwrite\Utopia\Database\Database; use Exception; use Throwable; use Utopia\Audit\Audit; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Structure; diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 3ab17c45b1..8bb9dbb390 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -6,7 +6,6 @@ use Appwrite\Event\Event; use Appwrite\Event\Func; use Appwrite\Event\Usage; use Appwrite\Messaging\Adapter\Realtime; -use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response\Model\Deployment; use Appwrite\Vcs\Comment; use Executor\Executor; @@ -14,6 +13,7 @@ use Swoole\Coroutine as Co; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Conflict; diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index ca7179850b..1fbbd3b2ec 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -8,12 +8,12 @@ use Appwrite\Event\Mail; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Network\Validator\CNAME; use Appwrite\Template\Template; -use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response\Model\Rule; use Exception; use Throwable; use Utopia\App; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index e92370e806..7f5576fcea 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -4,10 +4,10 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Event; use Appwrite\Messaging\Adapter\Realtime; -use Appwrite\Utopia\Database\Database; use Exception; use Utopia\Audit\Audit; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception as DatabaseException; use Utopia\Database\Exception\Authorization; diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index e00a0c824c..d54f3f5079 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -4,7 +4,6 @@ namespace Appwrite\Platform\Workers; use Appwrite\Auth\Auth; use Appwrite\Extend\Exception; -use Appwrite\Utopia\Database\Database; use Executor\Executor; use Throwable; use Utopia\Abuse\Abuse; @@ -14,6 +13,7 @@ use Utopia\Cache\Adapter\Filesystem; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception as DatabaseException; diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index 75a82f385d..b071a79bfd 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -6,12 +6,12 @@ use Appwrite\Event\Event; use Appwrite\Event\Func; use Appwrite\Event\Usage; use Appwrite\Messaging\Adapter\Realtime; -use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response\Model\Execution; use Exception; use Executor\Executor; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Conflict; diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 72c81ad2a5..6f642fabb7 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -4,10 +4,10 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Usage; use Appwrite\Messaging\Status as MessageStatus; -use Appwrite\Utopia\Database\Database; use Swoole\Runtime; use Utopia\CLI\Console; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 04935b806f..8e4aa5216d 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -6,9 +6,9 @@ use Appwrite\Event\Event; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Permission; use Appwrite\Role; -use Appwrite\Utopia\Database\Database; use Exception; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Conflict; diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index de9d46147f..d60946f709 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -4,8 +4,8 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Mail; use Appwrite\Template\Template; -use Appwrite\Utopia\Database\Database; use Exception; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Logger\Log; diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index 1f3f0effda..a3555c08dd 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -2,8 +2,8 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Database; use Utopia\Config\Config; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Queries; use Utopia\Database\Validator\Query\Cursor; diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 492253f74f..6f65552f1c 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -3,8 +3,8 @@ namespace Tests\E2E\Services\Databases; use Appwrite\Extend\Exception; -use Appwrite\Utopia\Database\Database; use Tests\E2E\Client; +use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; diff --git a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php index bff3c44d47..8484996058 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php @@ -2,11 +2,11 @@ namespace Tests\E2E\Services\Databases; -use Appwrite\Utopia\Database\Database; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideClient; +use Utopia\Database\Database; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; diff --git a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php index 558443c249..085d3ca01b 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php @@ -3,11 +3,11 @@ namespace Tests\E2E\Services\Databases; use Appwrite\Extend\Exception as AppwriteException; -use Appwrite\Utopia\Database\Database; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; +use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception; use Utopia\Database\Helpers\ID; diff --git a/tests/e2e/Services/GraphQL/DatabaseServerTest.php b/tests/e2e/Services/GraphQL/DatabaseServerTest.php index ba0bec9549..87006a1bea 100644 --- a/tests/e2e/Services/GraphQL/DatabaseServerTest.php +++ b/tests/e2e/Services/GraphQL/DatabaseServerTest.php @@ -2,12 +2,12 @@ namespace Tests\E2E\Services\GraphQL; -use Appwrite\Utopia\Database\Database; use Exception; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; +use Utopia\Database\Database; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; From a23402075eb078df21f9bb441ddb166238f22b4a Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 12 Aug 2024 17:45:43 +1200 Subject: [PATCH 005/144] Update database --- composer.json | 2 +- composer.lock | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 6fa56a4a31..6e7264f7ff 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.50.*", + "utopia-php/database": "dev-feat-single-shared-metadata-doc as 0.50.1", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index cd1cdf2a11..32b65d98e6 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": "b5c0db330bf30bd1d240b96116d96baf", + "content-hash": "2ca805c838d52ddffe38af10dcbcfacb", "packages": [ { "name": "adhocore/jwt", @@ -1720,16 +1720,16 @@ }, { "name": "utopia-php/database", - "version": "0.50.1", + "version": "dev-feat-single-shared-metadata-doc", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "1745147bef29a9bddf5dd03fd9174ec29e2c26f0" + "reference": "397aaa6ed4e7ee87042c51b2a1d900de13100679" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/1745147bef29a9bddf5dd03fd9174ec29e2c26f0", - "reference": "1745147bef29a9bddf5dd03fd9174ec29e2c26f0", + "url": "https://api.github.com/repos/utopia-php/database/zipball/397aaa6ed4e7ee87042c51b2a1d900de13100679", + "reference": "397aaa6ed4e7ee87042c51b2a1d900de13100679", "shasum": "" }, "require": { @@ -1770,9 +1770,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.50.1" + "source": "https://github.com/utopia-php/database/tree/feat-single-shared-metadata-doc" }, - "time": "2024-07-26T11:56:05+00:00" + "time": "2024-08-12T03:46:06+00:00" }, { "name": "utopia-php/domains", @@ -5591,9 +5591,18 @@ "time": "2023-11-21T18:54:41+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-feat-single-shared-metadata-doc", + "alias": "0.50.1", + "alias_normalized": "0.50.1.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { From 8ff72b341efb192743338f547f15eb0ddcad2038 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 12 Aug 2024 23:46:34 +1200 Subject: [PATCH 006/144] Don't set tenant for project collections creation --- app/controllers/api/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index bc8f372991..824a06b598 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -188,7 +188,7 @@ App::post('/v1/projects') if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { $dbForProject ->setSharedTables(true) - ->setTenant($project->getInternalId()) + ->setTenant(null) ->setNamespace($dsn->getParam('namespace')); } else { $dbForProject From 340aa48d938f341ab70d7518706655a7919ecff0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 13 Aug 2024 21:14:52 +1200 Subject: [PATCH 007/144] Catch duplicate on console db create --- Dockerfile | 6 +++--- app/http.php | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7cc0403b84..bcb14e9aa3 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM composer:2.0 as composer +FROM composer:2.0 AS composer ARG TESTING=false ENV TESTING=$TESTING @@ -12,7 +12,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \ --no-plugins --no-scripts --prefer-dist \ `if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi` -FROM --platform=$BUILDPLATFORM node:20.11.0-alpine3.19 as node +FROM --platform=$BUILDPLATFORM node:20.11.0-alpine3.19 AS node COPY app/console /usr/local/src/console @@ -29,7 +29,7 @@ ENV VITE_APPWRITE_GROWTH_ENDPOINT=$VITE_APPWRITE_GROWTH_ENDPOINT RUN npm ci RUN npm run build -FROM appwrite/base:0.9.1 as final +FROM appwrite/base:0.9.1 AS final LABEL maintainer="team@appwrite.io" diff --git a/app/http.php b/app/http.php index 20a5288fe4..a06563ceae 100644 --- a/app/http.php +++ b/app/http.php @@ -16,6 +16,7 @@ use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Exception\Duplicate; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; @@ -94,7 +95,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg try { Console::success('[Setup] - Creating database: appwrite...'); $dbForConsole->create(); - } catch (\Throwable $e) { + } catch (Duplicate) { Console::success('[Setup] - Skip: metadata table already exists'); } @@ -226,7 +227,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg }); }); -$http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) use ($register) { +$http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) use ($register) { App::setResource('swooleRequest', fn () => $swooleRequest); App::setResource('swooleResponse', fn () => $swooleResponse); From 73ca1efbeb435143a3d249d4e5789baecf08b896 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 13 Aug 2024 21:49:14 +1200 Subject: [PATCH 008/144] Catch duplicate db on project create --- app/controllers/api/projects.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 824a06b598..78690542a1 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -197,7 +197,11 @@ App::post('/v1/projects') ->setNamespace('_' . $project->getInternalId()); } - $dbForProject->create(); + try { + $dbForProject->create(); + } catch (Duplicate) { + // Database already exists + } $audit = new Audit($dbForProject); $audit->setup(); From 11ec31aefbee972923726c0d61bc068f645b05dd Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 13 Aug 2024 21:49:25 +1200 Subject: [PATCH 009/144] Update database --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 32b65d98e6..0fba9e6c8f 100644 --- a/composer.lock +++ b/composer.lock @@ -1724,12 +1724,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "397aaa6ed4e7ee87042c51b2a1d900de13100679" + "reference": "d7ae07e0b431c8245a72fb10aea6c08a0290dc4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/397aaa6ed4e7ee87042c51b2a1d900de13100679", - "reference": "397aaa6ed4e7ee87042c51b2a1d900de13100679", + "url": "https://api.github.com/repos/utopia-php/database/zipball/d7ae07e0b431c8245a72fb10aea6c08a0290dc4d", + "reference": "d7ae07e0b431c8245a72fb10aea6c08a0290dc4d", "shasum": "" }, "require": { @@ -1747,7 +1747,7 @@ "phpstan/phpstan": "1.10.*", "phpunit/phpunit": "^9.4", "rregeer/phpunit-coverage-check": "^0.3.1", - "swoole/ide-helper": "4.8.0", + "swoole/ide-helper": "5.1.2", "utopia-php/cli": "^0.14.0" }, "type": "library", @@ -1772,7 +1772,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-single-shared-metadata-doc" }, - "time": "2024-08-12T03:46:06+00:00" + "time": "2024-08-13T08:57:53+00:00" }, { "name": "utopia-php/domains", From 4c8cd5b6c6ca1ddf19c47f1819aa4df0a7e00c79 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 19 Aug 2024 14:52:15 +1200 Subject: [PATCH 010/144] Update audit, abuse, database --- app/controllers/api/projects.php | 2 +- app/controllers/shared/api.php | 2 +- app/http.php | 2 +- app/realtime.php | 2 +- composer.json | 6 ++-- composer.lock | 44 ++++++++++++----------- src/Appwrite/Platform/Workers/Deletes.php | 2 +- 7 files changed, 31 insertions(+), 29 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 78690542a1..9c02790e0f 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -14,7 +14,7 @@ use Appwrite\Utopia\Database\Validator\Queries\Projects; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; use PHPMailer\PHPMailer\PHPMailer; -use Utopia\Abuse\Adapters\TimeLimit; +use Utopia\Abuse\Adapters\Database\TimeLimit; use Utopia\App; use Utopia\Audit\Audit; use Utopia\Cache\Cache; diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 2b0013db29..b2f41bbaee 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -16,7 +16,7 @@ use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; use Utopia\Abuse\Abuse; -use Utopia\Abuse\Adapters\TimeLimit; +use Utopia\Abuse\Adapters\Database\TimeLimit; use Utopia\App; use Utopia\Cache\Adapter\Filesystem; use Utopia\Cache\Cache; diff --git a/app/http.php b/app/http.php index a06563ceae..345a41a3b0 100644 --- a/app/http.php +++ b/app/http.php @@ -9,7 +9,7 @@ use Swoole\Http\Request as SwooleRequest; use Swoole\Http\Response as SwooleResponse; use Swoole\Http\Server; use Swoole\Process; -use Utopia\Abuse\Adapters\TimeLimit; +use Utopia\Abuse\Adapters\Database\TimeLimit; use Utopia\App; use Utopia\Audit\Audit; use Utopia\CLI\Console; diff --git a/app/realtime.php b/app/realtime.php index 9c3c2b4d6a..b8fdb2cf21 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -13,7 +13,7 @@ use Swoole\Runtime; use Swoole\Table; use Swoole\Timer; use Utopia\Abuse\Abuse; -use Utopia\Abuse\Adapters\TimeLimit; +use Utopia\Abuse\Adapters\Database\TimeLimit; use Utopia\App; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; diff --git a/composer.json b/composer.json index d90fe2fae7..2bc993a86a 100644 --- a/composer.json +++ b/composer.json @@ -44,13 +44,13 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.13.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "0.38.*", + "utopia-php/abuse": "0.41.*", "utopia-php/analytics": "0.10.*", - "utopia-php/audit": "0.40.*", + "utopia-php/audit": "0.41.*", "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-migrations as 0.50.4", + "utopia-php/database": "dev-feat-migrations as 0.51.1", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index fc3c30e7f7..bd5b732bbc 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": "9f0148c3d90031407444e496f05c52ab", + "content-hash": "c7f621c0e56130f48703ba54364e4763", "packages": [ { "name": "adhocore/jwt", @@ -1428,26 +1428,28 @@ }, { "name": "utopia-php/abuse", - "version": "0.38.0", + "version": "0.41.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "b7be9086c9d9b4561d810cbd42fdda798742f56c" + "reference": "961019add0edc30c11b78ca74ce7ca7c9715b513" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/b7be9086c9d9b4561d810cbd42fdda798742f56c", - "reference": "b7be9086c9d9b4561d810cbd42fdda798742f56c", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/961019add0edc30c11b78ca74ce7ca7c9715b513", + "reference": "961019add0edc30c11b78ca74ce7ca7c9715b513", "shasum": "" }, "require": { "ext-curl": "*", "ext-pdo": "*", + "ext-redis": "*", "php": ">=8.0", - "utopia-php/database": "0.50.*" + "utopia-php/database": "0.51.*" }, "require-dev": { "laravel/pint": "1.5.*", + "phpbench/phpbench": "^1.2", "phpstan/phpstan": "^1.9", "phpunit/phpunit": "^9.4" }, @@ -1471,9 +1473,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.38.0" + "source": "https://github.com/utopia-php/abuse/tree/0.41.0" }, - "time": "2024-06-24T00:52:02+00:00" + "time": "2024-08-19T02:47:45+00:00" }, { "name": "utopia-php/analytics", @@ -1523,21 +1525,21 @@ }, { "name": "utopia-php/audit", - "version": "0.40.0", + "version": "0.41.0", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "735ae211ce5fee5b52b736731571b4030b1d7cdc" + "reference": "77f1d0a95ea791e38a38a8bc1b7728ffcedcd2d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/735ae211ce5fee5b52b736731571b4030b1d7cdc", - "reference": "735ae211ce5fee5b52b736731571b4030b1d7cdc", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/77f1d0a95ea791e38a38a8bc1b7728ffcedcd2d1", + "reference": "77f1d0a95ea791e38a38a8bc1b7728ffcedcd2d1", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "0.50.*" + "utopia-php/database": "0.51.*" }, "require-dev": { "laravel/pint": "1.5.*", @@ -1564,9 +1566,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.40.0" + "source": "https://github.com/utopia-php/audit/tree/0.41.0" }, - "time": "2024-06-24T00:52:17+00:00" + "time": "2024-08-16T06:08:00+00:00" }, { "name": "utopia-php/cache", @@ -1724,12 +1726,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "09da873eec2aff442a6201b74c9ddc2bee566cd7" + "reference": "ddf94c9928fed48f251722d7594c62fe1fdf664a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/09da873eec2aff442a6201b74c9ddc2bee566cd7", - "reference": "09da873eec2aff442a6201b74c9ddc2bee566cd7", + "url": "https://api.github.com/repos/utopia-php/database/zipball/ddf94c9928fed48f251722d7594c62fe1fdf664a", + "reference": "ddf94c9928fed48f251722d7594c62fe1fdf664a", "shasum": "" }, "require": { @@ -1772,7 +1774,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-08-13T10:00:28+00:00" + "time": "2024-08-19T02:27:52+00:00" }, { "name": "utopia-php/domains", @@ -5595,8 +5597,8 @@ { "package": "utopia-php/database", "version": "dev-feat-migrations", - "alias": "0.50.4", - "alias_normalized": "0.50.4.0" + "alias": "0.51.1", + "alias_normalized": "0.51.1.0" } ], "minimum-stability": "stable", diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index d54f3f5079..afd083126c 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -7,7 +7,7 @@ use Appwrite\Extend\Exception; use Executor\Executor; use Throwable; use Utopia\Abuse\Abuse; -use Utopia\Abuse\Adapters\TimeLimit; +use Utopia\Abuse\Adapters\Database\TimeLimit; use Utopia\Audit\Audit; use Utopia\Cache\Adapter\Filesystem; use Utopia\Cache\Cache; From b98bcdd4a177a18852e3a6a6d1bb151d90a2af2f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 19 Aug 2024 18:27:45 +1200 Subject: [PATCH 011/144] Update database --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index bd5b732bbc..47b29b556f 100644 --- a/composer.lock +++ b/composer.lock @@ -1726,12 +1726,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "ddf94c9928fed48f251722d7594c62fe1fdf664a" + "reference": "ab549c157bbfadbfad0ab1144fd0ea3953f30170" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/ddf94c9928fed48f251722d7594c62fe1fdf664a", - "reference": "ddf94c9928fed48f251722d7594c62fe1fdf664a", + "url": "https://api.github.com/repos/utopia-php/database/zipball/ab549c157bbfadbfad0ab1144fd0ea3953f30170", + "reference": "ab549c157bbfadbfad0ab1144fd0ea3953f30170", "shasum": "" }, "require": { @@ -1774,7 +1774,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-08-19T02:27:52+00:00" + "time": "2024-08-19T06:26:02+00:00" }, { "name": "utopia-php/domains", From 1eafbf2ee2ca0bb590fe0efa4d23395a55bf38d1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 19 Aug 2024 21:21:20 +1200 Subject: [PATCH 012/144] Update database --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 47b29b556f..4fa8292230 100644 --- a/composer.lock +++ b/composer.lock @@ -1726,12 +1726,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "ab549c157bbfadbfad0ab1144fd0ea3953f30170" + "reference": "bad0ea537637fff0546287c92e4a3242cd129b8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/ab549c157bbfadbfad0ab1144fd0ea3953f30170", - "reference": "ab549c157bbfadbfad0ab1144fd0ea3953f30170", + "url": "https://api.github.com/repos/utopia-php/database/zipball/bad0ea537637fff0546287c92e4a3242cd129b8d", + "reference": "bad0ea537637fff0546287c92e4a3242cd129b8d", "shasum": "" }, "require": { @@ -1774,7 +1774,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-08-19T06:26:02+00:00" + "time": "2024-08-19T09:05:54+00:00" }, { "name": "utopia-php/domains", From c18308c024d682a4e4eff903c24050fb9aa9af2d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 27 Aug 2024 17:43:29 +1200 Subject: [PATCH 013/144] Update database --- composer.json | 6 ++-- composer.lock | 34 ++++++++++----------- src/Appwrite/Utopia/Response/Model/Func.php | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 2bc993a86a..b2b6bc1b0d 100644 --- a/composer.json +++ b/composer.json @@ -44,13 +44,13 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.13.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "0.41.*", + "utopia-php/abuse": "0.42.*", "utopia-php/analytics": "0.10.*", - "utopia-php/audit": "0.41.*", + "utopia-php/audit": "0.42.*", "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-migrations as 0.51.1", + "utopia-php/database": "dev-feat-migrations as 0.52.1", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 4fa8292230..d661277744 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": "c7f621c0e56130f48703ba54364e4763", + "content-hash": "b88b030917436a58130e8cc96bcdb8c5", "packages": [ { "name": "adhocore/jwt", @@ -1428,16 +1428,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.41.0", + "version": "0.42.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "961019add0edc30c11b78ca74ce7ca7c9715b513" + "reference": "08cf17e7f4fd213966c8d8702e406f2269244f0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/961019add0edc30c11b78ca74ce7ca7c9715b513", - "reference": "961019add0edc30c11b78ca74ce7ca7c9715b513", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/08cf17e7f4fd213966c8d8702e406f2269244f0f", + "reference": "08cf17e7f4fd213966c8d8702e406f2269244f0f", "shasum": "" }, "require": { @@ -1445,7 +1445,7 @@ "ext-pdo": "*", "ext-redis": "*", "php": ">=8.0", - "utopia-php/database": "0.51.*" + "utopia-php/database": "0.52.*" }, "require-dev": { "laravel/pint": "1.5.*", @@ -1473,9 +1473,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.41.0" + "source": "https://github.com/utopia-php/abuse/tree/0.42.0" }, - "time": "2024-08-19T02:47:45+00:00" + "time": "2024-08-21T08:24:01+00:00" }, { "name": "utopia-php/analytics", @@ -1525,21 +1525,21 @@ }, { "name": "utopia-php/audit", - "version": "0.41.0", + "version": "0.42.0", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "77f1d0a95ea791e38a38a8bc1b7728ffcedcd2d1" + "reference": "9dc168470625bcf11ff8cd9ab5660db09129f618" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/77f1d0a95ea791e38a38a8bc1b7728ffcedcd2d1", - "reference": "77f1d0a95ea791e38a38a8bc1b7728ffcedcd2d1", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/9dc168470625bcf11ff8cd9ab5660db09129f618", + "reference": "9dc168470625bcf11ff8cd9ab5660db09129f618", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "0.51.*" + "utopia-php/database": "0.52.*" }, "require-dev": { "laravel/pint": "1.5.*", @@ -1566,9 +1566,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.41.0" + "source": "https://github.com/utopia-php/audit/tree/0.42.0" }, - "time": "2024-08-16T06:08:00+00:00" + "time": "2024-08-21T08:24:08+00:00" }, { "name": "utopia-php/cache", @@ -5597,8 +5597,8 @@ { "package": "utopia-php/database", "version": "dev-feat-migrations", - "alias": "0.51.1", - "alias_normalized": "0.51.1.0" + "alias": "0.52.1", + "alias_normalized": "0.52.1.0" } ], "minimum-stability": "stable", diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index 0c8d4d42d2..eb15536ad3 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -87,7 +87,7 @@ class Func extends Model ]) ->addRule('schedule', [ 'type' => self::TYPE_STRING, - 'description' => 'Function execution schedult in CRON format.', + 'description' => 'Function execution schedule in CRON format.', 'default' => '', 'example' => '5 4 * * *', ]) From 28642b9f0412e51f46a3b7a588b3c26ee62cd289 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Sep 2024 17:06:16 +1200 Subject: [PATCH 014/144] Shared tables array --- app/cli.php | 7 ++++--- app/controllers/api/projects.php | 9 ++++++--- app/init.php | 10 ++++++++-- app/realtime.php | 4 +++- app/worker.php | 12 +++++++++--- src/Appwrite/Platform/Workers/Deletes.php | 7 ++++--- 6 files changed, 34 insertions(+), 15 deletions(-) diff --git a/app/cli.php b/app/cli.php index 9a022eaacc..7700e8f03c 100644 --- a/app/cli.php +++ b/app/cli.php @@ -108,8 +108,9 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, if (isset($databases[$dsn->getHost()])) { $database = $databases[$dsn->getHost()]; + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + if (\in_array($dsn->getHost(), $sharedTables)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) @@ -130,10 +131,10 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, ->getResource(); $database = new Database($dbAdapter, $cache); - $databases[$dsn->getHost()] = $database; + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + if (\in_array($dsn->getHost(), $sharedTables)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 9c02790e0f..282459027b 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -127,11 +127,13 @@ App::post('/v1/projects') } // TODO: Temporary until all projects are using shared tables. - if ($dsn === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn, $sharedTables)) { $schema = 'appwrite'; $database = 'appwrite'; $namespace = System::getEnv('_APP_DATABASE_SHARED_NAMESPACE', ''); - $dsn = $schema . '://' . System::getEnv('_APP_DATABASE_SHARED_TABLES', '') . '?database=' . $database; + $dsn = $schema . '://' . $dsn . '?database=' . $database; if (!empty($namespace)) { $dsn .= '&namespace=' . $namespace; @@ -184,8 +186,9 @@ App::post('/v1/projects') $adapter = $pools->get($dsn->getHost())->pop()->getResource(); $dbForProject = new Database($adapter, $cache); + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject ->setSharedTables(true) ->setTenant(null) diff --git a/app/init.php b/app/init.php index 3b43d98895..a8e5f0ef62 100644 --- a/app/init.php +++ b/app/init.php @@ -248,6 +248,8 @@ const METRIC_NETWORK_REQUESTS = 'network.requests'; const METRIC_NETWORK_INBOUND = 'network.inbound'; const METRIC_NETWORK_OUTBOUND = 'network.outbound'; +const METRIC_MESSAGES = 'messages'; + $register = new Registry(); App::setMode(System::getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION)); @@ -1339,7 +1341,9 @@ App::setResource('dbForProject', function (Group $pools, Database $dbForConsole, $dsn = new DSN('mysql://' . $project->getAttribute('database')); } - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) @@ -1392,7 +1396,9 @@ App::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, ->setMetadata('project', $project->getId()) ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS); - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) diff --git a/app/realtime.php b/app/realtime.php index b8fdb2cf21..71a087b652 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -92,7 +92,9 @@ if (!function_exists("getProjectDB")) { $database = new Database($adapter, getCache()); - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) diff --git a/app/worker.php b/app/worker.php index 9bcdae78e6..3761162f9e 100644 --- a/app/worker.php +++ b/app/worker.php @@ -93,7 +93,9 @@ Server::setResource('dbForProject', function (Cache $cache, Registry $register, $dsn = new DSN('mysql://' . $project->getAttribute('database')); } - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) @@ -126,7 +128,9 @@ Server::setResource('getProjectDB', function (Group $pools, Database $dbForConso if (isset($databases[$dsn->getHost()])) { $database = $databases[$dsn->getHost()]; - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) @@ -150,7 +154,9 @@ Server::setResource('getProjectDB', function (Group $pools, Database $dbForConso $databases[$dsn->getHost()] = $database; - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index afd083126c..0ff1a69b1d 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -493,19 +493,20 @@ class Deletes extends Action ]; $limit = \count($projectCollectionIds) + 25; + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); while (true) { $collections = $dbForProject->listCollections($limit); foreach ($collections as $collection) { - if ($dsn->getHost() !== System::getEnv('_APP_DATABASE_SHARED_TABLES', '') || !\in_array($collection->getId(), $projectCollectionIds)) { + if (\in_array($dsn->getHost(), $sharedTables) || !\in_array($collection->getId(), $projectCollectionIds)) { $dbForProject->deleteCollection($collection->getId()); } else { $this->deleteByGroup($collection->getId(), [], database: $dbForProject); } } - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + if (\in_array($dsn->getHost(), $sharedTables)) { $collectionsIds = \array_map(fn ($collection) => $collection->getId(), $collections); if (empty(\array_diff($collectionsIds, $projectCollectionIds))) { @@ -554,7 +555,7 @@ class Deletes extends Action ], $dbForConsole); // Delete metadata table - if ($dsn->getHost() !== System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject->deleteCollection('_metadata'); } else { $this->deleteByGroup('_metadata', [], $dbForProject); From ee7de0cb415a0ed790c2897ef3c4c309dbd4b633 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Sep 2024 23:02:12 +1200 Subject: [PATCH 015/144] Update database --- composer.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/composer.lock b/composer.lock index d661277744..c1faf7d853 100644 --- a/composer.lock +++ b/composer.lock @@ -1726,12 +1726,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "bad0ea537637fff0546287c92e4a3242cd129b8d" + "reference": "32ab2f79315906053586513a3e8f994cb8f783e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/bad0ea537637fff0546287c92e4a3242cd129b8d", - "reference": "bad0ea537637fff0546287c92e4a3242cd129b8d", + "url": "https://api.github.com/repos/utopia-php/database/zipball/32ab2f79315906053586513a3e8f994cb8f783e5", + "reference": "32ab2f79315906053586513a3e8f994cb8f783e5", "shasum": "" }, "require": { @@ -1743,14 +1743,14 @@ "utopia-php/mongo": "0.3.*" }, "require-dev": { - "fakerphp/faker": "^1.14", - "laravel/pint": "1.13.*", - "pcov/clobber": "^2.0", - "phpstan/phpstan": "1.10.*", - "phpunit/phpunit": "^9.4", - "rregeer/phpunit-coverage-check": "^0.3.1", - "swoole/ide-helper": "5.1.2", - "utopia-php/cli": "^0.14.0" + "fakerphp/faker": "1.23.*", + "laravel/pint": "1.17.*", + "pcov/clobber": "2.0.*", + "phpstan/phpstan": "1.11.*", + "phpunit/phpunit": "9.6.*", + "rregeer/phpunit-coverage-check": "0.3.*", + "swoole/ide-helper": "5.1.3", + "utopia-php/cli": "0.14.*" }, "type": "library", "autoload": { @@ -1774,7 +1774,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-08-19T09:05:54+00:00" + "time": "2024-09-12T11:01:10+00:00" }, { "name": "utopia-php/domains", From 25d44b5b4c3f6a9a868e10a226947565de9e7868 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Sep 2024 23:04:44 +1200 Subject: [PATCH 016/144] Update generator --- composer.json | 2 +- composer.lock | 348 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 250 insertions(+), 100 deletions(-) diff --git a/composer.json b/composer.json index b2b6bc1b0d..24b0c0f5cc 100644 --- a/composer.json +++ b/composer.json @@ -82,7 +82,7 @@ }, "require-dev": { "ext-fileinfo": "*", - "appwrite/sdk-generator": "0.38.*", + "appwrite/sdk-generator": "0.39.*", "phpunit/phpunit": "9.5.20", "swoole/ide-helper": "5.1.2", "textalk/websocket": "1.5.7", diff --git a/composer.lock b/composer.lock index c1faf7d853..e310a39810 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": "b88b030917436a58130e8cc96bcdb8c5", + "content-hash": "e7d892934103b23bcd8183d6df297366", "packages": [ { "name": "adhocore/jwt", @@ -1129,20 +1129,20 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-mbstring": "*" @@ -1189,7 +1189,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" }, "funding": [ { @@ -1205,24 +1205,24 @@ "type": "tidelift" } ], - "time": "2024-06-19T12:30:46+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "type": "library", "extra": { @@ -1269,7 +1269,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" }, "funding": [ { @@ -1285,7 +1285,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "thecodingmachine/safe", @@ -1924,16 +1924,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.7", + "version": "0.33.8", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "78d293d99a262bd63ece750bbf989c7e0643b825" + "reference": "a7f577540a25cb90896fef2b64767bf8d700f3c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/78d293d99a262bd63ece750bbf989c7e0643b825", - "reference": "78d293d99a262bd63ece750bbf989c7e0643b825", + "url": "https://api.github.com/repos/utopia-php/http/zipball/a7f577540a25cb90896fef2b64767bf8d700f3c5", + "reference": "a7f577540a25cb90896fef2b64767bf8d700f3c5", "shasum": "" }, "require": { @@ -1963,9 +1963,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.7" + "source": "https://github.com/utopia-php/http/tree/0.33.8" }, - "time": "2024-08-01T14:01:04+00:00" + "time": "2024-08-15T14:10:09+00:00" }, { "name": "utopia-php/image", @@ -2598,16 +2598,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.4", + "version": "0.18.5", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "94ab8758fabcefee5c5fa723616e45719833f922" + "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/94ab8758fabcefee5c5fa723616e45719833f922", - "reference": "94ab8758fabcefee5c5fa723616e45719833f922", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/7d355c5e3ccc8ecebc0266f8ddd30088a43be919", + "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919", "shasum": "" }, "require": { @@ -2647,9 +2647,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.4" + "source": "https://github.com/utopia-php/storage/tree/0.18.5" }, - "time": "2024-04-02T08:24:09+00:00" + "time": "2024-09-04T08:57:27+00:00" }, { "name": "utopia-php/swoole", @@ -2760,16 +2760,16 @@ }, { "name": "utopia-php/vcs", - "version": "0.8.1", + "version": "0.8.2", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "3084aa93d24ed1e70f01e75f4318fc0d07f12596" + "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/3084aa93d24ed1e70f01e75f4318fc0d07f12596", - "reference": "3084aa93d24ed1e70f01e75f4318fc0d07f12596", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", + "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", "shasum": "" }, "require": { @@ -2803,9 +2803,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.8.1" + "source": "https://github.com/utopia-php/vcs/tree/0.8.2" }, - "time": "2024-07-29T20:49:09+00:00" + "time": "2024-08-13T14:36:30+00:00" }, { "name": "utopia-php/websocket", @@ -2992,16 +2992,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.38.8", + "version": "0.39.21", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "6367c57ddbcf7b88cacb900c4fe7ef3f28bf38ef" + "reference": "9754b190d33aaad56fdb8defc94f90248184c5ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/6367c57ddbcf7b88cacb900c4fe7ef3f28bf38ef", - "reference": "6367c57ddbcf7b88cacb900c4fe7ef3f28bf38ef", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/9754b190d33aaad56fdb8defc94f90248184c5ac", + "reference": "9754b190d33aaad56fdb8defc94f90248184c5ac", "shasum": "" }, "require": { @@ -3010,12 +3010,12 @@ "ext-mbstring": "*", "matthiasmullie/minify": "1.3.*", "php": ">=8.0", - "twig/twig": "v3.8.*" + "twig/twig": "3.14.*" }, "require-dev": { - "brianium/paratest": "v7.4.*", - "phpunit/phpunit": "10.5.*", - "squizlabs/php_codesniffer": "3.9.*" + "brianium/paratest": "7.*", + "phpunit/phpunit": "11.*", + "squizlabs/php_codesniffer": "3.*" }, "type": "library", "autoload": { @@ -3037,9 +3037,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.8" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.21" }, - "time": "2024-06-17T00:42:27+00:00" + "time": "2024-09-10T08:49:29+00:00" }, { "name": "doctrine/deprecations", @@ -3160,16 +3160,16 @@ }, { "name": "laravel/pint", - "version": "v1.17.1", + "version": "v1.17.3", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "b5b6f716db298671c1dfea5b1082ec2c0ae7064f" + "reference": "9d77be916e145864f10788bb94531d03e1f7b482" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/b5b6f716db298671c1dfea5b1082ec2c0ae7064f", - "reference": "b5b6f716db298671c1dfea5b1082ec2c0ae7064f", + "url": "https://api.github.com/repos/laravel/pint/zipball/9d77be916e145864f10788bb94531d03e1f7b482", + "reference": "9d77be916e145864f10788bb94531d03e1f7b482", "shasum": "" }, "require": { @@ -3180,13 +3180,13 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.59.3", - "illuminate/view": "^10.48.12", - "larastan/larastan": "^2.9.7", + "friendsofphp/php-cs-fixer": "^3.64.0", + "illuminate/view": "^10.48.20", + "larastan/larastan": "^2.9.8", "laravel-zero/framework": "^10.4.0", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^1.15.1", - "pestphp/pest": "^2.34.8" + "pestphp/pest": "^2.35.1" }, "bin": [ "builds/pint" @@ -3222,7 +3222,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-08-01T09:06:33+00:00" + "time": "2024-09-03T15:00:28+00:00" }, { "name": "matthiasmullie/minify", @@ -3830,16 +3830,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.29.1", + "version": "1.30.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4" + "reference": "51b95ec8670af41009e2b2b56873bad96682413e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/51b95ec8670af41009e2b2b56873bad96682413e", + "reference": "51b95ec8670af41009e2b2b56873bad96682413e", "shasum": "" }, "require": { @@ -3871,41 +3871,41 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.1" }, - "time": "2024-05-31T08:52:43+00:00" + "time": "2024-09-07T20:13:05+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.31", + "version": "9.2.32", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.18 || ^5.0", + "nikic/php-parser": "^4.19.1 || ^5.1.0", "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.6" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -3914,7 +3914,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "9.2.x-dev" } }, "autoload": { @@ -3943,7 +3943,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" }, "funding": [ { @@ -3951,7 +3951,7 @@ "type": "github" } ], - "time": "2024-03-02T06:37:42+00:00" + "time": "2024-08-22T04:23:01+00:00" }, { "name": "phpunit/php-file-iterator", @@ -4299,16 +4299,16 @@ }, { "name": "psr/log", - "version": "3.0.0", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", - "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", "shasum": "" }, "require": { @@ -4343,9 +4343,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/3.0.0" + "source": "https://github.com/php-fig/log/tree/3.0.2" }, - "time": "2021-07-14T16:46:02+00:00" + "time": "2024-09-11T13:17:53+00:00" }, { "name": "sebastian/cli-parser", @@ -5343,21 +5343,88 @@ "time": "2024-02-01T22:28:11+00:00" }, { - "name": "symfony/polyfill-ctype", - "version": "v1.30.0", + "name": "symfony/deprecation-contracts", + "version": "v3.5.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", + "shasum": "" + }, + "require": { + "php": ">=7.2" }, "provide": { "ext-ctype": "*" @@ -5403,7 +5470,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" }, "funding": [ { @@ -5419,7 +5486,83 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" }, { "name": "textalk/websocket", @@ -5522,30 +5665,37 @@ }, { "name": "twig/twig", - "version": "v3.8.0", + "version": "v3.14.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d" + "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", - "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72", + "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php80": "^1.22" + "symfony/polyfill-php81": "^1.29" }, "require-dev": { "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.3|^7.0" + "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" }, "type": "library", "autoload": { + "files": [ + "src/Resources/core.php", + "src/Resources/debug.php", + "src/Resources/escaper.php", + "src/Resources/string_loader.php" + ], "psr-4": { "Twig\\": "src/" } @@ -5578,7 +5728,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.8.0" + "source": "https://github.com/twigphp/Twig/tree/v3.14.0" }, "funding": [ { @@ -5590,7 +5740,7 @@ "type": "tidelift" } ], - "time": "2023-11-21T18:54:41+00:00" + "time": "2024-09-09T17:55:12+00:00" } ], "aliases": [ From d18a67e6d8ec3bd17fe43fc2e8011819e358f4d1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Sep 2024 23:06:47 +1200 Subject: [PATCH 017/144] Update packages --- composer.json | 6 +++--- composer.lock | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 24b0c0f5cc..6ced6dbb99 100644 --- a/composer.json +++ b/composer.json @@ -44,13 +44,13 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.13.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "0.42.*", + "utopia-php/abuse": "0.43.*", "utopia-php/analytics": "0.10.*", - "utopia-php/audit": "0.42.*", + "utopia-php/audit": "0.43.*", "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-migrations as 0.52.1", + "utopia-php/database": "dev-feat-migrations as 0.53.4", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index e310a39810..a591ce890e 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": "e7d892934103b23bcd8183d6df297366", + "content-hash": "a6b8178b7dd891ad65cd7a89bdf61fff", "packages": [ { "name": "adhocore/jwt", @@ -1428,16 +1428,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.42.0", + "version": "0.43.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "08cf17e7f4fd213966c8d8702e406f2269244f0f" + "reference": "6346a3b4c5177a43160035a7289e30fdfb0790d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/08cf17e7f4fd213966c8d8702e406f2269244f0f", - "reference": "08cf17e7f4fd213966c8d8702e406f2269244f0f", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/6346a3b4c5177a43160035a7289e30fdfb0790d6", + "reference": "6346a3b4c5177a43160035a7289e30fdfb0790d6", "shasum": "" }, "require": { @@ -1445,7 +1445,7 @@ "ext-pdo": "*", "ext-redis": "*", "php": ">=8.0", - "utopia-php/database": "0.52.*" + "utopia-php/database": "0.53.*" }, "require-dev": { "laravel/pint": "1.5.*", @@ -1473,9 +1473,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.42.0" + "source": "https://github.com/utopia-php/abuse/tree/0.43.0" }, - "time": "2024-08-21T08:24:01+00:00" + "time": "2024-08-30T05:17:23+00:00" }, { "name": "utopia-php/analytics", @@ -1525,21 +1525,21 @@ }, { "name": "utopia-php/audit", - "version": "0.42.0", + "version": "0.43.0", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "9dc168470625bcf11ff8cd9ab5660db09129f618" + "reference": "cef22b5dc6a6d28fcd522f41c7bf7ded4a4dfd3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/9dc168470625bcf11ff8cd9ab5660db09129f618", - "reference": "9dc168470625bcf11ff8cd9ab5660db09129f618", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/cef22b5dc6a6d28fcd522f41c7bf7ded4a4dfd3e", + "reference": "cef22b5dc6a6d28fcd522f41c7bf7ded4a4dfd3e", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "0.52.*" + "utopia-php/database": "0.53.*" }, "require-dev": { "laravel/pint": "1.5.*", @@ -1566,9 +1566,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.42.0" + "source": "https://github.com/utopia-php/audit/tree/0.43.0" }, - "time": "2024-08-21T08:24:08+00:00" + "time": "2024-08-30T05:17:36+00:00" }, { "name": "utopia-php/cache", @@ -5747,8 +5747,8 @@ { "package": "utopia-php/database", "version": "dev-feat-migrations", - "alias": "0.52.1", - "alias_normalized": "0.52.1.0" + "alias": "0.53.4", + "alias_normalized": "0.53.4.0" } ], "minimum-stability": "stable", From bee844fcdb54d4f37d5259d0317d3b80d63111e5 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 15 Sep 2024 17:40:55 +0200 Subject: [PATCH 018/144] sync against 1.6x --- app/cli.php | 8 +- app/config/bla | 36 +++ app/console | 1 + app/controllers/api/functions.php | 5 +- app/controllers/api/projects.php | 17 +- app/controllers/shared/api.php | 4 +- app/init.php | 48 ++-- app/realtime.php | 16 +- app/worker.php | 41 +-- composer.lock | 235 ++++++++++++------ src/Appwrite/Event/Build.php | 1 + src/Appwrite/Event/Certificate.php | 1 + src/Appwrite/Event/Database.php | 1 + src/Appwrite/Event/Event.php | 7 + src/Appwrite/Event/Migration.php | 2 + src/Appwrite/Messaging/Adapter.php | 4 +- src/Appwrite/Messaging/Adapter/Realtime.php | 8 +- src/Appwrite/Platform/Workers/Builds.php | 24 +- .../Platform/Workers/Certificates.php | 46 ++-- src/Appwrite/Platform/Workers/Databases.php | 72 ++++-- src/Appwrite/Platform/Workers/Deletes.php | 10 +- src/Appwrite/Platform/Workers/Functions.php | 19 +- src/Appwrite/Platform/Workers/Migrations.php | 31 ++- 23 files changed, 448 insertions(+), 189 deletions(-) create mode 100644 app/config/bla create mode 160000 app/console diff --git a/app/cli.php b/app/cli.php index 9a022eaacc..0dec8bad04 100644 --- a/app/cli.php +++ b/app/cli.php @@ -109,8 +109,8 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, if (isset($databases[$dsn->getHost()])) { $database = $databases[$dsn->getHost()]; - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { - $database + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -133,8 +133,8 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, $databases[$dsn->getHost()] = $database; - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { - $database + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); diff --git a/app/config/bla b/app/config/bla new file mode 100644 index 0000000000..37b151a403 --- /dev/null +++ b/app/config/bla @@ -0,0 +1,36 @@ +version: '3.8' + +services: + db_15: + image: mysql:8.0.36-debian + container_name: mysql_db_15 + environment: + MYSQL_ROOT_PASSWORD: lJVYGNZTOTF4VsGSnz5CWoVp + MYSQL_DATABASE: appwrite + MYSQL_USER: appwrite_user + MYSQL_PASSWORD: Fy8i367HpJd8EB1VGos3vsf + volumes: + - /mnt/db-15:/var/lib/mysql + ports: + - "3307:3306" + networks: + - mysql_network + + db_16: + image: mysql:8.0.36-debian + container_name: mysql_db_16 + environment: + MYSQL_ROOT_PASSWORD: d1RNc7NsnsQ8I1OQd0eeLWr0 + MYSQL_DATABASE: appwrite + MYSQL_USER: appwrite_user + MYSQL_PASSWORD: KlQ4NMyl46YPumqSA8CUOLjO + volumes: + - /mnt/db-16:/var/lib/mysql + ports: + - "3308:3306" + networks: + - mysql_network + +networks: + mysql_network: + driver: bridge \ No newline at end of file diff --git a/app/console b/app/console new file mode 160000 index 0000000000..0959b594b3 --- /dev/null +++ b/app/console @@ -0,0 +1 @@ +Subproject commit 0959b594b32f176819d4afb3a769afea212db789 diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 7c6d89c7f0..6a5e12f4fd 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -183,7 +183,8 @@ App::post('/v1/functions') ->inject('queueForBuilds') ->inject('dbForConsole') ->inject('gitHub') - ->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) use ($redeployVcs) { + ->inject('realtimeConnection') + ->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $githubgithub, Callable $realtimeConnection) use ($redeployVcs) { $functionId = ($functionId == 'unique()') ? ID::unique() : $functionId; $allowList = \array_filter(\explode(',', System::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); @@ -374,6 +375,7 @@ App::post('/v1/functions') project: $project ); Realtime::send( + redis: $realtimeConnection($queueForEvents->getSourceRegion()), projectId: 'console', payload: $rule->getArrayCopy(), events: $allEvents, @@ -381,6 +383,7 @@ App::post('/v1/functions') roles: $target['roles'] ); Realtime::send( + redis: $realtimeConnection($queueForEvents->getSourceRegion()), projectId: $project->getId(), payload: $rule->getArrayCopy(), events: $allEvents, diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 3a8c232195..0c640255f8 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -125,6 +125,13 @@ App::post('/v1/projects') if ($index !== false) { $dsn = $databases[$index]; } else { + + if ($region !== 'default') { + $databases = array_filter($databases, function ($value) use ($region) { + return str_contains($value, $region); + }); + } + $dsn = $databases[array_rand($databases)]; } @@ -133,11 +140,13 @@ App::post('/v1/projects') } // TODO: Temporary until all projects are using shared tables. - if ($dsn === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn, $sharedTablesKeys)) { + $schema = 'appwrite'; $database = 'appwrite'; $namespace = System::getEnv('_APP_DATABASE_SHARED_NAMESPACE', ''); - $dsn = $schema . '://' . System::getEnv('_APP_DATABASE_SHARED_TABLES', '') . '?database=' . $database; + $dsn = $schema . '://' . $dsn . '?database=' . $database; if (!empty($namespace)) { $dsn .= '&namespace=' . $namespace; @@ -192,8 +201,8 @@ App::post('/v1/projects') $adapter = $pools->get($dsn->getHost())->pop()->getResource(); $dbForProject = new Database($adapter, $cache); - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { - $dbForProject + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $dbForProject ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 0cb88d31fa..792cb15138 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -590,7 +590,8 @@ App::shutdown() ->inject('queueForFunctions') ->inject('mode') ->inject('dbForConsole') - ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole) use ($parseLabel) { + ->inject('realtimeConnection') + ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole, callable $realtimeConnection) use ($parseLabel) { $responsePayload = $response->getPayload(); @@ -636,6 +637,7 @@ App::shutdown() ); Realtime::send( + redis: $realtimeConnection($queueForEvents->getSourceRegion()), projectId: $target['projectId'] ?? $project->getId(), payload: $queueForEvents->getRealtimePayload(), events: $allEvents, diff --git a/app/init.php b/app/init.php index 9540de57de..b6c73f9919 100644 --- a/app/init.php +++ b/app/init.php @@ -89,6 +89,10 @@ use Utopia\Validator\Range; use Utopia\Validator\URL; use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub as VcsGitHub; +use Appwrite\Messaging\Adapter\Realtime; +use Appwrite\Utopia\Request; + + const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; @@ -1390,8 +1394,8 @@ App::setResource('dbForProject', function (Group $pools, Database $dbForConsole, $dsn = new DSN('mysql://' . $project->getAttribute('database')); } - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { - $database + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -1443,8 +1447,8 @@ App::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, ->setMetadata('project', $project->getId()) ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS); - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { - $database + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -1494,23 +1498,33 @@ App::setResource('deviceForLocal', function () { return new Local(); }); -App::setResource('deviceForFiles', function ($project) { - return getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); -}, ['project']); +App::setResource('deviceForFiles', function ($project, $connectionString) { + return getDevice(APP_STORAGE_UPLOADS.'/app-'.$project->getId(), $connectionString); +}, ['project', 'connectionString']); -App::setResource('deviceForFunctions', function ($project) { - return getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()); -}, ['project']); +App::setResource('deviceForFunctions', function ($project, $connectionString) { + return getDevice(APP_STORAGE_FUNCTIONS.'/app-'.$project->getId(), $connectionString); +}, ['project', 'connectionString']); -App::setResource('deviceForBuilds', function ($project) { - return getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()); -}, ['project']); +App::setResource('deviceForBuilds', function ($project, $connectionString) { + return getDevice(APP_STORAGE_BUILDS.'/app-'.$project->getId(), $connectionString); +}, ['project', 'connectionString']); -function getDevice($root): Device +App::setResource('connectionString', function () { + return System::getEnv('_APP_CONNECTIONS_STORAGE', ''); +}); + +App::setResource('realtimeConnection',function ($pools) { + return function () use ($pools) { + return $pools->get('pubsub')->pop()->getResource(); + }; +}, ['pools']); + + +function getDevice(string $root, string $connectionString = ''): Device { - $connection = System::getEnv('_APP_CONNECTIONS_STORAGE', ''); - if (!empty($connection)) { + if (! empty($connectionString)) { $acl = 'private'; $device = Storage::DEVICE_LOCAL; $accessKey = ''; @@ -1519,7 +1533,7 @@ function getDevice($root): Device $region = ''; try { - $dsn = new DSN($connection); + $dsn = new DSN($connectionString); $device = $dsn->getScheme(); $accessKey = $dsn->getUser() ?? ''; $accessSecret = $dsn->getPassword() ?? ''; diff --git a/app/realtime.php b/app/realtime.php index b8fdb2cf21..9499705e4d 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -92,8 +92,8 @@ if (!function_exists("getProjectDB")) { $database = new Database($adapter, getCache()); - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { - $database + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -135,6 +135,16 @@ if (!function_exists("getCache")) { } } +if (!function_exists("getPubSub")) { + function getPubSub(): \Redis + { + global $register; + + $pools = $register->get('pools'); /** @var \Utopia\Pools\Group $pools */ + return $pools->get('pubsub')->pop()->getResource(); + } +} + $realtime = new Realtime(); /** @@ -354,7 +364,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, } $start = time(); - $redis = $register->get('pools')->get('pubsub')->pop()->getResource(); /** @var Redis $redis */ + $redis = getPubSub(); /** @var \Redis $redis */ $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); if ($redis->ping(true)) { diff --git a/app/worker.php b/app/worker.php index 9bcdae78e6..7bd9b23832 100644 --- a/app/worker.php +++ b/app/worker.php @@ -93,8 +93,8 @@ Server::setResource('dbForProject', function (Cache $cache, Registry $register, $dsn = new DSN('mysql://' . $project->getAttribute('database')); } - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { - $database + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -126,8 +126,8 @@ Server::setResource('getProjectDB', function (Group $pools, Database $dbForConso if (isset($databases[$dsn->getHost()])) { $database = $databases[$dsn->getHost()]; - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { - $database + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -150,8 +150,8 @@ Server::setResource('getProjectDB', function (Group $pools, Database $dbForConso $databases[$dsn->getHost()] = $database; - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { - $database + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -256,22 +256,27 @@ Server::setResource('pools', function (Registry $register) { return $register->get('pools'); }, ['register']); -Server::setResource('deviceForFunctions', function (Document $project) { - return getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()); -}, ['project']); +Server::setResource('deviceForFunctions', function (Document $project, $connectionString) { + return getDevice(APP_STORAGE_FUNCTIONS.'/app-'.$project->getId(), $connectionString); +}, ['project', 'connectionString']); -Server::setResource('deviceForFiles', function (Document $project) { - return getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); -}, ['project']); +Server::setResource('deviceForFiles', function (Document $project, $connectionString) { + return getDevice(APP_STORAGE_UPLOADS.'/app-'.$project->getId(), $connectionString); +}, ['project', 'connectionString']); -Server::setResource('deviceForBuilds', function (Document $project) { - return getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()); -}, ['project']); +Server::setResource('deviceForBuilds', function (Document $project, $connectionString) { + return getDevice(APP_STORAGE_BUILDS.'/app-'.$project->getId(), $connectionString); +}, ['project', 'connectionString']); -Server::setResource('deviceForCache', function (Document $project) { - return getDevice(APP_STORAGE_CACHE . '/app-' . $project->getId()); -}, ['project']); +Server::setResource('deviceForCache', function (Document $project, $connectionString) { + return getDevice(APP_STORAGE_CACHE.'/app-'.$project->getId(), $connectionString); +}, ['project', 'connectionString']); +Server::setResource('realtimeConnection',function ($pools) { + return function () use ($pools) { + return $pools->get('pubsub')->pop()->getResource(); + }; +}, ['pools']); $pools = $register->get('pools'); $platform = new Appwrite(); diff --git a/composer.lock b/composer.lock index aac1554dbf..d717482314 100644 --- a/composer.lock +++ b/composer.lock @@ -1130,20 +1130,20 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-mbstring": "*" @@ -1190,7 +1190,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" }, "funding": [ { @@ -1206,24 +1206,24 @@ "type": "tidelift" } ], - "time": "2024-06-19T12:30:46+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "type": "library", "extra": { @@ -1270,7 +1270,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" }, "funding": [ { @@ -1286,7 +1286,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "thecodingmachine/safe", @@ -2993,16 +2993,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.19", + "version": "0.39.21", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "d5653a2f744d2c297d44f99ff68bfc26c1a3b804" + "reference": "9754b190d33aaad56fdb8defc94f90248184c5ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/d5653a2f744d2c297d44f99ff68bfc26c1a3b804", - "reference": "d5653a2f744d2c297d44f99ff68bfc26c1a3b804", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/9754b190d33aaad56fdb8defc94f90248184c5ac", + "reference": "9754b190d33aaad56fdb8defc94f90248184c5ac", "shasum": "" }, "require": { @@ -3011,12 +3011,12 @@ "ext-mbstring": "*", "matthiasmullie/minify": "1.3.*", "php": ">=8.0", - "twig/twig": "v3.8.*" + "twig/twig": "3.14.*" }, "require-dev": { - "brianium/paratest": "v7.4.*", - "phpunit/phpunit": "10.5.*", - "squizlabs/php_codesniffer": "3.9.*" + "brianium/paratest": "7.*", + "phpunit/phpunit": "11.*", + "squizlabs/php_codesniffer": "3.*" }, "type": "library", "autoload": { @@ -3038,22 +3038,22 @@ "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.39.19" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.21" }, - "time": "2024-08-30T12:04:18+00:00" + "time": "2024-09-10T08:49:29+00:00" }, { "name": "doctrine/annotations", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f" + "reference": "901c2ee5d26eb64ff43c47976e114bf00843acf7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f", - "reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/901c2ee5d26eb64ff43c47976e114bf00843acf7", + "reference": "901c2ee5d26eb64ff43c47976e114bf00843acf7", "shasum": "" }, "require": { @@ -3065,10 +3065,10 @@ "require-dev": { "doctrine/cache": "^2.0", "doctrine/coding-standard": "^10", - "phpstan/phpstan": "^1.8.0", + "phpstan/phpstan": "^1.10.28", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "symfony/cache": "^5.4 || ^6", - "vimeo/psalm": "^4.10" + "symfony/cache": "^5.4 || ^6.4 || ^7", + "vimeo/psalm": "^4.30 || ^5.14" }, "suggest": { "php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations" @@ -3114,9 +3114,9 @@ ], "support": { "issues": "https://github.com/doctrine/annotations/issues", - "source": "https://github.com/doctrine/annotations/tree/2.0.1" + "source": "https://github.com/doctrine/annotations/tree/2.0.2" }, - "time": "2023-02-02T22:02:53+00:00" + "time": "2024-09-05T10:17:24+00:00" }, { "name": "doctrine/deprecations", @@ -4185,16 +4185,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.30.0", + "version": "1.30.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "5ceb0e384997db59f38774bf79c2a6134252c08f" + "reference": "51b95ec8670af41009e2b2b56873bad96682413e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/5ceb0e384997db59f38774bf79c2a6134252c08f", - "reference": "5ceb0e384997db59f38774bf79c2a6134252c08f", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/51b95ec8670af41009e2b2b56873bad96682413e", + "reference": "51b95ec8670af41009e2b2b56873bad96682413e", "shasum": "" }, "require": { @@ -4226,9 +4226,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.1" }, - "time": "2024-08-29T09:54:52+00:00" + "time": "2024-09-07T20:13:05+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4756,16 +4756,16 @@ }, { "name": "psr/log", - "version": "3.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "79dff0b268932c640297f5208d6298f71855c03e" + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/79dff0b268932c640297f5208d6298f71855c03e", - "reference": "79dff0b268932c640297f5208d6298f71855c03e", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", "shasum": "" }, "require": { @@ -4800,9 +4800,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/3.0.1" + "source": "https://github.com/php-fig/log/tree/3.0.2" }, - "time": "2024-08-21T13:31:24+00:00" + "time": "2024-09-11T13:17:53+00:00" }, { "name": "sebastian/cli-parser", @@ -6222,20 +6222,20 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540" + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-ctype": "*" @@ -6281,7 +6281,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" }, "funding": [ { @@ -6297,24 +6297,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a" + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/64647a7c30b2283f5d49b874d84a18fc22054b7a", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -6359,7 +6359,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0" }, "funding": [ { @@ -6375,24 +6375,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb" + "reference": "3833d7255cc303546435cb650316bff708a1c75c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", + "reference": "3833d7255cc303546435cb650316bff708a1c75c", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -6440,7 +6440,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0" }, "funding": [ { @@ -6456,7 +6456,83 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/process", @@ -6790,30 +6866,37 @@ }, { "name": "twig/twig", - "version": "v3.8.0", + "version": "v3.14.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d" + "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", - "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72", + "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php80": "^1.22" + "symfony/polyfill-php81": "^1.29" }, "require-dev": { "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.3|^7.0" + "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" }, "type": "library", "autoload": { + "files": [ + "src/Resources/core.php", + "src/Resources/debug.php", + "src/Resources/escaper.php", + "src/Resources/string_loader.php" + ], "psr-4": { "Twig\\": "src/" } @@ -6846,7 +6929,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.8.0" + "source": "https://github.com/twigphp/Twig/tree/v3.14.0" }, "funding": [ { @@ -6858,7 +6941,7 @@ "type": "tidelift" } ], - "time": "2023-11-21T18:54:41+00:00" + "time": "2024-09-09T17:55:12+00:00" }, { "name": "webmozart/glob", @@ -6936,5 +7019,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } diff --git a/src/Appwrite/Event/Build.php b/src/Appwrite/Event/Build.php index b8cb62a6f8..af517f2598 100644 --- a/src/Appwrite/Event/Build.php +++ b/src/Appwrite/Event/Build.php @@ -115,6 +115,7 @@ class Build extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ + 'sourceRegion' => System::getEnv('_APP_REGION', 'default'), 'project' => $this->project, 'resource' => $this->resource, 'deployment' => $this->deployment, diff --git a/src/Appwrite/Event/Certificate.php b/src/Appwrite/Event/Certificate.php index 85058c96fe..cacfcc867f 100644 --- a/src/Appwrite/Event/Certificate.php +++ b/src/Appwrite/Event/Certificate.php @@ -77,6 +77,7 @@ class Certificate extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ + 'sourceRegion' => System::getEnv('_APP_REGION', 'default'), 'project' => $this->project, 'domain' => $this->domain, 'skipRenewCheck' => $this->skipRenewCheck diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index f9eb7d9a7d..b6eea1e748 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -121,6 +121,7 @@ class Database extends Event try { $result = $client->enqueue([ + 'sourceRegion' => System::getEnv('_APP_REGION', 'default'), 'project' => $this->project, 'user' => $this->user, 'type' => $this->type, diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 5e73378743..69cf8ddc2a 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Utopia\Database\Document; use Utopia\Queue\Client; use Utopia\Queue\Connection; +use Utopia\System\System; class Event { @@ -109,6 +110,11 @@ class Event return $this->event; } + public function getSourceRegion(): string + { + return System::getEnv('_APP_REGION', 'default'); + } + /** * Set project for this event. * @@ -301,6 +307,7 @@ class Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ + 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'user' => $this->user, 'payload' => $this->payload, diff --git a/src/Appwrite/Event/Migration.php b/src/Appwrite/Event/Migration.php index 478291829b..23b959c880 100644 --- a/src/Appwrite/Event/Migration.php +++ b/src/Appwrite/Event/Migration.php @@ -79,6 +79,8 @@ class Migration extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ + 'sourceRegion' => $this->getSourceRegion(), + 'project' => $this->project, 'user' => $this->user, 'migration' => $this->migration diff --git a/src/Appwrite/Messaging/Adapter.php b/src/Appwrite/Messaging/Adapter.php index 27dd7f68eb..6104d27c53 100644 --- a/src/Appwrite/Messaging/Adapter.php +++ b/src/Appwrite/Messaging/Adapter.php @@ -5,6 +5,8 @@ namespace Appwrite\Messaging; abstract class Adapter { abstract public function subscribe(string $projectId, mixed $identifier, array $roles, array $channels): void; + abstract public function unsubscribe(mixed $identifier): void; - abstract public static function send(string $projectId, array $payload, array $events, array $channels, array $roles, array $options): void; + + abstract public static function send(\redis $redis, string $projectId, array $payload, array $events, array $channels, array $roles, array $options): void; } diff --git a/src/Appwrite/Messaging/Adapter/Realtime.php b/src/Appwrite/Messaging/Adapter/Realtime.php index 55d8db2924..9359e2b4b5 100644 --- a/src/Appwrite/Messaging/Adapter/Realtime.php +++ b/src/Appwrite/Messaging/Adapter/Realtime.php @@ -122,15 +122,17 @@ class Realtime extends Adapter /** * Sends an event to the Realtime Server + * @param \Redis $redis * @param string $projectId * @param array $payload - * @param string $event + * @param array $events * @param array $channels * @param array $roles * @param array $options * @return void + * @throws \RedisException */ - public static function send(string $projectId, array $payload, array $events, array $channels, array $roles, array $options = []): void + public static function send(\Redis $redis, string $projectId, array $payload, array $events, array $channels, array $roles, array $options = []): void { if (empty($channels) || empty($roles) || empty($projectId)) { return; @@ -139,8 +141,6 @@ class Realtime extends Adapter $permissionsChanged = array_key_exists('permissionsChanged', $options) && $options['permissionsChanged']; $userId = array_key_exists('userId', $options) ? $options['userId'] : null; - $redis = new \Redis(); //TODO: make this part of the constructor - $redis->connect(System::getEnv('_APP_REDIS_HOST', ''), System::getEnv('_APP_REDIS_PORT', '')); $redis->publish('realtime', json_encode([ 'project' => $projectId, 'roles' => $roles, diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 5dd2f7f886..18d4f9bd79 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -33,6 +33,11 @@ use Utopia\VCS\Adapter\Git\GitHub; class Builds extends Action { + /** + * @var mixed|string + */ + protected string $sourceRegion; + public static function getName(): string { return 'builds'; @@ -54,7 +59,8 @@ class Builds extends Action ->inject('dbForProject') ->inject('deviceForFunctions') ->inject('log') - ->callback(fn ($message, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Usage $usage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log) => $this->action($message, $dbForConsole, $queueForEvents, $queueForFunctions, $usage, $cache, $dbForProject, $deviceForFunctions, $log)); + ->inject('realtimeConnection') + ->callback(fn ($message, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Usage $usage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log, Callable $realtimeConnection) => $this->action($message, $dbForConsole, $queueForEvents, $queueForFunctions, $usage, $cache, $dbForProject, $deviceForFunctions, $log, $realtimeConnection)); } /** @@ -67,10 +73,11 @@ class Builds extends Action * @param Database $dbForProject * @param Device $deviceForFunctions * @param Log $log + * @param callable $realtimeConnection * @return void * @throws \Utopia\Database\Exception */ - public function action(Message $message, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Usage $queueForUsage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log): void + public function action(Message $message, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Usage $queueForUsage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log, Callable $realtimeConnection): void { $payload = $message->getPayload() ?? []; @@ -84,6 +91,7 @@ class Builds extends Action $deployment = new Document($payload['deployment'] ?? []); $template = new Document($payload['template'] ?? []); + $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); @@ -92,7 +100,7 @@ class Builds extends Action case BUILD_TYPE_RETRY: Console::info('Creating build for deployment: ' . $deployment->getId()); $github = new GitHub($cache); - $this->buildDeployment($deviceForFunctions, $queueForFunctions, $queueForEvents, $queueForUsage, $dbForConsole, $dbForProject, $github, $project, $resource, $deployment, $template, $log); + $this->buildDeployment($deviceForFunctions, $queueForFunctions, $queueForEvents, $queueForUsage, $dbForConsole, $dbForProject, $github, $project, $resource, $deployment, $template, $log, $realtimeConnection); break; default: @@ -117,7 +125,7 @@ class Builds extends Action * @throws \Utopia\Database\Exception * @throws Exception */ - protected function buildDeployment(Device $deviceForFunctions, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Database $dbForConsole, Database $dbForProject, GitHub $github, Document $project, Document $function, Document $deployment, Document $template, Log $log): void + protected function buildDeployment(Device $deviceForFunctions, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Database $dbForConsole, Database $dbForProject, GitHub $github, Document $project, Document $function, Document $deployment, Document $template, Log $log, Callable $realtimeConnection): void { $executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST')); @@ -376,6 +384,7 @@ class Builds extends Action project: $project ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $build->getArrayCopy(), events: $allEvents, @@ -454,6 +463,7 @@ class Builds extends Action ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $build->getArrayCopy(), events: $allEvents, @@ -552,12 +562,12 @@ class Builds extends Action $err = $error; } }), - Co\go(function () use ($executor, $project, $deployment, &$response, &$build, $dbForProject, $allEvents, &$err, &$isCanceled) { + Co\go(function () use ($realtimeConnection, $executor, $project, $deployment, &$response, &$build, $dbForProject, $allEvents, &$err, &$isCanceled) { try { $executor->getLogs( deploymentId: $deployment->getId(), projectId: $project->getId(), - callback: function ($logs) use (&$response, &$err, &$build, $dbForProject, $allEvents, $project, &$isCanceled) { + callback: function ($logs) use ($realtimeConnection, &$response, &$err, &$build, $dbForProject, $allEvents, $project, &$isCanceled) { if ($isCanceled) { return; } @@ -591,6 +601,7 @@ class Builds extends Action project: $project ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $build->getArrayCopy(), events: $allEvents, @@ -693,6 +704,7 @@ class Builds extends Action project: $project ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $build->getArrayCopy(), events: $allEvents, diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 58dc1dd28a..1d95fc6a51 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -30,6 +30,11 @@ use Utopia\System\System; class Certificates extends Action { + /** + * @var mixed|string + */ + protected string $sourceRegion; + public static function getName(): string { return 'certificates'; @@ -48,7 +53,8 @@ class Certificates extends Action ->inject('queueForEvents') ->inject('queueForFunctions') ->inject('log') - ->callback(fn (Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log) => $this->action($message, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log)); + ->inject('realtimeConnection') + ->callback(fn (Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, Callable $realtimeConnection) => $this->action($message, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log, $realtimeConnection)); } /** @@ -58,11 +64,12 @@ class Certificates extends Action * @param Event $queueForEvents * @param Func $queueForFunctions * @param Log $log + * @param callable $realtimeConnection * @return void * @throws Throwable * @throws \Utopia\Database\Exception */ - public function action(Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log): void + public function action(Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, Callable $realtimeConnection): void { $payload = $message->getPayload() ?? []; @@ -74,9 +81,9 @@ class Certificates extends Action $domain = new Domain($document->getAttribute('domain', '')); $skipRenewCheck = $payload['skipRenewCheck'] ?? false; + $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; $log->addTag('domain', $domain->get()); - - $this->execute($domain, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log, $skipRenewCheck); + $this->execute($domain, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log,$realtimeConnection, $skipRenewCheck); } /** @@ -85,12 +92,17 @@ class Certificates extends Action * @param Mail $queueForMails * @param Event $queueForEvents * @param Func $queueForFunctions + * @param Log $log + * @param callable $realtimeConnection * @param bool $skipRenewCheck * @return void + * @throws Authorization + * @throws Conflict + * @throws Structure * @throws Throwable * @throws \Utopia\Database\Exception */ - private function execute(Domain $domain, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, bool $skipRenewCheck = false): void + protected function execute(Domain $domain, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, Callable $realtimeConnection, bool $skipRenewCheck = false): void { /** * 1. Read arguments and validate domain @@ -193,7 +205,7 @@ class Certificates extends Action $certificate->setAttribute('updated', DateTime::now()); // Save all changes we made to certificate document into database - $this->saveCertificateDocument($domain->get(), $certificate, $success, $dbForConsole, $queueForEvents, $queueForFunctions); + $this->saveCertificateDocument($domain->get(), $certificate, $success, $dbForConsole, $queueForEvents, $queueForFunctions, $realtimeConnection); } } @@ -212,7 +224,7 @@ class Certificates extends Action * @throws Conflict * @throws Structure */ - private function saveCertificateDocument(string $domain, Document $certificate, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions): void + protected function saveCertificateDocument(string $domain, Document $certificate, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Callable $realtimeConnection): void { // Check if update or insert required $certificateDocument = $dbForConsole->findOne('certificates', [Query::equal('domain', [$domain])]); @@ -226,7 +238,7 @@ class Certificates extends Action } $certificateId = $certificate->getId(); - $this->updateDomainDocuments($certificateId, $domain, $success, $dbForConsole, $queueForEvents, $queueForFunctions); + $this->updateDomainDocuments($certificateId, $domain, $success, $dbForConsole, $queueForEvents, $queueForFunctions, $realtimeConnection); } /** @@ -234,7 +246,7 @@ class Certificates extends Action * * @return null|string Returns main domain. If null, there is no main domain yet. */ - private function getMainDomain(): ?string + protected function getMainDomain(): ?string { $envDomain = System::getEnv('_APP_DOMAIN', ''); if (!empty($envDomain) && $envDomain !== 'localhost') { @@ -255,7 +267,7 @@ class Certificates extends Action * @return void * @throws Exception */ - private function validateDomain(Domain $domain, bool $isMainDomain, Log $log): void + protected function validateDomain(Domain $domain, bool $isMainDomain, Log $log): void { if (empty($domain->get())) { throw new Exception('Missing certificate domain.'); @@ -299,7 +311,7 @@ class Certificates extends Action * @return bool True, if certificate needs to be renewed * @throws Exception */ - private function isRenewRequired(string $domain, Log $log): bool + protected function isRenewRequired(string $domain, Log $log): bool { $certPath = APP_STORAGE_CERTIFICATES . '/' . $domain . '/cert.pem'; if (\file_exists($certPath)) { @@ -333,7 +345,7 @@ class Certificates extends Action * @return array Named array with keys 'stdout' and 'stderr', both string * @throws Exception */ - private function issueCertificate(string $folder, string $domain, string $email): array + protected function issueCertificate(string $folder, string $domain, string $email): array { $stdout = ''; $stderr = ''; @@ -363,7 +375,7 @@ class Certificates extends Action * @return string * @throws \Utopia\Database\Exception */ - private function getRenewDate(string $domain): string + protected function getRenewDate(string $domain): string { $certPath = APP_STORAGE_CERTIFICATES . '/' . $domain . '/cert.pem'; $certData = openssl_x509_parse(file_get_contents($certPath)); @@ -381,7 +393,7 @@ class Certificates extends Action * @return void * @throws Exception */ - private function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void + protected function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void { // Prepare folder in storage for domain @@ -432,7 +444,7 @@ class Certificates extends Action * @return void * @throws Exception */ - private function notifyError(string $domain, string $errorMessage, int $attempt, Mail $queueForMails): void + protected function notifyError(string $domain, string $errorMessage, int $attempt, Mail $queueForMails): void { // Log error into console Console::warning('Cannot renew domain (' . $domain . ') on attempt no. ' . $attempt . ' certificate: ' . $errorMessage); @@ -475,7 +487,7 @@ class Certificates extends Action * * @return void */ - private function updateDomainDocuments(string $certificateId, string $domain, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions): void + protected function updateDomainDocuments(string $certificateId, string $domain, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Callable $realtimeConnection): void { $rule = $dbForConsole->findOne('rules', [ @@ -525,6 +537,7 @@ class Certificates extends Action project: $project ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $rule->getArrayCopy(), events: $allEvents, @@ -532,6 +545,7 @@ class Certificates extends Action roles: $target['roles'] ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: $project->getId(), payload: $rule->getArrayCopy(), events: $allEvents, diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 56f5f012e8..5932deb7d9 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -21,6 +21,11 @@ use Utopia\Queue\Message; class Databases extends Action { + /** + * @var array|mixed + */ + protected string $sourceRegion; + public static function getName(): string { return 'databases'; @@ -37,7 +42,8 @@ class Databases extends Action ->inject('dbForConsole') ->inject('dbForProject') ->inject('log') - ->callback(fn (Message $message, Database $dbForConsole, Database $dbForProject, Log $log) => $this->action($message, $dbForConsole, $dbForProject, $log)); + ->inject('realtimeConnection') + ->callback(fn (Message $message, Database $dbForConsole, Database $dbForProject, Log $log, callable $realtimeConnection) => $this->action($message, $dbForConsole, $dbForProject, $log, $realtimeConnection)); } /** @@ -45,10 +51,16 @@ class Databases extends Action * @param Database $dbForConsole * @param Database $dbForProject * @param Log $log + * @param callable $realtimeConnection * @return void - * @throws \Exception + * @throws Authorization + * @throws Conflict + * @throws DatabaseException + * @throws Restricted + * @throws Structure + * @throws Exception */ - public function action(Message $message, Database $dbForConsole, Database $dbForProject, Log $log): void + public function action(Message $message, Database $dbForConsole, Database $dbForProject, Log $log, callable $realtimeConnection): void { $payload = $message->getPayload() ?? []; @@ -62,6 +74,7 @@ class Databases extends Action $document = new Document($payload['document'] ?? []); $database = new Document($payload['database'] ?? []); + $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); @@ -74,10 +87,10 @@ class Databases extends Action match (\strval($type)) { DATABASE_TYPE_DELETE_DATABASE => $this->deleteDatabase($database, $project, $dbForProject), DATABASE_TYPE_DELETE_COLLECTION => $this->deleteCollection($database, $collection, $project, $dbForProject), - DATABASE_TYPE_CREATE_ATTRIBUTE => $this->createAttribute($database, $collection, $document, $project, $dbForConsole, $dbForProject), - DATABASE_TYPE_DELETE_ATTRIBUTE => $this->deleteAttribute($database, $collection, $document, $project, $dbForConsole, $dbForProject), - DATABASE_TYPE_CREATE_INDEX => $this->createIndex($database, $collection, $document, $project, $dbForConsole, $dbForProject), - DATABASE_TYPE_DELETE_INDEX => $this->deleteIndex($database, $collection, $document, $project, $dbForConsole, $dbForProject), + DATABASE_TYPE_CREATE_ATTRIBUTE => $this->createAttribute($database, $collection, $document, $project, $dbForConsole, $dbForProject, $realtimeConnection), + DATABASE_TYPE_DELETE_ATTRIBUTE => $this->deleteAttribute($database, $collection, $document, $project, $dbForConsole, $dbForProject, $realtimeConnection), + DATABASE_TYPE_CREATE_INDEX => $this->createIndex($database, $collection, $document, $project, $dbForConsole, $dbForProject, $realtimeConnection), + DATABASE_TYPE_DELETE_INDEX => $this->deleteIndex($database, $collection, $document, $project, $dbForConsole, $dbForProject, $realtimeConnection), default => throw new \Exception('No database operation for type: ' . \strval($type)), }; } @@ -89,12 +102,15 @@ class Databases extends Action * @param Document $project * @param Database $dbForConsole * @param Database $dbForProject + * @param callable $realtimeConnection * @return void * @throws Authorization * @throws Conflict - * @throws \Exception + * @throws DatabaseException + * @throws Structure + * @throws Exception */ - private function createAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject): void + private function createAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); @@ -195,7 +211,7 @@ class Databases extends Action ); } } finally { - $this->trigger($database, $collection, $attribute, $project, $projectId, $events); + $this->trigger($database, $collection, $attribute, $project, $projectId, $events, $realtimeConnection); } if ($type === Database::VAR_RELATIONSHIP && $options['twoWay']) { @@ -212,12 +228,16 @@ class Databases extends Action * @param Document $project * @param Database $dbForConsole * @param Database $dbForProject + * @param callable $realtimeConnection * @return void * @throws Authorization * @throws Conflict - * @throws \Exception - **/ - private function deleteAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject): void + * @throws DatabaseException + * @throws Restricted + * @throws Structure + * @throws Exception + */ + private function deleteAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); @@ -296,7 +316,7 @@ class Databases extends Action ); } } finally { - $this->trigger($database, $collection, $attribute, $project, $projectId, $events); + $this->trigger($database, $collection, $attribute, $project, $projectId, $events, $realtimeConnection); } // The underlying database removes/rebuilds indexes when attribute is removed @@ -366,13 +386,15 @@ class Databases extends Action * @param Document $project * @param Database $dbForConsole * @param Database $dbForProject + * @param callable $realtimeConnection * @return void * @throws Authorization * @throws Conflict - * @throws Structure * @throws DatabaseException + * @throws Structure + * @throws Exception */ - private function createIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject): void + private function createIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); @@ -414,7 +436,7 @@ class Databases extends Action $index->setAttribute('status', 'failed') ); } finally { - $this->trigger($database, $collection, $index, $project, $projectId, $events); + $this->trigger($database, $collection, $index, $project, $projectId, $events, $realtimeConnection); } $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); @@ -427,13 +449,15 @@ class Databases extends Action * @param Document $project * @param Database $dbForConsole * @param Database $dbForProject + * @param callable $realtimeConnection * @return void * @throws Authorization * @throws Conflict - * @throws Structure * @throws DatabaseException + * @throws Structure + * @throws Exception */ - private function deleteIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject): void + private function deleteIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); @@ -472,7 +496,7 @@ class Databases extends Action $index->setAttribute('status', 'stuck') ); } finally { - $this->trigger($database, $collection, $index, $project, $projectId, $events); + $this->trigger($database, $collection, $index, $project, $projectId, $events, $realtimeConnection); } $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collection->getId()); @@ -612,13 +636,18 @@ class Databases extends Action Console::info("Deleted {$count} document by group in " . ($executionEnd - $executionStart) . " seconds"); } + /** + * @throws \RedisException + * @throws Exception + */ protected function trigger( Document $database, Document $collection, Document $attribute, Document $project, string $projectId, - array $events + array $events, + callable $realtimeConnection ): void { $target = Realtime::fromPayload( // Pass first, most verbose event pattern @@ -627,6 +656,7 @@ class Databases extends Action project: $project, ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $attribute->getArrayCopy(), events: $events, diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index c70d9ca11b..da6e85fdba 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -497,19 +497,20 @@ class Deletes extends Action ]; $limit = \count($projectCollectionIds) + 25; + $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); while (true) { $collections = $dbForProject->listCollections($limit); foreach ($collections as $collection) { - if ($dsn->getHost() !== System::getEnv('_APP_DATABASE_SHARED_TABLES', '') || !\in_array($collection->getId(), $projectCollectionIds)) { - $dbForProject->deleteCollection($collection->getId()); + if (! in_array($dsn->getHost(), $sharedTablesKeys) || !\in_array($collection->getId(), $projectCollectionIds)) { + $dbForProject->deleteCollection($collection->getId()); $dbForProject->deleteCollection($collection->getId()); } else { $this->deleteByGroup($collection->getId(), [], database: $dbForProject); } } - if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + if (in_array($dsn->getHost(), $sharedTablesKeys)) { $collectionsIds = \array_map(fn ($collection) => $collection->getId(), $collections); if (empty(\array_diff($collectionsIds, $projectCollectionIds))) { @@ -558,7 +559,8 @@ class Deletes extends Action ], $dbForConsole); // Delete metadata table - if ($dsn->getHost() !== System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { + System::getEnv('_APP_DATABASE_SHARED_TABLES', ''); + if (! in_array($dsn, $sharedTablesKeys)) { $dbForProject->deleteCollection('_metadata'); } else { $this->deleteByGroup('_metadata', [], $dbForProject); diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index e0f66c30f9..481486e63f 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -28,6 +28,11 @@ use Utopia\System\System; class Functions extends Action { + /** + * @var mixed|string + */ + protected string $sourceRegion; + public static function getName(): string { return 'functions'; @@ -47,7 +52,8 @@ class Functions extends Action ->inject('queueForEvents') ->inject('queueForUsage') ->inject('log') - ->callback(fn (Message $message, Database $dbForProject, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Log $log) => $this->action($message, $dbForProject, $queueForFunctions, $queueForEvents, $queueForUsage, $log)); + ->inject('realtimeConnection') + ->callback(fn (Message $message, Database $dbForProject, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Log $log, Callable $realtimeConnection) => $this->action($message, $dbForProject, $queueForFunctions, $queueForEvents, $queueForUsage, $log, $realtimeConnection)); } /** @@ -63,7 +69,7 @@ class Functions extends Action * @throws \Utopia\Database\Exception * @throws Conflict */ - public function action(Message $message, Database $dbForProject, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Log $log): void + public function action(Message $message, Database $dbForProject, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Log $log, Callable $realtimeConnection): void { $payload = $message->getPayload() ?? []; @@ -93,6 +99,9 @@ class Functions extends Action return; } + $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; + + if ($function->isEmpty() && !empty($functionId)) { $function = $dbForProject->getDocument('functions', $functionId); } @@ -125,6 +134,7 @@ class Functions extends Action Console::success('Iterating function: ' . $function->getAttribute('name')); $this->execute( + realtimeConnection: $realtimeConnection, log: $log, dbForProject: $dbForProject, queueForFunctions: $queueForFunctions, @@ -161,6 +171,7 @@ class Functions extends Action $execution = new Document($payload['execution'] ?? []); $user = new Document($payload['user'] ?? []); $this->execute( + realtimeConnection: $realtimeConnection, log: $log, dbForProject: $dbForProject, queueForFunctions: $queueForFunctions, @@ -183,6 +194,7 @@ class Functions extends Action case 'schedule': $execution = new Document($payload['execution'] ?? []); $this->execute( + realtimeConnection: $realtimeConnection, log: $log, dbForProject: $dbForProject, queueForFunctions: $queueForFunctions, @@ -292,6 +304,7 @@ class Functions extends Action * @throws Conflict */ private function execute( + Callable $realtimeConnection, Log $log, Database $dbForProject, Func $queueForFunctions, @@ -583,6 +596,7 @@ class Functions extends Action payload: $execution ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $execution->getArrayCopy(), events: $allEvents, @@ -590,6 +604,7 @@ class Functions extends Action roles: $target['roles'] ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: $project->getId(), payload: $execution->getArrayCopy(), events: $allEvents, diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 8ab5ebac46..13812a2e12 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -32,6 +32,10 @@ class Migrations extends Action { private ?Database $dbForProject = null; private ?Database $dbForConsole = null; + /** + * @var string + */ + protected string $sourceRegion; public static function getName(): string { @@ -49,7 +53,8 @@ class Migrations extends Action ->inject('dbForProject') ->inject('dbForConsole') ->inject('log') - ->callback(fn (Message $message, Database $dbForProject, Database $dbForConsole, Log $log) => $this->action($message, $dbForProject, $dbForConsole, $log)); + ->inject('realtimeConnection') + ->callback(fn (Message $message, Database $dbForProject, Database $dbForConsole, Log $log, Callable $realtimeConnection) => $this->action($message, $dbForProject, $dbForConsole, $log, $realtimeConnection)); } /** @@ -60,7 +65,7 @@ class Migrations extends Action * @return void * @throws Exception */ - public function action(Message $message, Database $dbForProject, Database $dbForConsole, Log $log): void + public function action(Message $message, Database $dbForProject, Database $dbForConsole, Log $log, Callable $realtimeConnection): void { $payload = $message->getPayload() ?? []; @@ -76,6 +81,7 @@ class Migrations extends Action return; } + $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; $this->dbForProject = $dbForProject; $this->dbForConsole = $dbForConsole; @@ -89,7 +95,7 @@ class Migrations extends Action $log->addTag('migrationId', $migration->getId()); $log->addTag('projectId', $project->getId()); - $this->processMigration($project, $migration, $log); + $this->processMigration($project, $migration, $log, $realtimeConnection); } /** @@ -134,7 +140,7 @@ class Migrations extends Action * @throws \Utopia\Database\Exception * @throws Exception */ - protected function updateMigrationDocument(Document $migration, Document $project): Document + protected function updateMigrationDocument(Document $migration, Document $project, Callable $realtimeConnection): Document { /** Trigger Realtime */ $allEvents = Event::generateEvents('migrations.[migrationId].update', [ @@ -148,6 +154,7 @@ class Migrations extends Action ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $migration->getArrayCopy(), events: $allEvents, @@ -156,6 +163,7 @@ class Migrations extends Action ); Realtime::send( + redis: $realtimeConnection($this->sourceRegion), projectId: $project->getId(), payload: $migration->getArrayCopy(), events: $allEvents, @@ -236,6 +244,7 @@ class Migrations extends Action * @param Document $project * @param Document $migration * @param Log $log + * @param callable $realtimeConnection * @return void * @throws Authorization * @throws Conflict @@ -243,7 +252,7 @@ class Migrations extends Action * @throws Structure * @throws \Utopia\Database\Exception */ - protected function processMigration(Document $project, Document $migration, Log $log): void + protected function processMigration(Document $project, Document $migration, Log $log, Callable $realtimeConnection): void { /** * @var Document $migrationDocument @@ -259,7 +268,7 @@ class Migrations extends Action $migrationDocument->setAttribute('stage', 'processing'); $migrationDocument->setAttribute('status', 'processing'); $log->addBreadcrumb(new Breadcrumb("debug", "migration", "Migration hit stage 'processing'", \microtime(true))); - $this->updateMigrationDocument($migrationDocument, $projectDocument); + $this->updateMigrationDocument($migrationDocument, $projectDocument, $realtimeConnection); $log->addTag('type', $migrationDocument->getAttribute('source')); @@ -281,12 +290,12 @@ class Migrations extends Action /** Start Transfer */ $migrationDocument->setAttribute('stage', 'migrating'); $log->addBreadcrumb(new Breadcrumb("debug", "migration", "Migration hit stage 'migrating'", \microtime(true))); - $this->updateMigrationDocument($migrationDocument, $projectDocument); - $transfer->run($migrationDocument->getAttribute('resources'), function () use ($migrationDocument, $transfer, $projectDocument) { + $this->updateMigrationDocument($migrationDocument, $projectDocument, $realtimeConnection); + $transfer->run($migrationDocument->getAttribute('resources'), function () use ($realtimeConnection, $migrationDocument, $transfer, $projectDocument) { $migrationDocument->setAttribute('resourceData', json_encode($transfer->getCache())); $migrationDocument->setAttribute('statusCounters', json_encode($transfer->getStatusCounters())); - $this->updateMigrationDocument($migrationDocument, $projectDocument); + $this->updateMigrationDocument($migrationDocument, $projectDocument, $realtimeConnection); }); $sourceErrors = $source->getErrors(); @@ -309,7 +318,7 @@ class Migrations extends Action $migrationDocument->setAttribute('errors', $errorMessages); $log->addExtra('migrationErrors', json_encode($errorMessages)); - $this->updateMigrationDocument($migrationDocument, $projectDocument); + $this->updateMigrationDocument($migrationDocument, $projectDocument, $realtimeConnection); return; } @@ -352,7 +361,7 @@ class Migrations extends Action $this->removeAPIKey($tempAPIKey); } if ($migrationDocument) { - $this->updateMigrationDocument($migrationDocument, $projectDocument); + $this->updateMigrationDocument($migrationDocument, $projectDocument, $realtimeConnection); if ($migrationDocument->getAttribute('status', '') == 'failed') { throw new Exception("Migration failed"); From 501411f5b5af509d119be02ccce6224fcff75c78 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 15 Sep 2024 17:42:46 +0200 Subject: [PATCH 019/144] 1.6.x --- app/config/bla | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 app/config/bla diff --git a/app/config/bla b/app/config/bla deleted file mode 100644 index 37b151a403..0000000000 --- a/app/config/bla +++ /dev/null @@ -1,36 +0,0 @@ -version: '3.8' - -services: - db_15: - image: mysql:8.0.36-debian - container_name: mysql_db_15 - environment: - MYSQL_ROOT_PASSWORD: lJVYGNZTOTF4VsGSnz5CWoVp - MYSQL_DATABASE: appwrite - MYSQL_USER: appwrite_user - MYSQL_PASSWORD: Fy8i367HpJd8EB1VGos3vsf - volumes: - - /mnt/db-15:/var/lib/mysql - ports: - - "3307:3306" - networks: - - mysql_network - - db_16: - image: mysql:8.0.36-debian - container_name: mysql_db_16 - environment: - MYSQL_ROOT_PASSWORD: d1RNc7NsnsQ8I1OQd0eeLWr0 - MYSQL_DATABASE: appwrite - MYSQL_USER: appwrite_user - MYSQL_PASSWORD: KlQ4NMyl46YPumqSA8CUOLjO - volumes: - - /mnt/db-16:/var/lib/mysql - ports: - - "3308:3306" - networks: - - mysql_network - -networks: - mysql_network: - driver: bridge \ No newline at end of file From fd8b7eb6fc3bf95b6276ca0ff69b1303b44e3af4 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 17 Sep 2024 15:35:48 +0300 Subject: [PATCH 020/144] update --- app/controllers/api/databases.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index a9bb58df4b..8c8dc2ca57 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -205,7 +205,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $relatedCollection->getId()); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); } - + var_dump($queueForDatabase); $queueForDatabase ->setType(DATABASE_TYPE_CREATE_ATTRIBUTE) ->setDatabase($db) From eb553fa96ce017d694a54f39fa48938381c6d6a1 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 17 Sep 2024 21:09:16 +0300 Subject: [PATCH 021/144] debug --- src/Appwrite/Event/Database.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index b6eea1e748..9fe991a6dd 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -108,6 +108,10 @@ class Database extends Event */ public function trigger(): string|bool { + + var_dump('database='); + var_dump($this->getProject()->getAttribute('database')); + try { $dsn = new DSN($this->getProject()->getAttribute('database')); } catch (\InvalidArgumentException) { @@ -115,6 +119,9 @@ class Database extends Event $dsn = new DSN('mysql://' . $this->getProject()->getAttribute('database')); } + var_dump('$dsn->getHost()='); + var_dump($dsn->getHost()); + $this->setQueue($dsn->getHost()); $client = new Client($this->queue, $this->connection); From 134f90a46454ae4818c1948f1ab30f5f9a86f0f4 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 17 Sep 2024 23:32:36 +0300 Subject: [PATCH 022/144] fix --- app/controllers/api/databases.php | 2 +- src/Appwrite/Event/Database.php | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 8c8dc2ca57..a9bb58df4b 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -205,7 +205,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $relatedCollection->getId()); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); } - var_dump($queueForDatabase); + $queueForDatabase ->setType(DATABASE_TYPE_CREATE_ATTRIBUTE) ->setDatabase($db) diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 9fe991a6dd..69c38e2ec5 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -109,8 +109,6 @@ class Database extends Event public function trigger(): string|bool { - var_dump('database='); - var_dump($this->getProject()->getAttribute('database')); try { $dsn = new DSN($this->getProject()->getAttribute('database')); @@ -119,9 +117,6 @@ class Database extends Event $dsn = new DSN('mysql://' . $this->getProject()->getAttribute('database')); } - var_dump('$dsn->getHost()='); - var_dump($dsn->getHost()); - $this->setQueue($dsn->getHost()); $client = new Client($this->queue, $this->connection); From b706571a2122ec55a5b9171ea6a11ff8814ffc72 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 18 Sep 2024 10:55:30 +0300 Subject: [PATCH 023/144] _APP_OPTIONS_ROUTER_PROTECTION --- app/controllers/general.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index 0bbfa2b694..c63dfae1ab 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -57,6 +57,10 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo ]) )[0] ?? null; + var_dump(System::getEnv('_APP_DOMAIN_FUNCTIONS', '')); + var_dump($host); + var_dump(APP_HOSTNAME_INTERNAL); + if ($route === null) { if ($host === System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain cannot be used for security reasons. Please use any subdomain instead.'); From ec02d881c980c51dc7cc0c4d6320479357d8dd71 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 18 Sep 2024 11:52:59 +0300 Subject: [PATCH 024/144] updates --- app/controllers/general.php | 4 +++- src/Appwrite/Event/Build.php | 2 +- src/Appwrite/Event/Certificate.php | 2 +- src/Appwrite/Event/Database.php | 3 +-- src/Appwrite/Event/Event.php | 2 ++ src/Appwrite/Event/Func.php | 1 + src/Appwrite/Event/Migration.php | 1 - src/Appwrite/Platform/Workers/Builds.php | 2 +- src/Appwrite/Platform/Workers/Certificates.php | 2 +- src/Appwrite/Platform/Workers/Databases.php | 2 +- src/Appwrite/Platform/Workers/Functions.php | 1 - 11 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index c63dfae1ab..1240d659a0 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -60,7 +60,9 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo var_dump(System::getEnv('_APP_DOMAIN_FUNCTIONS', '')); var_dump($host); var_dump(APP_HOSTNAME_INTERNAL); - + var_dump($request->getHeader('host')); + var_dump($request->getHeader('x-forwarded-host')); + if ($route === null) { if ($host === System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain cannot be used for security reasons. Please use any subdomain instead.'); diff --git a/src/Appwrite/Event/Build.php b/src/Appwrite/Event/Build.php index af517f2598..237803a7ff 100644 --- a/src/Appwrite/Event/Build.php +++ b/src/Appwrite/Event/Build.php @@ -115,7 +115,7 @@ class Build extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ - 'sourceRegion' => System::getEnv('_APP_REGION', 'default'), + 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'resource' => $this->resource, 'deployment' => $this->deployment, diff --git a/src/Appwrite/Event/Certificate.php b/src/Appwrite/Event/Certificate.php index cacfcc867f..188e6dd27d 100644 --- a/src/Appwrite/Event/Certificate.php +++ b/src/Appwrite/Event/Certificate.php @@ -77,7 +77,7 @@ class Certificate extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ - 'sourceRegion' => System::getEnv('_APP_REGION', 'default'), + 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'domain' => $this->domain, 'skipRenewCheck' => $this->skipRenewCheck diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 69c38e2ec5..4b53b71d99 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -109,7 +109,6 @@ class Database extends Event public function trigger(): string|bool { - try { $dsn = new DSN($this->getProject()->getAttribute('database')); } catch (\InvalidArgumentException) { @@ -123,7 +122,7 @@ class Database extends Event try { $result = $client->enqueue([ - 'sourceRegion' => System::getEnv('_APP_REGION', 'default'), + 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'user' => $this->user, 'type' => $this->type, diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 69cf8ddc2a..3595be9216 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -110,6 +110,8 @@ class Event return $this->event; } + + public function getSourceRegion(): string { return System::getEnv('_APP_REGION', 'default'); diff --git a/src/Appwrite/Event/Func.php b/src/Appwrite/Event/Func.php index 451df2b6c1..a099f7152c 100644 --- a/src/Appwrite/Event/Func.php +++ b/src/Appwrite/Event/Func.php @@ -220,6 +220,7 @@ class Func extends Event $events = $this->getEvent() ? Event::generateEvents($this->getEvent(), $this->getParams()) : null; return $client->enqueue([ + 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'user' => $this->user, 'function' => $this->function, diff --git a/src/Appwrite/Event/Migration.php b/src/Appwrite/Event/Migration.php index 23b959c880..eddce6354e 100644 --- a/src/Appwrite/Event/Migration.php +++ b/src/Appwrite/Event/Migration.php @@ -80,7 +80,6 @@ class Migration extends Event return $client->enqueue([ 'sourceRegion' => $this->getSourceRegion(), - 'project' => $this->project, 'user' => $this->user, 'migration' => $this->migration diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 18d4f9bd79..36fe1a6d1a 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -90,8 +90,8 @@ class Builds extends Action $resource = new Document($payload['resource'] ?? []); $deployment = new Document($payload['deployment'] ?? []); $template = new Document($payload['template'] ?? []); - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; + $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 1d95fc6a51..7a4ce1ef0b 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -80,8 +80,8 @@ class Certificates extends Action $document = new Document($payload['domain'] ?? []); $domain = new Domain($document->getAttribute('domain', '')); $skipRenewCheck = $payload['skipRenewCheck'] ?? false; - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; + $log->addTag('domain', $domain->get()); $this->execute($domain, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log,$realtimeConnection, $skipRenewCheck); } diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 5932deb7d9..7f3132dcb0 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -73,8 +73,8 @@ class Databases extends Action $collection = new Document($payload['collection'] ?? []); $document = new Document($payload['document'] ?? []); $database = new Document($payload['database'] ?? []); - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; + $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index 481486e63f..e03a8ac069 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -101,7 +101,6 @@ class Functions extends Action $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; - if ($function->isEmpty() && !empty($functionId)) { $function = $dbForProject->getDocument('functions', $functionId); } From 812d8a34cf60db4ce2a76648466d10215123d1c1 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 18 Sep 2024 13:45:09 +0300 Subject: [PATCH 025/144] updates --- app/controllers/general.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 1240d659a0..2273e802bb 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -57,12 +57,12 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo ]) )[0] ?? null; - var_dump(System::getEnv('_APP_DOMAIN_FUNCTIONS', '')); - var_dump($host); - var_dump(APP_HOSTNAME_INTERNAL); - var_dump($request->getHeader('host')); - var_dump($request->getHeader('x-forwarded-host')); - +// var_dump(System::getEnv('_APP_DOMAIN_FUNCTIONS', '')); +// var_dump($host); +// var_dump(APP_HOSTNAME_INTERNAL); +// var_dump($request->getHeader('host')); +// var_dump($request->getHeader('x-forwarded-host')); + if ($route === null) { if ($host === System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain cannot be used for security reasons. Please use any subdomain instead.'); From d1b062a418b9246d24e20c1e90f4e2b7598fc758 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 19 Sep 2024 20:03:15 +0300 Subject: [PATCH 026/144] Scheduled task fix --- app/cli.php | 4 ++++ src/Appwrite/Platform/Tasks/ScheduleBase.php | 21 ++++++++----------- .../Platform/Tasks/ScheduleExecutions.php | 10 ++++----- .../Platform/Tasks/ScheduleFunctions.php | 12 ++++------- .../Platform/Tasks/ScheduleMessages.php | 12 +++++------ 5 files changed, 26 insertions(+), 33 deletions(-) diff --git a/app/cli.php b/app/cli.php index 0dec8bad04..9b85804349 100644 --- a/app/cli.php +++ b/app/cli.php @@ -156,15 +156,19 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, CLI::setResource('queue', function (Group $pools) { return $pools->get('queue')->pop()->getResource(); }, ['pools']); + CLI::setResource('queueForFunctions', function (Connection $queue) { return new Func($queue); }, ['queue']); + CLI::setResource('queueForDeletes', function (Connection $queue) { return new Delete($queue); }, ['queue']); + CLI::setResource('queueForCertificates', function (Connection $queue) { return new Certificate($queue); }, ['queue']); + CLI::setResource('logError', function (Registry $register) { return function (Throwable $error, string $namespace, string $action) use ($register) { $logger = $register->get('logger'); diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index e013220aa4..29ca74ee8e 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -11,6 +11,7 @@ use Utopia\Database\Exception; use Utopia\Database\Query; use Utopia\Platform\Action; use Utopia\Pools\Group; +use Utopia\Queue\Connection; use Utopia\System\System; use function Swoole\Coroutine\run; @@ -26,7 +27,7 @@ abstract class ScheduleBase extends Action abstract public static function getSupportedResource(): string; abstract protected function enqueueResources( - Group $pools, + Connection $queue, Database $dbForConsole ); @@ -36,10 +37,10 @@ abstract class ScheduleBase extends Action $this ->desc("Execute {$type}s scheduled in Appwrite") - ->inject('pools') + ->inject('queue') ->inject('dbForConsole') ->inject('getProjectDB') - ->callback(fn (Group $pools, Database $dbForConsole, callable $getProjectDB) => $this->action($pools, $dbForConsole, $getProjectDB)); + ->callback(fn (Connection $queue, Database $dbForConsole, callable $getProjectDB) => $this->action($queue, $dbForConsole, $getProjectDB)); } /** @@ -47,7 +48,7 @@ abstract class ScheduleBase extends Action * 2. Create timer that sync all changes from 'schedules' collection to local copy. Only reading changes thanks to 'resourceUpdatedAt' attribute * 3. Create timer that prepares coroutines for soon-to-execute schedules. When it's ready, coroutine sleeps until exact time before sending request to worker. */ - public function action(Group $pools, Database $dbForConsole, callable $getProjectDB): void + public function action(Connection $queue, Database $dbForConsole, callable $getProjectDB): void { Console::title(\ucfirst(static::getSupportedResource()) . ' scheduler V1'); Console::success(APP_NAME . ' ' . \ucfirst(static::getSupportedResource()) . ' scheduler v1 has started'); @@ -127,17 +128,15 @@ abstract class ScheduleBase extends Action $latestDocument = \end($results); } - $pools->reclaim(); - Console::success("{$total} resources were loaded in " . (\microtime(true) - $loadStart) . " seconds"); Console::success("Starting timers at " . DateTime::now()); - run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools) { + run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $queue) { /** * The timer synchronize $schedules copy with database collection. */ - Timer::tick(static::UPDATE_TIMER * 1000, function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools) { + Timer::tick(static::UPDATE_TIMER * 1000, function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $queue) { $time = DateTime::now(); $timerStart = \microtime(true); @@ -186,17 +185,15 @@ abstract class ScheduleBase extends Action $lastSyncUpdate = $time; $timerEnd = \microtime(true); - $pools->reclaim(); - Console::log("Sync tick: {$total} schedules were updated in " . ($timerEnd - $timerStart) . " seconds"); }); Timer::tick( static::ENQUEUE_TIMER * 1000, - fn () => $this->enqueueResources($pools, $dbForConsole) + fn () => $this->enqueueResources($queue, $dbForConsole) ); - $this->enqueueResources($pools, $dbForConsole); + $this->enqueueResources($queue, $dbForConsole); }); } } diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 0e618642d5..2822aea130 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -6,6 +6,7 @@ use Appwrite\Event\Func; use Swoole\Coroutine as Co; use Utopia\Database\Database; use Utopia\Pools\Group; +use Utopia\Queue\Connection; class ScheduleExecutions extends ScheduleBase { @@ -22,11 +23,10 @@ class ScheduleExecutions extends ScheduleBase return 'execution'; } - protected function enqueueResources(Group $pools, Database $dbForConsole): void + protected function enqueueResources(Connection $queue, Database $dbForConsole): void { - $queue = $pools->get('queue')->pop(); - $connection = $queue->getResource(); - $queueForFunctions = new Func($connection); + + $queueForFunctions = new Func($queue); $intervalEnd = (new \DateTime())->modify('+' . self::ENQUEUE_TIMER . ' seconds'); foreach ($this->schedules as $schedule) { @@ -72,7 +72,5 @@ class ScheduleExecutions extends ScheduleBase unset($this->schedules[$schedule['$internalId']]); } - - $queue->reclaim(); } } diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index e2c278714f..a598bb5f45 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -8,6 +8,7 @@ use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Pools\Group; +use Utopia\Queue\Connection; class ScheduleFunctions extends ScheduleBase { @@ -26,7 +27,7 @@ class ScheduleFunctions extends ScheduleBase return 'function'; } - protected function enqueueResources(Group $pools, Database $dbForConsole): void + protected function enqueueResources(Connection $queue, Database $dbForConsole): void { $timerStart = \microtime(true); $time = DateTime::now(); @@ -65,12 +66,9 @@ class ScheduleFunctions extends ScheduleBase } foreach ($delayedExecutions as $delay => $scheduleKeys) { - \go(function () use ($delay, $scheduleKeys, $pools) { + \go(function () use ($delay, $scheduleKeys, $queue) { \sleep($delay); // in seconds - $queue = $pools->get('queue')->pop(); - $connection = $queue->getResource(); - foreach ($scheduleKeys as $scheduleKey) { // Ensure schedule was not deleted if (!\array_key_exists($scheduleKey, $this->schedules)) { @@ -79,7 +77,7 @@ class ScheduleFunctions extends ScheduleBase $schedule = $this->schedules[$scheduleKey]; - $queueForFunctions = new Func($connection); + $queueForFunctions = new Func($queue); $queueForFunctions ->setType('schedule') @@ -89,8 +87,6 @@ class ScheduleFunctions extends ScheduleBase ->setProject($schedule['project']) ->trigger(); } - - $queue->reclaim(); }); } diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 167f1282ed..cd136cf67d 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -5,6 +5,7 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Messaging; use Utopia\Database\Database; use Utopia\Pools\Group; +use Utopia\Queue\Connection; class ScheduleMessages extends ScheduleBase { @@ -21,7 +22,7 @@ class ScheduleMessages extends ScheduleBase return 'message'; } - protected function enqueueResources(Group $pools, Database $dbForConsole): void + protected function enqueueResources(Connection $queue, Database $dbForConsole): void { foreach ($this->schedules as $schedule) { if (!$schedule['active']) { @@ -35,10 +36,9 @@ class ScheduleMessages extends ScheduleBase continue; } - \go(function () use ($schedule, $pools, $dbForConsole) { - $queue = $pools->get('queue')->pop(); - $connection = $queue->getResource(); - $queueForMessaging = new Messaging($connection); + \go(function () use ($schedule, $queue, $dbForConsole) { + + $queueForMessaging = new Messaging($queue); $queueForMessaging ->setType(MESSAGE_SEND_TYPE_EXTERNAL) @@ -51,8 +51,6 @@ class ScheduleMessages extends ScheduleBase $schedule['$id'], ); - $queue->reclaim(); - unset($this->schedules[$schedule['$internalId']]); }); } From 0de1e649588ff7472d5bbbe9fee13084ce53bf2a Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 24 Sep 2024 12:41:14 +0300 Subject: [PATCH 027/144] debug --- src/Appwrite/Platform/Workers/Certificates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 7a4ce1ef0b..2261912551 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -174,7 +174,7 @@ class Certificates extends Action $logs = 'Certificate successfully generated.'; $certificate->setAttribute('logs', \mb_strcut($logs, 0, 1000000));// Limit to 1MB - + var_dump($certificate); // Give certificates to Traefik $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); From e4d554689f220969fd4b181c05d8d9b4a0cd8b09 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 29 Sep 2024 17:35:27 +0300 Subject: [PATCH 028/144] debug --- app/controllers/general.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 2273e802bb..3e1d77aad5 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -1006,7 +1006,9 @@ App::get('/.well-known/acme-challenge/*') ->action(function (Request $request, Response $response) { $uriChunks = \explode('/', $request->getURI()); $token = $uriChunks[\count($uriChunks) - 1]; - + var_dump('Appwrite acme-challenge'); + var_dump($request->getURI()); + var_dump($token); $validator = new Text(100, allowList: [ ...Text::NUMBERS, ...Text::ALPHABET_LOWER, From 08e5ed6a8a62da5b072b6cb16fc31e68089d4946 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 29 Sep 2024 17:37:56 +0300 Subject: [PATCH 029/144] debug --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 26b8c3a7a3..b55b0102a5 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.5-rc1", + "utopia-php/database": "0.53.*", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", From 8f6151a575d57a2f86e400fb32e3543b126031a9 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 6 Oct 2024 18:56:39 +0300 Subject: [PATCH 030/144] updates --- app/init.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/init.php b/app/init.php index 9ca874aafc..a10bdd6896 100644 --- a/app/init.php +++ b/app/init.php @@ -90,10 +90,6 @@ use Utopia\Validator\Range; use Utopia\Validator\URL; use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub as VcsGitHub; -use Appwrite\Messaging\Adapter\Realtime; -use Appwrite\Utopia\Request; - - const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; From 6b429c9da9c43baf8f22ee00b34f11082d045c8b Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 6 Oct 2024 18:59:22 +0300 Subject: [PATCH 031/144] updates --- app/controllers/general.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 7cb971a228..8261356d89 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -1010,9 +1010,6 @@ App::get('/.well-known/acme-challenge/*') ->action(function (Request $request, Response $response) { $uriChunks = \explode('/', $request->getURI()); $token = $uriChunks[\count($uriChunks) - 1]; - var_dump('Appwrite acme-challenge'); - var_dump($request->getURI()); - var_dump($token); $validator = new Text(100, allowList: [ ...Text::NUMBERS, ...Text::ALPHABET_LOWER, From 0cce55565a611feccbc1101671ceaae0b4b4d7be Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 6 Oct 2024 20:16:00 +0300 Subject: [PATCH 032/144] updates --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 3c48977a7c..275fd9dbb9 100644 --- a/composer.lock +++ b/composer.lock @@ -1624,16 +1624,16 @@ }, { "name": "utopia-php/cli", - "version": "0.15.0", + "version": "0.15.1", "source": { "type": "git", "url": "https://github.com/utopia-php/cli.git", - "reference": "ccb7c8125ffe0254fef8f25744bfa376eb7bd0ea" + "reference": "d69bbe51a6a94dc4e5bcdd542b5938038b985a65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cli/zipball/ccb7c8125ffe0254fef8f25744bfa376eb7bd0ea", - "reference": "ccb7c8125ffe0254fef8f25744bfa376eb7bd0ea", + "url": "https://api.github.com/repos/utopia-php/cli/zipball/d69bbe51a6a94dc4e5bcdd542b5938038b985a65", + "reference": "d69bbe51a6a94dc4e5bcdd542b5938038b985a65", "shasum": "" }, "require": { @@ -1667,9 +1667,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cli/issues", - "source": "https://github.com/utopia-php/cli/tree/0.15.0" + "source": "https://github.com/utopia-php/cli/tree/0.15.1" }, - "time": "2023-03-01T05:55:14+00:00" + "time": "2024-10-04T13:55:36+00:00" }, { "name": "utopia-php/config", From 5850caff3590fab61fb34bb7f9b0fe4b0475b115 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 7 Oct 2024 11:25:52 +0300 Subject: [PATCH 033/144] debug --- app/controllers/api/projects.php | 14 ++++++++++++++ app/controllers/general.php | 7 +++++++ app/controllers/shared/api.php | 20 ++++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 8073af85b0..a0785131fc 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -88,7 +88,11 @@ App::post('/v1/projects') ->inject('hooks') ->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForConsole, Cache $cache, Group $pools, Hooks $hooks) { + $ctime = time(); + var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before getDocument('teams')"); $team = $dbForConsole->getDocument('teams', $teamId); + $diff = time() - $ctime; + var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After getDocument('teams') : " . $diff . " sec"); if ($team->isEmpty()) { throw new Exception(Exception::TEAM_NOT_FOUND); @@ -154,6 +158,9 @@ App::post('/v1/projects') } try { + + $ctime = time(); + var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createDocument('projects')"); $project = $dbForConsole->createDocument('projects', new Document([ '$id' => $projectId, '$permissions' => [ @@ -187,6 +194,9 @@ App::post('/v1/projects') 'search' => implode(' ', [$projectId, $name]), 'database' => $dsn, ])); + + $diff = time() - $ctime; + var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createDocument('projects') : " . $diff . " sec"); } catch (Duplicate) { throw new Exception(Exception::PROJECT_ALREADY_EXISTS); } @@ -238,7 +248,11 @@ App::post('/v1/projects') }, $collection['indexes']); try { + $ctime = time(); + var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createCollection('".$key."')"); $dbForProject->createCollection($key, $attributes, $indexes); + $diff = time() - $ctime; + var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createCollection('".$key."') : " . $diff . " sec"); } catch (Duplicate) { // Collection already exists } diff --git a/app/controllers/general.php b/app/controllers/general.php index 8261356d89..4e84a88c34 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -460,6 +460,10 @@ App::init() /* * Appwrite Router */ + + + $ctime = time(); + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before general first init hook"); $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain @@ -661,6 +665,9 @@ App::init() ) { throw new AppwriteException(AppwriteException::GENERAL_UNKNOWN_ORIGIN, $originValidator->getDescription()); } + + $diff = time() - $ctime; + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After general first init hook : " . $diff . " sec"); }); App::options() diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 13ffbdbb67..fb06e24e77 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -162,6 +162,9 @@ App::init() ->inject('mode') ->inject('team') ->action(function (App $utopia, Request $request, Database $dbForConsole, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team) { + $ctime = time(); + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first init hook"); + $route = $utopia->getRoute(); if ($project->isEmpty()) { @@ -344,6 +347,8 @@ App::init() throw new Exception(Exception::USER_MORE_FACTORS_REQUIRED); } } + $diff = time() - $ctime; + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first init hook : " . $diff . " sec"); }); App::init() @@ -363,7 +368,8 @@ App::init() ->inject('dbForProject') ->inject('mode') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Usage $queueForUsage, Database $dbForProject, string $mode) use ($databaseListener) { - + $ctime = time(); + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second init hook"); $route = $utopia->getRoute(); if ( @@ -521,6 +527,8 @@ App::init() ; } } + $diff = time() - $ctime; + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second init hook : " . $diff . " sec"); }); App::init() @@ -551,6 +559,8 @@ App::shutdown() ->inject('project') ->inject('dbForProject') ->action(function (App $utopia, Request $request, Response $response, Document $project, Database $dbForProject) { + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first shutdown hook"); + $route = $utopia->getRoute(); $sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS_DEFAULT; $session = $response->getPayload(); $userId = $session['userId'] ?? ''; @@ -575,6 +585,8 @@ App::shutdown() } $dbForProject->purgeCachedDocument('users', $userId); + $diff = time() - $ctime; + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first shutdown hook : " . $diff . " sec"); }); App::shutdown() @@ -597,7 +609,9 @@ App::shutdown() ->inject('dbForConsole') ->inject('realtimeConnection') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole, callable $realtimeConnection) use ($parseLabel) { - + $ctime = time(); + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second shutdown hook"); + $route = $utopia->getRoute(); $responsePayload = $response->getPayload(); if (!empty($queueForEvents->getEvent())) { @@ -800,6 +814,8 @@ App::shutdown() } } } + $diff = time() - $ctime; + var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second shutdown hook : " . $diff . " sec"); }); App::init() From 1cd3e691611eb134fc8ad804c2598efefb868605 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 7 Oct 2024 11:42:14 +0300 Subject: [PATCH 034/144] debug --- app/controllers/api/projects.php | 12 ++++++------ app/controllers/general.php | 4 ++-- app/controllers/shared/api.php | 15 ++++++++------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index a0785131fc..2ddac1394d 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -88,10 +88,10 @@ App::post('/v1/projects') ->inject('hooks') ->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForConsole, Cache $cache, Group $pools, Hooks $hooks) { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before getDocument('teams')"); $team = $dbForConsole->getDocument('teams', $teamId); - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After getDocument('teams') : " . $diff . " sec"); if ($team->isEmpty()) { @@ -159,7 +159,7 @@ App::post('/v1/projects') try { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createDocument('projects')"); $project = $dbForConsole->createDocument('projects', new Document([ '$id' => $projectId, @@ -195,7 +195,7 @@ App::post('/v1/projects') 'database' => $dsn, ])); - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createDocument('projects') : " . $diff . " sec"); } catch (Duplicate) { throw new Exception(Exception::PROJECT_ALREADY_EXISTS); @@ -248,10 +248,10 @@ App::post('/v1/projects') }, $collection['indexes']); try { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createCollection('".$key."')"); $dbForProject->createCollection($key, $attributes, $indexes); - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createCollection('".$key."') : " . $diff . " sec"); } catch (Duplicate) { // Collection already exists diff --git a/app/controllers/general.php b/app/controllers/general.php index 4e84a88c34..b2d4ad69a1 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -462,7 +462,7 @@ App::init() */ - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before general first init hook"); $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); @@ -666,7 +666,7 @@ App::init() throw new AppwriteException(AppwriteException::GENERAL_UNKNOWN_ORIGIN, $originValidator->getDescription()); } - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After general first init hook : " . $diff . " sec"); }); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index fb06e24e77..f4b38f1eb4 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -162,7 +162,7 @@ App::init() ->inject('mode') ->inject('team') ->action(function (App $utopia, Request $request, Database $dbForConsole, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team) { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first init hook"); $route = $utopia->getRoute(); @@ -347,7 +347,7 @@ App::init() throw new Exception(Exception::USER_MORE_FACTORS_REQUIRED); } } - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first init hook : " . $diff . " sec"); }); @@ -368,7 +368,7 @@ App::init() ->inject('dbForProject') ->inject('mode') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Usage $queueForUsage, Database $dbForProject, string $mode) use ($databaseListener) { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second init hook"); $route = $utopia->getRoute(); @@ -527,7 +527,7 @@ App::init() ; } } - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second init hook : " . $diff . " sec"); }); @@ -559,6 +559,7 @@ App::shutdown() ->inject('project') ->inject('dbForProject') ->action(function (App $utopia, Request $request, Response $response, Document $project, Database $dbForProject) { + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first shutdown hook"); $route = $utopia->getRoute(); $sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS_DEFAULT; @@ -585,7 +586,7 @@ App::shutdown() } $dbForProject->purgeCachedDocument('users', $userId); - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first shutdown hook : " . $diff . " sec"); }); @@ -609,7 +610,7 @@ App::shutdown() ->inject('dbForConsole') ->inject('realtimeConnection') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole, callable $realtimeConnection) use ($parseLabel) { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second shutdown hook"); $route = $utopia->getRoute(); $responsePayload = $response->getPayload(); @@ -814,7 +815,7 @@ App::shutdown() } } } - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second shutdown hook : " . $diff . " sec"); }); From d2c66894fd04f550de68a7b74d72cd34c75e689c Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 7 Oct 2024 17:56:08 +0300 Subject: [PATCH 035/144] debug --- app/controllers/api/projects.php | 12 ++++++------ app/controllers/general.php | 4 ++-- app/controllers/shared/api.php | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 2ddac1394d..31b713da9a 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -89,10 +89,10 @@ App::post('/v1/projects') ->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForConsole, Cache $cache, Group $pools, Hooks $hooks) { $ctime = \microtime(true); - var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before getDocument('teams')"); + var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - Before getDocument('teams')"); $team = $dbForConsole->getDocument('teams', $teamId); $diff = \microtime(true) - $ctime; - var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After getDocument('teams') : " . $diff . " sec"); + var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - After getDocument('teams') : " . $diff . " sec"); if ($team->isEmpty()) { throw new Exception(Exception::TEAM_NOT_FOUND); @@ -160,7 +160,7 @@ App::post('/v1/projects') try { $ctime = \microtime(true); - var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createDocument('projects')"); + var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - Before createDocument('projects')"); $project = $dbForConsole->createDocument('projects', new Document([ '$id' => $projectId, '$permissions' => [ @@ -196,7 +196,7 @@ App::post('/v1/projects') ])); $diff = \microtime(true) - $ctime; - var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createDocument('projects') : " . $diff . " sec"); + var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - After createDocument('projects') : " . $diff . " sec"); } catch (Duplicate) { throw new Exception(Exception::PROJECT_ALREADY_EXISTS); } @@ -249,10 +249,10 @@ App::post('/v1/projects') try { $ctime = \microtime(true); - var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createCollection('".$key."')"); + var_dump($request->getURI() ." [".$region."|".System::getEnv('_APP_REGION')."] - Before createCollection('".$key."')"); $dbForProject->createCollection($key, $attributes, $indexes); $diff = \microtime(true) - $ctime; - var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createCollection('".$key."') : " . $diff . " sec"); + var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - After createCollection('".$key."') : " . $diff . " sec"); } catch (Duplicate) { // Collection already exists } diff --git a/app/controllers/general.php b/app/controllers/general.php index b2d4ad69a1..1ed164c1e8 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -463,7 +463,7 @@ App::init() $ctime = \microtime(true); - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before general first init hook"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before general first init hook"); $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain @@ -667,7 +667,7 @@ App::init() } $diff = \microtime(true) - $ctime; - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After general first init hook : " . $diff . " sec"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After general first init hook : " . $diff . " sec"); }); App::options() diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index f4b38f1eb4..0290f7786f 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -163,7 +163,7 @@ App::init() ->inject('team') ->action(function (App $utopia, Request $request, Database $dbForConsole, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team) { $ctime = \microtime(true); - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first init hook"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first init hook"); $route = $utopia->getRoute(); @@ -348,7 +348,7 @@ App::init() } } $diff = \microtime(true) - $ctime; - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first init hook : " . $diff . " sec"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first init hook : " . $diff . " sec"); }); App::init() @@ -369,7 +369,7 @@ App::init() ->inject('mode') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Usage $queueForUsage, Database $dbForProject, string $mode) use ($databaseListener) { $ctime = \microtime(true); - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second init hook"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second init hook"); $route = $utopia->getRoute(); if ( @@ -528,7 +528,7 @@ App::init() } } $diff = \microtime(true) - $ctime; - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second init hook : " . $diff . " sec"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second init hook : " . $diff . " sec"); }); App::init() @@ -560,7 +560,7 @@ App::shutdown() ->inject('dbForProject') ->action(function (App $utopia, Request $request, Response $response, Document $project, Database $dbForProject) { $ctime = \microtime(true); - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first shutdown hook"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first shutdown hook"); $route = $utopia->getRoute(); $sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS_DEFAULT; $session = $response->getPayload(); @@ -587,7 +587,7 @@ App::shutdown() $dbForProject->purgeCachedDocument('users', $userId); $diff = \microtime(true) - $ctime; - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first shutdown hook : " . $diff . " sec"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first shutdown hook : " . $diff . " sec"); }); App::shutdown() @@ -611,7 +611,7 @@ App::shutdown() ->inject('realtimeConnection') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole, callable $realtimeConnection) use ($parseLabel) { $ctime = \microtime(true); - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second shutdown hook"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second shutdown hook"); $route = $utopia->getRoute(); $responsePayload = $response->getPayload(); @@ -816,7 +816,7 @@ App::shutdown() } } $diff = \microtime(true) - $ctime; - var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second shutdown hook : " . $diff . " sec"); + var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second shutdown hook : " . $diff . " sec"); }); App::init() From 7d7b2c7544f376aa20ce7e4ffceaf7e7c7340bde Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 8 Oct 2024 21:51:43 +0300 Subject: [PATCH 036/144] debug --- app/controllers/api/projects.php | 13 ------------- app/controllers/general.php | 7 +------ app/controllers/shared/api.php | 16 ---------------- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 31b713da9a..b950ca81fe 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -88,11 +88,7 @@ App::post('/v1/projects') ->inject('hooks') ->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForConsole, Cache $cache, Group $pools, Hooks $hooks) { - $ctime = \microtime(true); - var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - Before getDocument('teams')"); $team = $dbForConsole->getDocument('teams', $teamId); - $diff = \microtime(true) - $ctime; - var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - After getDocument('teams') : " . $diff . " sec"); if ($team->isEmpty()) { throw new Exception(Exception::TEAM_NOT_FOUND); @@ -158,9 +154,6 @@ App::post('/v1/projects') } try { - - $ctime = \microtime(true); - var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - Before createDocument('projects')"); $project = $dbForConsole->createDocument('projects', new Document([ '$id' => $projectId, '$permissions' => [ @@ -195,8 +188,6 @@ App::post('/v1/projects') 'database' => $dsn, ])); - $diff = \microtime(true) - $ctime; - var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - After createDocument('projects') : " . $diff . " sec"); } catch (Duplicate) { throw new Exception(Exception::PROJECT_ALREADY_EXISTS); } @@ -248,11 +239,7 @@ App::post('/v1/projects') }, $collection['indexes']); try { - $ctime = \microtime(true); - var_dump($request->getURI() ." [".$region."|".System::getEnv('_APP_REGION')."] - Before createCollection('".$key."')"); $dbForProject->createCollection($key, $attributes, $indexes); - $diff = \microtime(true) - $ctime; - var_dump($request->getURI() . " [".$region."|".System::getEnv('_APP_REGION')."] - After createCollection('".$key."') : " . $diff . " sec"); } catch (Duplicate) { // Collection already exists } diff --git a/app/controllers/general.php b/app/controllers/general.php index 1ed164c1e8..971881c60d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -461,10 +461,7 @@ App::init() * Appwrite Router */ - - $ctime = \microtime(true); - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before general first init hook"); - $host = $request->getHostname() ?? ''; + $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain if ($host !== $mainDomain) { @@ -666,8 +663,6 @@ App::init() throw new AppwriteException(AppwriteException::GENERAL_UNKNOWN_ORIGIN, $originValidator->getDescription()); } - $diff = \microtime(true) - $ctime; - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After general first init hook : " . $diff . " sec"); }); App::options() diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 0290f7786f..c5e4f516d6 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -162,8 +162,6 @@ App::init() ->inject('mode') ->inject('team') ->action(function (App $utopia, Request $request, Database $dbForConsole, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team) { - $ctime = \microtime(true); - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first init hook"); $route = $utopia->getRoute(); @@ -347,8 +345,6 @@ App::init() throw new Exception(Exception::USER_MORE_FACTORS_REQUIRED); } } - $diff = \microtime(true) - $ctime; - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first init hook : " . $diff . " sec"); }); App::init() @@ -368,8 +364,6 @@ App::init() ->inject('dbForProject') ->inject('mode') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Usage $queueForUsage, Database $dbForProject, string $mode) use ($databaseListener) { - $ctime = \microtime(true); - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second init hook"); $route = $utopia->getRoute(); if ( @@ -527,8 +521,6 @@ App::init() ; } } - $diff = \microtime(true) - $ctime; - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second init hook : " . $diff . " sec"); }); App::init() @@ -559,8 +551,6 @@ App::shutdown() ->inject('project') ->inject('dbForProject') ->action(function (App $utopia, Request $request, Response $response, Document $project, Database $dbForProject) { - $ctime = \microtime(true); - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first shutdown hook"); $route = $utopia->getRoute(); $sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS_DEFAULT; $session = $response->getPayload(); @@ -586,8 +576,6 @@ App::shutdown() } $dbForProject->purgeCachedDocument('users', $userId); - $diff = \microtime(true) - $ctime; - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first shutdown hook : " . $diff . " sec"); }); App::shutdown() @@ -610,8 +598,6 @@ App::shutdown() ->inject('dbForConsole') ->inject('realtimeConnection') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole, callable $realtimeConnection) use ($parseLabel) { - $ctime = \microtime(true); - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second shutdown hook"); $route = $utopia->getRoute(); $responsePayload = $response->getPayload(); @@ -815,8 +801,6 @@ App::shutdown() } } } - $diff = \microtime(true) - $ctime; - var_dump($request->getURI() . " [".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second shutdown hook : " . $diff . " sec"); }); App::init() From 16fe23244b4b1d726751daa425cda6a22078ec84 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 9 Oct 2024 20:13:28 +0300 Subject: [PATCH 037/144] builds metric reduce --- app/controllers/shared/api.php | 8 +++++- composer.lock | 48 +++++++++++++++++----------------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index c5e4f516d6..9631d9b09d 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -469,7 +469,6 @@ App::init() ); $timestamp = 60 * 60 * 24 * 30; $data = $cache->load($key, $timestamp); - if (!empty($data) && !$cacheLog->isEmpty()) { $parts = explode('/', $cacheLog->getAttribute('resourceType')); $type = $parts[0] ?? null; @@ -712,9 +711,13 @@ App::shutdown() * Cache label */ $useCache = $route->getLabel('cache', false); + var_dump('$useCache='); + var_dump($useCache); if ($useCache) { $resource = $resourceType = null; $data = $response->getPayload(); + var_dump('!empty($data[payload]='); + var_dump(!empty($data['payload'])); if (!empty($data['payload'])) { $pattern = $route->getLabel('cache.resource', null); if (!empty($pattern)) { @@ -731,7 +734,10 @@ App::shutdown() $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); $accessedAt = $cacheLog->getAttribute('accessedAt', ''); $now = DateTime::now(); + var_dump('$cacheLog='); + var_dump($cacheLog); if ($cacheLog->isEmpty()) { + var_dump('inserting.....'); Authorization::skip(fn () => $dbForProject->createDocument('cache', new Document([ '$id' => $key, 'resource' => $resource, diff --git a/composer.lock b/composer.lock index 275fd9dbb9..c7ef692624 100644 --- a/composer.lock +++ b/composer.lock @@ -2124,16 +2124,16 @@ }, { "name": "utopia-php/messaging", - "version": "0.12.0", + "version": "0.12.1", "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "6e466d3511981291843c6ebf9ce3f44fc75e37b0" + "reference": "b9dfafb5efc1d12cbee01d03dc98853ef026e35b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/6e466d3511981291843c6ebf9ce3f44fc75e37b0", - "reference": "6e466d3511981291843c6ebf9ce3f44fc75e37b0", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/b9dfafb5efc1d12cbee01d03dc98853ef026e35b", + "reference": "b9dfafb5efc1d12cbee01d03dc98853ef026e35b", "shasum": "" }, "require": { @@ -2169,22 +2169,22 @@ ], "support": { "issues": "https://github.com/utopia-php/messaging/issues", - "source": "https://github.com/utopia-php/messaging/tree/0.12.0" + "source": "https://github.com/utopia-php/messaging/tree/0.12.1" }, - "time": "2024-05-30T14:58:25+00:00" + "time": "2024-10-09T08:17:07+00:00" }, { "name": "utopia-php/migration", - "version": "0.6.4", + "version": "0.6.7", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "e43ef283f1386084e11d1ffe093fb6c6d7a6ce6c" + "reference": "9f2d1afc2acf2b6cdc5088ad4becbab131df0f2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/e43ef283f1386084e11d1ffe093fb6c6d7a6ce6c", - "reference": "e43ef283f1386084e11d1ffe093fb6c6d7a6ce6c", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/9f2d1afc2acf2b6cdc5088ad4becbab131df0f2a", + "reference": "9f2d1afc2acf2b6cdc5088ad4becbab131df0f2a", "shasum": "" }, "require": { @@ -2225,9 +2225,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.4" + "source": "https://github.com/utopia-php/migration/tree/0.6.7" }, - "time": "2024-10-02T15:16:36+00:00" + "time": "2024-10-09T10:21:25+00:00" }, { "name": "utopia-php/mongo", @@ -3002,16 +3002,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.22", + "version": "0.39.23", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "bdbb1607527550e67283ff0533522d1410c2c0df" + "reference": "0acceabb7593c9c07c5db85a84a5ebac60896763" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/bdbb1607527550e67283ff0533522d1410c2c0df", - "reference": "bdbb1607527550e67283ff0533522d1410c2c0df", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/0acceabb7593c9c07c5db85a84a5ebac60896763", + "reference": "0acceabb7593c9c07c5db85a84a5ebac60896763", "shasum": "" }, "require": { @@ -3047,9 +3047,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.39.22" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.23" }, - "time": "2024-10-01T16:16:26+00:00" + "time": "2024-10-08T00:38:57+00:00" }, { "name": "doctrine/annotations", @@ -3573,16 +3573,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.3.0", + "version": "v5.3.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "3abf7425cd284141dc5d8d14a9ee444de3345d1a" + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3abf7425cd284141dc5d8d14a9ee444de3345d1a", - "reference": "3abf7425cd284141dc5d8d14a9ee444de3345d1a", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", "shasum": "" }, "require": { @@ -3625,9 +3625,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" }, - "time": "2024-09-29T13:56:26+00:00" + "time": "2024-10-08T18:51:32+00:00" }, { "name": "phar-io/manifest", From cffbc77d053a1041e414ef0a1abe97a0f91c04d7 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 10 Oct 2024 11:05:54 +0300 Subject: [PATCH 038/144] update file preview cache save flow --- app/controllers/shared/api.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 9631d9b09d..229d2e3588 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -461,6 +461,7 @@ App::init() ->on(Database::EVENT_DOCUMENT_DELETE, 'calculate-usage', fn ($event, $document) => $databaseListener($event, $document, $project, $queueForUsage, $dbForProject)); $useCache = $route->getLabel('cache', false); + if ($useCache) { $key = md5($request->getURI() . '*' . implode('*', $request->getParams()) . '*' . APP_CACHE_BUSTER); $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); @@ -711,13 +712,11 @@ App::shutdown() * Cache label */ $useCache = $route->getLabel('cache', false); - var_dump('$useCache='); - var_dump($useCache); + if ($useCache) { $resource = $resourceType = null; $data = $response->getPayload(); - var_dump('!empty($data[payload]='); - var_dump(!empty($data['payload'])); + if (!empty($data['payload'])) { $pattern = $route->getLabel('cache.resource', null); if (!empty($pattern)) { @@ -734,10 +733,8 @@ App::shutdown() $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); $accessedAt = $cacheLog->getAttribute('accessedAt', ''); $now = DateTime::now(); - var_dump('$cacheLog='); - var_dump($cacheLog); + if ($cacheLog->isEmpty()) { - var_dump('inserting.....'); Authorization::skip(fn () => $dbForProject->createDocument('cache', new Document([ '$id' => $key, 'resource' => $resource, @@ -751,17 +748,17 @@ App::shutdown() Authorization::skip(fn () => $dbForProject->updateDocument('cache', $cacheLog->getId(), $cacheLog)); } - if ($signature !== $cacheLog->getAttribute('signature')) { - $cache = new Cache( - new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()) - ); + $cache = new Cache( + new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()) + ); + $timestamp = 60 * 60 * 24 * 30; + $data = $cache->load($key, $timestamp); + if ($signature !== $cacheLog->getAttribute('signature') || empty($data)) { $cache->save($key, $data['payload']); } } } - - if ($project->getId() !== 'console') { if (!Auth::isPrivilegedUser(Authorization::getRoles())) { $fileSize = 0; From d477de256a2b99e9494efcf39472655a3aef3f77 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 10 Oct 2024 11:40:13 +0300 Subject: [PATCH 039/144] update file preview cache save flow --- app/controllers/shared/api.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 229d2e3588..1aee73d021 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -751,6 +751,7 @@ App::shutdown() $cache = new Cache( new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()) ); + $timestamp = 60 * 60 * 24 * 30; $data = $cache->load($key, $timestamp); if ($signature !== $cacheLog->getAttribute('signature') || empty($data)) { From 74ecc20751ab58e38787fb6a44dcfbdb0d79a091 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 10 Oct 2024 12:07:53 +0300 Subject: [PATCH 040/144] debug --- app/controllers/shared/api.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 1aee73d021..43a86b837d 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -754,6 +754,8 @@ App::shutdown() $timestamp = 60 * 60 * 24 * 30; $data = $cache->load($key, $timestamp); + var_dump($cacheLog->getAttribute('signature')); + var_dump(empty($data)); if ($signature !== $cacheLog->getAttribute('signature') || empty($data)) { $cache->save($key, $data['payload']); } From 7921bd62d9313dccaac0206bdb2dcad6921033b7 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 10 Oct 2024 12:11:35 +0300 Subject: [PATCH 041/144] debug --- app/controllers/shared/api.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 43a86b837d..8ddb9c61f7 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -753,10 +753,8 @@ App::shutdown() ); $timestamp = 60 * 60 * 24 * 30; - $data = $cache->load($key, $timestamp); - var_dump($cacheLog->getAttribute('signature')); - var_dump(empty($data)); - if ($signature !== $cacheLog->getAttribute('signature') || empty($data)) { + $cacheFile = $cache->load($key, $timestamp); + if ($signature !== $cacheLog->getAttribute('signature') || empty($cacheFile)) { $cache->save($key, $data['payload']); } } From 36e4c8c399c3c61a5ea03a14ad9854b466f68e3e Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 10 Oct 2024 12:53:45 +0300 Subject: [PATCH 042/144] debug --- app/controllers/shared/api.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 8ddb9c61f7..952ab8b49e 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -471,6 +471,7 @@ App::init() $timestamp = 60 * 60 * 24 * 30; $data = $cache->load($key, $timestamp); if (!empty($data) && !$cacheLog->isEmpty()) { + $timerStart = \microtime(true); $parts = explode('/', $cacheLog->getAttribute('resourceType')); $type = $parts[0] ?? null; @@ -506,7 +507,8 @@ App::init() throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); } } - + $timerEnd= \microtime(true); + var_dump('Timer: ' . $timerEnd - $timerStart); $response ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $timestamp) . ' GMT') ->addHeader('X-Appwrite-Cache', 'hit') From 051d6e580cb16b0f27b7a16b442815425d687cb3 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 13 Oct 2024 18:15:11 +0300 Subject: [PATCH 043/144] debug --- app/worker.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/worker.php b/app/worker.php index df8a5b8c7a..ee3349f1c8 100644 --- a/app/worker.php +++ b/app/worker.php @@ -268,9 +268,9 @@ Server::setResource('deviceForBuilds', function (Document $project, $connectionS return getDevice(APP_STORAGE_BUILDS.'/app-'.$project->getId(), $connectionString); }, ['project', 'connectionString']); -Server::setResource('deviceForCache', function (Document $project, $connectionString) { - return getDevice(APP_STORAGE_CACHE.'/app-'.$project->getId(), $connectionString); -}, ['project', 'connectionString']); +Server::setResource('deviceForCache', function (Document $project) { + return getDevice(APP_STORAGE_CACHE.'/app-'.$project->getId()); +}, ['project']); Server::setResource('realtimeConnection',function ($pools) { return function () use ($pools) { From add6a60af47572423ee3b538edf96f49eddb5996 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 14 Oct 2024 14:33:53 +1300 Subject: [PATCH 044/144] Remove redundant files --- app/init.php | 2 -- src/Appwrite/Utopia/Database/Database.php | 42 ----------------------- src/Appwrite/Utopia/Database/Mirror.php | 16 --------- 3 files changed, 60 deletions(-) delete mode 100644 src/Appwrite/Utopia/Database/Database.php delete mode 100644 src/Appwrite/Utopia/Database/Mirror.php diff --git a/app/init.php b/app/init.php index 913f26efba..ff6ccd8d35 100644 --- a/app/init.php +++ b/app/init.php @@ -285,8 +285,6 @@ const METRIC_NETWORK_REQUESTS = 'network.requests'; const METRIC_NETWORK_INBOUND = 'network.inbound'; const METRIC_NETWORK_OUTBOUND = 'network.outbound'; -const METRIC_MESSAGES = 'messages'; - $register = new Registry(); App::setMode(System::getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION)); diff --git a/src/Appwrite/Utopia/Database/Database.php b/src/Appwrite/Utopia/Database/Database.php deleted file mode 100644 index 3e0a59b394..0000000000 --- a/src/Appwrite/Utopia/Database/Database.php +++ /dev/null @@ -1,42 +0,0 @@ -getMethod() === Query::TYPE_SEARCH || $query->getMethod() === Query::TYPE_EQUAL) { - $attribute = $query->getAttribute(); - - if ($collectionCache === null) { - $collectionCache = $this->silent(fn () => $this->getCollection($collection)); - } - - $attributeMetadata = null; - foreach ($collectionCache->getAttribute('attributes', []) as $attributeDocument) { - if ($attributeDocument->getId() === $attribute) { - $attributeMetadata = $attributeDocument; - break; - } - } - - if ($attributeMetadata !== null) { - if ($attributeMetadata->getAttribute('array', false) === true) { - $query->setMethod(Query::TYPE_CONTAINS); - } - } - } - } - } catch (\Throwable $err) { - // Ignore error, to not do any harm - } - - return parent::find($collection, $queries); - } -} diff --git a/src/Appwrite/Utopia/Database/Mirror.php b/src/Appwrite/Utopia/Database/Mirror.php deleted file mode 100644 index 2ad1665958..0000000000 --- a/src/Appwrite/Utopia/Database/Mirror.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Mon, 14 Oct 2024 14:50:56 +1300 Subject: [PATCH 045/144] Allow shared tables V1 and V2 --- app/controllers/api/projects.php | 50 +++++++++++++++----------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index f20b79a00a..e80e2888b2 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -118,6 +118,10 @@ App::post('/v1/projects') $projectId = ($projectId == 'unique()') ? ID::unique() : $projectId; + if ($projectId === 'console') { + throw new Exception(Exception::PROJECT_RESERVED_PROJECT, "'console' is a reserved project."); + } + $databases = Config::getParam('pools-database', []); $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); @@ -128,10 +132,6 @@ App::post('/v1/projects') $dsn = $databases[array_rand($databases)]; } - if ($projectId === 'console') { - throw new Exception(Exception::PROJECT_RESERVED_PROJECT, "'console' is a reserved project."); - } - // TODO: Temporary until all projects are using shared tables. $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); @@ -194,11 +194,13 @@ App::post('/v1/projects') $adapter = $pools->get($dsn->getHost())->pop()->getResource(); $dbForProject = new Database($adapter, $cache); $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); + $globalCollections = !\in_array($dsn->getHost(), $sharedTablesV1); if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject ->setSharedTables(true) - ->setTenant(null) + ->setTenant($globalCollections ? null : $project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); } else { $dbForProject @@ -207,38 +209,32 @@ App::post('/v1/projects') ->setNamespace('_' . $project->getInternalId()); } + $create = true; + try { $dbForProject->create(); } catch (Duplicate) { - // Database already exists + $create = false; } - $audit = new Audit($dbForProject); - $audit->setup(); + if ($create || !$globalCollections) { + $audit = new Audit($dbForProject); + $audit->setup(); - $abuse = new TimeLimit('', 0, 1, $dbForProject); - $abuse->setup(); + $abuse = new TimeLimit('', 0, 1, $dbForProject); + $abuse->setup(); - /** @var array $collections */ - $collections = Config::getParam('collections', [])['projects'] ?? []; + /** @var array $collections */ + $collections = Config::getParam('collections', [])['projects'] ?? []; - foreach ($collections as $key => $collection) { - if (($collection['$collection'] ?? '') !== Database::METADATA) { - continue; - } + foreach ($collections as $key => $collection) { + if (($collection['$collection'] ?? '') !== Database::METADATA) { + continue; + } - $attributes = \array_map(function (array $attribute) { - return new Document($attribute); - }, $collection['attributes']); - - $indexes = \array_map(function (array $index) { - return new Document($index); - }, $collection['indexes']); - - try { + $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); + $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); $dbForProject->createCollection($key, $attributes, $indexes); - } catch (Duplicate) { - // Collection already exists } } From 78b9be2e78e348d1b0c547cb09dc01d333bc4789 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 14 Oct 2024 14:55:18 +1300 Subject: [PATCH 046/144] Lint --- app/controllers/api/databases.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 381ecfb3fc..e1ad74acc6 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -3,7 +3,6 @@ use Appwrite\Auth\Auth; use Appwrite\Detector\Detector; use Appwrite\Event\Database as EventDatabase; -use Appwrite\Event\Delete; use Appwrite\Event\Event; use Appwrite\Event\Usage; use Appwrite\Extend\Exception; @@ -15,7 +14,6 @@ use Appwrite\Utopia\Database\Validator\Queries\Databases; use Appwrite\Utopia\Database\Validator\Queries\Indexes; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; -use Couchbase\QueryException; use MaxMind\Db\Reader; use Utopia\App; use Utopia\Audit\Audit; From d0481482ae5b45a7fe8dd7de26189e5d86b72a7a Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 14 Oct 2024 10:36:52 +0300 Subject: [PATCH 047/144] debug --- app/init.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/init.php b/app/init.php index a10bdd6896..041dfad75b 100644 --- a/app/init.php +++ b/app/init.php @@ -945,7 +945,9 @@ $register->set('pools', function () { }, default => throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Invalid scheme'), }; - + var_dump($poolSize); + $poolSize = $poolSize/8; + var_dump($poolSize); $pool = new Pool($name, $poolSize, function () use ($type, $resource, $dsn) { // Get Adapter switch ($type) { From 1373d62c5215e369fca4f2f36ba16bd2e41af1ef Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 14 Oct 2024 16:18:01 +0300 Subject: [PATCH 048/144] debug --- app/init.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/init.php b/app/init.php index 041dfad75b..a10bdd6896 100644 --- a/app/init.php +++ b/app/init.php @@ -945,9 +945,7 @@ $register->set('pools', function () { }, default => throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Invalid scheme'), }; - var_dump($poolSize); - $poolSize = $poolSize/8; - var_dump($poolSize); + $pool = new Pool($name, $poolSize, function () use ($type, $resource, $dsn) { // Get Adapter switch ($type) { From a80b9219276c5cc86e09e73855b13fa6aa4f50b1 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 14 Oct 2024 16:21:23 +0300 Subject: [PATCH 049/144] debug --- app/controllers/shared/api.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 952ab8b49e..27504d33ab 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -507,8 +507,7 @@ App::init() throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); } } - $timerEnd= \microtime(true); - var_dump('Timer: ' . $timerEnd - $timerStart); + $response ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $timestamp) . ' GMT') ->addHeader('X-Appwrite-Cache', 'hit') From 36d2b84301dbd6f0775d727c95c470aff43338e9 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 15 Oct 2024 18:09:54 +1300 Subject: [PATCH 050/144] Update lock --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 815adf390a..e7ef5316ce 100644 --- a/composer.lock +++ b/composer.lock @@ -1728,12 +1728,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "790b870631a8061a335619d2ccb163ccc05235cf" + "reference": "8bb5793b6e252e2ec840b7056d74e65767c287e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/790b870631a8061a335619d2ccb163ccc05235cf", - "reference": "790b870631a8061a335619d2ccb163ccc05235cf", + "url": "https://api.github.com/repos/utopia-php/database/zipball/8bb5793b6e252e2ec840b7056d74e65767c287e8", + "reference": "8bb5793b6e252e2ec840b7056d74e65767c287e8", "shasum": "" }, "require": { @@ -1776,7 +1776,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-10-14T00:54:06+00:00" + "time": "2024-10-15T03:52:20+00:00" }, { "name": "utopia-php/domains", From 30bd25d134575bbdbf868cc9d963e98027ef8d61 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 15 Oct 2024 20:19:19 +1300 Subject: [PATCH 051/144] Update lock --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index e7ef5316ce..e0c0b534b4 100644 --- a/composer.lock +++ b/composer.lock @@ -1728,12 +1728,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "8bb5793b6e252e2ec840b7056d74e65767c287e8" + "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/8bb5793b6e252e2ec840b7056d74e65767c287e8", - "reference": "8bb5793b6e252e2ec840b7056d74e65767c287e8", + "url": "https://api.github.com/repos/utopia-php/database/zipball/efd0f4e8fb5d158486aec0e6fea9561facf0daad", + "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad", "shasum": "" }, "require": { @@ -1776,7 +1776,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-10-15T03:52:20+00:00" + "time": "2024-10-15T05:50:09+00:00" }, { "name": "utopia-php/domains", From f189c41421ece0f4ae20bfe082316bd2ea977013 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 18 Oct 2024 21:39:16 +0200 Subject: [PATCH 052/144] temp: custom cloudflare hostnames --- .../Platform/Workers/Certificates.php | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 58dc1dd28a..062e9a1bb9 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -22,6 +22,7 @@ use Utopia\Database\Exception\Structure; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Domains\Domain; +use Utopia\Fetch\Client; use Utopia\Locale\Locale; use Utopia\Logger\Log; use Utopia\Platform\Action; @@ -43,16 +44,18 @@ class Certificates extends Action $this ->desc('Certificates worker') ->inject('message') + ->inject('project') ->inject('dbForConsole') ->inject('queueForMails') ->inject('queueForEvents') ->inject('queueForFunctions') ->inject('log') - ->callback(fn (Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log) => $this->action($message, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log)); + ->callback(fn (Message $message, Document $project, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log) => $this->action($message, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log)); } /** * @param Message $message + * @param Document $project * @param Database $dbForConsole * @param Mail $queueForMails * @param Event $queueForEvents @@ -62,7 +65,7 @@ class Certificates extends Action * @throws Throwable * @throws \Utopia\Database\Exception */ - public function action(Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log): void + public function action(Message $message, Document $project, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log): void { $payload = $message->getPayload() ?? []; @@ -162,6 +165,8 @@ class Certificates extends Action $logs = 'Certificate successfully generated.'; $certificate->setAttribute('logs', \mb_strcut($logs, 0, 1000000));// Limit to 1MB + // TEMP: add custom hostnames to cloudflare + $this->addCustomHostnameToRegistrar($project, $domain->get()); // Give certificates to Traefik $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); @@ -197,6 +202,34 @@ class Certificates extends Action } } + /** + * Add custom hostname to Cloudflare registrar + * + * @param Document $project + * @param string $hostname + * @return void + * @throws Exception + */ + private function addCustomHostnameToRegistrar(Document $project, string $hostname): void + { + $client = new Client(); + $client + ->addHeader('Content-Type', Client::CONTENT_TYPE_APPLICATION_JSON) + ->addHeader('Authorization', 'Bearer ' . System::getEnv('_APP_SYSTEM_CLOUDFLARE_TOKEN')); + + $response = $client->fetch("https://api.cloudflare.com/client/v4/zones/zone_id/custom_hostnames", Client::METHOD_POST, [ + 'custom_metadata' => [ + 'projectId' => $project->getId(), + 'organizationId' => $project->getAttribute('teamId') + ], + 'hostname' => $hostname + ]); + + if ($response->getStatusCode() !== 400) { + throw new Exception('Failed to add custom hostname to Cloudflare: ' . $response->getBody()); + } + } + /** * Save certificate data into database. * From ccbde6c470e9f909ee477eb031c05cf32e6a7350 Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Fri, 18 Oct 2024 21:44:36 +0200 Subject: [PATCH 053/144] fix zone id --- src/Appwrite/Platform/Workers/Certificates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 062e9a1bb9..a182b37192 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -217,7 +217,7 @@ class Certificates extends Action ->addHeader('Content-Type', Client::CONTENT_TYPE_APPLICATION_JSON) ->addHeader('Authorization', 'Bearer ' . System::getEnv('_APP_SYSTEM_CLOUDFLARE_TOKEN')); - $response = $client->fetch("https://api.cloudflare.com/client/v4/zones/zone_id/custom_hostnames", Client::METHOD_POST, [ + $response = $client->fetch("https://api.cloudflare.com/client/v4/zones/b2d0e62383d3c0f6299efab107af2c7a/custom_hostnames", Client::METHOD_POST, [ 'custom_metadata' => [ 'projectId' => $project->getId(), 'organizationId' => $project->getAttribute('teamId') @@ -225,7 +225,7 @@ class Certificates extends Action 'hostname' => $hostname ]); - if ($response->getStatusCode() !== 400) { + if ($response->getStatusCode() !== 200) { throw new Exception('Failed to add custom hostname to Cloudflare: ' . $response->getBody()); } } From f21b1c87a6c9f8de0760f3e78008dac47a13ce3a Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Fri, 18 Oct 2024 22:07:36 +0200 Subject: [PATCH 054/144] fix missing ssl object --- src/Appwrite/Platform/Workers/Certificates.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index a182b37192..897de6c935 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -222,7 +222,12 @@ class Certificates extends Action 'projectId' => $project->getId(), 'organizationId' => $project->getAttribute('teamId') ], - 'hostname' => $hostname + 'hostname' => $hostname, + 'ssl' => [ + "method" => "http", + "type" => "dv", + "wildcard" => false + ] ]); if ($response->getStatusCode() !== 200) { From 687252b15b879d37e012558601a7c7c937144bcf Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Fri, 18 Oct 2024 22:21:53 +0200 Subject: [PATCH 055/144] fix adding custom hostname & error logging --- src/Appwrite/Platform/Workers/Certificates.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 897de6c935..03cdd596e1 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -50,7 +50,7 @@ class Certificates extends Action ->inject('queueForEvents') ->inject('queueForFunctions') ->inject('log') - ->callback(fn (Message $message, Document $project, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log) => $this->action($message, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log)); + ->callback(fn (Message $message, Document $project, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log) => $this->action($message, $project, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log)); } /** @@ -79,7 +79,7 @@ class Certificates extends Action $log->addTag('domain', $domain->get()); - $this->execute($domain, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log, $skipRenewCheck); + $this->execute($domain, $project, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log, $skipRenewCheck); } /** @@ -93,7 +93,7 @@ class Certificates extends Action * @throws Throwable * @throws \Utopia\Database\Exception */ - private function execute(Domain $domain, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, bool $skipRenewCheck = false): void + private function execute(Domain $domain, Document $project, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, bool $skipRenewCheck = false): void { /** * 1. Read arguments and validate domain @@ -165,8 +165,12 @@ class Certificates extends Action $logs = 'Certificate successfully generated.'; $certificate->setAttribute('logs', \mb_strcut($logs, 0, 1000000));// Limit to 1MB - // TEMP: add custom hostnames to cloudflare - $this->addCustomHostnameToRegistrar($project, $domain->get()); + try { + // TEMP: add custom hostnames to cloudflare + $this->addCustomHostnameToRegistrar($project, $domain->get()); + } catch (Exception $e) { + Console::error('Failed to add custom hostname to registrar: ' . $e->getMessage()); + } // Give certificates to Traefik $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); From f4d456fa4cf0618765535996b35a6a6f57b649c3 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 18 Oct 2024 20:52:29 +0000 Subject: [PATCH 056/144] chore: updat certs logic --- src/Appwrite/Platform/Workers/Certificates.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 03cdd596e1..1f57daaa42 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -158,9 +158,13 @@ class Certificates extends Action // Prepare folder name for certbot. Using this helps prevent miss-match in LetsEncrypt configuration when renewing certificate $folder = ID::unique(); - // Generate certificate files using Let's Encrypt - $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); - + try { + // Generate certificate files using Let's Encrypt + $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); + } catch (\Throwable $th) { + Console::error('Failed to generate Lets Encrypt certificate'); + } + // Command succeeded, store all data into document $logs = 'Certificate successfully generated.'; $certificate->setAttribute('logs', \mb_strcut($logs, 0, 1000000));// Limit to 1MB @@ -168,8 +172,8 @@ class Certificates extends Action try { // TEMP: add custom hostnames to cloudflare $this->addCustomHostnameToRegistrar($project, $domain->get()); - } catch (Exception $e) { - Console::error('Failed to add custom hostname to registrar: ' . $e->getMessage()); + } catch (\Throwable $th) { + Console::error('Failed to add custom hostname to registrar: ' . $th->getMessage()); } // Give certificates to Traefik From 28b02a4ba863c6640b6f8379074181e693e5ad51 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 18 Oct 2024 21:18:20 +0000 Subject: [PATCH 057/144] chore: fix bug --- src/Appwrite/Platform/Workers/Certificates.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 1f57daaa42..cec0706a79 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -160,7 +160,10 @@ class Certificates extends Action try { // Generate certificate files using Let's Encrypt - $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); + $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); + + // Give certificates to Traefik + $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); } catch (\Throwable $th) { Console::error('Failed to generate Lets Encrypt certificate'); } @@ -176,9 +179,6 @@ class Certificates extends Action Console::error('Failed to add custom hostname to registrar: ' . $th->getMessage()); } - // Give certificates to Traefik - $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); - // Update certificate info stored in database $certificate->setAttribute('renewDate', $this->getRenewDate($domain->get())); $certificate->setAttribute('attempts', 0); @@ -222,13 +222,13 @@ class Certificates extends Action { $client = new Client(); $client - ->addHeader('Content-Type', Client::CONTENT_TYPE_APPLICATION_JSON) + ->addHeader('content-type', Client::CONTENT_TYPE_APPLICATION_JSON) ->addHeader('Authorization', 'Bearer ' . System::getEnv('_APP_SYSTEM_CLOUDFLARE_TOKEN')); $response = $client->fetch("https://api.cloudflare.com/client/v4/zones/b2d0e62383d3c0f6299efab107af2c7a/custom_hostnames", Client::METHOD_POST, [ 'custom_metadata' => [ - 'projectId' => $project->getId(), - 'organizationId' => $project->getAttribute('teamId') + 'projectId' => $project->getId() ?? '', + 'organizationId' => $project->getAttribute('teamId', '') ], 'hostname' => $hostname, 'ssl' => [ From 6fe7d92feae728b89473a2af2b4fceddce8030ee Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 18 Oct 2024 22:32:03 +0000 Subject: [PATCH 058/144] chore: update cert generation --- src/Appwrite/Platform/Workers/Certificates.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index cec0706a79..cf38401351 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -226,10 +226,6 @@ class Certificates extends Action ->addHeader('Authorization', 'Bearer ' . System::getEnv('_APP_SYSTEM_CLOUDFLARE_TOKEN')); $response = $client->fetch("https://api.cloudflare.com/client/v4/zones/b2d0e62383d3c0f6299efab107af2c7a/custom_hostnames", Client::METHOD_POST, [ - 'custom_metadata' => [ - 'projectId' => $project->getId() ?? '', - 'organizationId' => $project->getAttribute('teamId', '') - ], 'hostname' => $hostname, 'ssl' => [ "method" => "http", From 5ea83b882788f9893039e4b9ea4f9b771d4b7892 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 18 Oct 2024 23:45:42 +0000 Subject: [PATCH 059/144] chore: update cert generation --- src/Appwrite/Platform/Workers/Certificates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index cf38401351..ddb5130838 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -234,7 +234,7 @@ class Certificates extends Action ] ]); - if ($response->getStatusCode() !== 200) { + if ($response->getStatusCode() !== 201) { throw new Exception('Failed to add custom hostname to Cloudflare: ' . $response->getBody()); } } From 5451a9cd23c2394e26f574f6a68645fd6d3b04ee Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 20 Oct 2024 10:56:44 +0300 Subject: [PATCH 060/144] sync against feat-migration --- app/controllers/api/databases.php | 8 +-- app/controllers/api/projects.php | 62 ++++++++--------- app/http.php | 5 +- app/init.php | 12 ++-- app/realtime.php | 6 +- app/worker.php | 18 +++-- composer.json | 2 +- composer.lock | 76 ++++++++++++--------- src/Appwrite/Platform/Workers/Databases.php | 45 ++---------- src/Appwrite/Platform/Workers/Deletes.php | 32 ++------- src/Appwrite/Utopia/Response/Model/Func.php | 2 +- 11 files changed, 117 insertions(+), 151 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 9c110647af..e1ad74acc6 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -3,7 +3,6 @@ use Appwrite\Auth\Auth; use Appwrite\Detector\Detector; use Appwrite\Event\Database as EventDatabase; -use Appwrite\Event\Delete; use Appwrite\Event\Event; use Appwrite\Event\Usage; use Appwrite\Extend\Exception; @@ -3656,11 +3655,10 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/documents/:docu ->inject('requestTimestamp') ->inject('response') ->inject('dbForProject') - ->inject('queueForDeletes') ->inject('queueForEvents') ->inject('queueForUsage') ->inject('mode') - ->action(function (string $databaseId, string $collectionId, string $documentId, ?\DateTime $requestTimestamp, Response $response, Database $dbForProject, Delete $queueForDeletes, Event $queueForEvents, Usage $queueForUsage, string $mode) { + ->action(function (string $databaseId, string $collectionId, string $documentId, ?\DateTime $requestTimestamp, Response $response, Database $dbForProject, Event $queueForEvents, Usage $queueForUsage, string $mode) { $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); $isAPIKey = Auth::isAppUser(Authorization::getRoles()); @@ -3733,10 +3731,6 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/documents/:docu ) ); - $queueForDeletes - ->setType(DELETE_TYPE_AUDIT) - ->setDocument($document); - $queueForEvents ->setParam('databaseId', $databaseId) ->setParam('collectionId', $collection->getId()) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index b950ca81fe..77eed678d9 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -118,6 +118,10 @@ App::post('/v1/projects') $projectId = ($projectId == 'unique()') ? ID::unique() : $projectId; + if ($projectId === 'console') { + throw new Exception(Exception::PROJECT_RESERVED_PROJECT, "'console' is a reserved project."); + } + $databases = Config::getParam('pools-database', []); $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); @@ -135,14 +139,10 @@ App::post('/v1/projects') $dsn = $databases[array_rand($databases)]; } - if ($projectId === 'console') { - throw new Exception(Exception::PROJECT_RESERVED_PROJECT, "'console' is a reserved project."); - } - // TODO: Temporary until all projects are using shared tables. - $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if (in_array($dsn, $sharedTablesKeys)) { + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + if (\in_array($dsn, $sharedTables)) { $schema = 'appwrite'; $database = 'appwrite'; $namespace = System::getEnv('_APP_DATABASE_SHARED_NAMESPACE', ''); @@ -187,7 +187,6 @@ App::post('/v1/projects') 'search' => implode(' ', [$projectId, $name]), 'database' => $dsn, ])); - } catch (Duplicate) { throw new Exception(Exception::PROJECT_ALREADY_EXISTS); } @@ -201,11 +200,14 @@ App::post('/v1/projects') $adapter = $pools->get($dsn->getHost())->pop()->getResource(); $dbForProject = new Database($adapter, $cache); + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); + $globalCollections = !\in_array($dsn->getHost(), $sharedTablesV1); - $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if (in_array($dsn->getHost(), $sharedTablesKeys)) { $dbForProject + if (\in_array($dsn->getHost(), $sharedTables)) { + $dbForProject ->setSharedTables(true) - ->setTenant($project->getInternalId()) + ->setTenant($globalCollections ? null : $project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); } else { $dbForProject @@ -214,34 +216,32 @@ App::post('/v1/projects') ->setNamespace('_' . $project->getInternalId()); } - $dbForProject->create(); + $create = true; - $audit = new Audit($dbForProject); - $audit->setup(); + try { + $dbForProject->create(); + } catch (Duplicate) { + $create = false; + } - $abuse = new TimeLimit('', 0, 1, $dbForProject); - $abuse->setup(); + if ($create || !$globalCollections) { + $audit = new Audit($dbForProject); + $audit->setup(); - /** @var array $collections */ - $collections = Config::getParam('collections', [])['projects'] ?? []; + $abuse = new TimeLimit('', 0, 1, $dbForProject); + $abuse->setup(); - foreach ($collections as $key => $collection) { - if (($collection['$collection'] ?? '') !== Database::METADATA) { - continue; - } + /** @var array $collections */ + $collections = Config::getParam('collections', [])['projects'] ?? []; - $attributes = \array_map(function (array $attribute) { - return new Document($attribute); - }, $collection['attributes']); + foreach ($collections as $key => $collection) { + if (($collection['$collection'] ?? '') !== Database::METADATA) { + continue; + } - $indexes = \array_map(function (array $index) { - return new Document($index); - }, $collection['indexes']); - - try { + $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); + $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); $dbForProject->createCollection($key, $attributes, $indexes); - } catch (Duplicate) { - // Collection already exists } } diff --git a/app/http.php b/app/http.php index bec772c770..9754263046 100644 --- a/app/http.php +++ b/app/http.php @@ -16,6 +16,7 @@ use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Exception\Duplicate; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; @@ -92,7 +93,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg try { Console::success('[Setup] - Creating database: appwrite...'); $dbForConsole->create(); - } catch (\Throwable $e) { + } catch (Duplicate) { Console::success('[Setup] - Skip: metadata table already exists'); } @@ -224,7 +225,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg }); }); -$http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) use ($register) { +$http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) use ($register) { App::setResource('swooleRequest', fn () => $swooleRequest); App::setResource('swooleResponse', fn () => $swooleResponse); diff --git a/app/init.php b/app/init.php index a10bdd6896..e18b5102b4 100644 --- a/app/init.php +++ b/app/init.php @@ -1407,8 +1407,10 @@ App::setResource('dbForProject', function (Group $pools, Database $dbForConsole, $dsn = new DSN('mysql://' . $project->getAttribute('database')); } - $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { + $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -1460,8 +1462,10 @@ App::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, ->setMetadata('project', $project->getId()) ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS); - $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { + $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); diff --git a/app/realtime.php b/app/realtime.php index 00633b7f9c..6ca4639f85 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -92,8 +92,10 @@ if (!function_exists('getProjectDB')) { $database = new Database($adapter, getCache()); - $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { + $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); diff --git a/app/worker.php b/app/worker.php index ee3349f1c8..0e76338e64 100644 --- a/app/worker.php +++ b/app/worker.php @@ -93,8 +93,10 @@ Server::setResource('dbForProject', function (Cache $cache, Registry $register, $dsn = new DSN('mysql://' . $project->getAttribute('database')); } - $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { + $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -126,8 +128,10 @@ Server::setResource('getProjectDB', function (Group $pools, Database $dbForConso if (isset($databases[$dsn->getHost()])) { $database = $databases[$dsn->getHost()]; - $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { + $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); @@ -150,8 +154,10 @@ Server::setResource('getProjectDB', function (Group $pools, Database $dbForConso $databases[$dsn->getHost()] = $database; - $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); - if (in_array($dsn->getHost(), $sharedTablesKeys)) { $database + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + + if (\in_array($dsn->getHost(), $sharedTables)) { + $database ->setSharedTables(true) ->setTenant($project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); diff --git a/composer.json b/composer.json index c176d383f3..10f2a12492 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.5", + "utopia-php/database": "dev-feat-migrations as 0.53.6", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index c7ef692624..bc2b3fb5ca 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": "1884e3a2966762c4a955842426b64f6c", + "content-hash": "5cb1524d4677594554ab26d05b3c38e6", "packages": [ { "name": "adhocore/jwt", @@ -1724,16 +1724,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.5", + "version": "dev-feat-migrations", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "689ba22063bf46def385da8695ba7a921e81e38d" + "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/689ba22063bf46def385da8695ba7a921e81e38d", - "reference": "689ba22063bf46def385da8695ba7a921e81e38d", + "url": "https://api.github.com/repos/utopia-php/database/zipball/efd0f4e8fb5d158486aec0e6fea9561facf0daad", + "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad", "shasum": "" }, "require": { @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.5" + "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-09-24T08:43:10+00:00" + "time": "2024-10-15T05:50:09+00:00" }, { "name": "utopia-php/domains", @@ -2070,16 +2070,16 @@ }, { "name": "utopia-php/logger", - "version": "0.6.1", + "version": "0.6.2", "source": { "type": "git", "url": "https://github.com/utopia-php/logger.git", - "reference": "7e8ff512c6f04577aba1df67c7b9628971946f9c" + "reference": "25b5bd2ad8bb51292f76332faa7034644fd0941d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/logger/zipball/7e8ff512c6f04577aba1df67c7b9628971946f9c", - "reference": "7e8ff512c6f04577aba1df67c7b9628971946f9c", + "url": "https://api.github.com/repos/utopia-php/logger/zipball/25b5bd2ad8bb51292f76332faa7034644fd0941d", + "reference": "25b5bd2ad8bb51292f76332faa7034644fd0941d", "shasum": "" }, "require": { @@ -2118,9 +2118,9 @@ ], "support": { "issues": "https://github.com/utopia-php/logger/issues", - "source": "https://github.com/utopia-php/logger/tree/0.6.1" + "source": "https://github.com/utopia-php/logger/tree/0.6.2" }, - "time": "2024-09-20T14:02:12+00:00" + "time": "2024-10-14T16:02:49+00:00" }, { "name": "utopia-php/messaging", @@ -2175,16 +2175,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.7", + "version": "0.6.9", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "9f2d1afc2acf2b6cdc5088ad4becbab131df0f2a" + "reference": "ce97cdf2ca82e7cec78e2ed484ef2c71ebe8744b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/9f2d1afc2acf2b6cdc5088ad4becbab131df0f2a", - "reference": "9f2d1afc2acf2b6cdc5088ad4becbab131df0f2a", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/ce97cdf2ca82e7cec78e2ed484ef2c71ebe8744b", + "reference": "ce97cdf2ca82e7cec78e2ed484ef2c71ebe8744b", "shasum": "" }, "require": { @@ -2225,9 +2225,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.7" + "source": "https://github.com/utopia-php/migration/tree/0.6.9" }, - "time": "2024-10-09T10:21:25+00:00" + "time": "2024-10-16T08:33:21+00:00" }, { "name": "utopia-php/mongo", @@ -3002,16 +3002,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.23", + "version": "0.39.24", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "0acceabb7593c9c07c5db85a84a5ebac60896763" + "reference": "412451c87f6ef17e24e9a5cf41721043d74c60c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/0acceabb7593c9c07c5db85a84a5ebac60896763", - "reference": "0acceabb7593c9c07c5db85a84a5ebac60896763", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/412451c87f6ef17e24e9a5cf41721043d74c60c8", + "reference": "412451c87f6ef17e24e9a5cf41721043d74c60c8", "shasum": "" }, "require": { @@ -3047,9 +3047,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.39.23" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.24" }, - "time": "2024-10-08T00:38:57+00:00" + "time": "2024-10-09T19:13:27+00:00" }, { "name": "doctrine/annotations", @@ -3847,6 +3847,7 @@ "issues": "https://github.com/phpbench/dom/issues", "source": "https://github.com/phpbench/dom/tree/0.3.3" }, + "abandoned": true, "time": "2023-03-06T23:46:57+00:00" }, { @@ -4194,16 +4195,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.32.0", + "version": "1.33.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4" + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", - "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", "shasum": "" }, "require": { @@ -4235,9 +4236,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.32.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" }, - "time": "2024-09-26T07:23:32+00:00" + "time": "2024-10-13T11:25:22+00:00" }, { "name": "phpunit/php-code-coverage", @@ -7002,9 +7003,18 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-feat-migrations", + "alias": "0.53.6", + "alias_normalized": "0.53.6.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 7f3132dcb0..c9023318c7 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -5,7 +5,6 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Event; use Appwrite\Messaging\Adapter\Realtime; use Exception; -use Utopia\Audit\Audit; use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\Document; @@ -53,12 +52,7 @@ class Databases extends Action * @param Log $log * @param callable $realtimeConnection * @return void - * @throws Authorization - * @throws Conflict - * @throws DatabaseException - * @throws Restricted - * @throws Structure - * @throws Exception + * @throws \Exception */ public function action(Message $message, Database $dbForConsole, Database $dbForProject, Log $log, callable $realtimeConnection): void { @@ -106,9 +100,7 @@ class Databases extends Action * @return void * @throws Authorization * @throws Conflict - * @throws DatabaseException - * @throws Structure - * @throws Exception + * @throws \Exception */ private function createAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void { @@ -151,7 +143,6 @@ class Databases extends Action $options = $attribute->getAttribute('options', []); $project = $dbForConsole->getDocument('projects', $projectId); - try { switch ($type) { case Database::VAR_RELATIONSHIP: @@ -232,12 +223,9 @@ class Databases extends Action * @return void * @throws Authorization * @throws Conflict - * @throws DatabaseException - * @throws Restricted - * @throws Structure - * @throws Exception - */ - private function deleteAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void + * @throws \Exception + **/ + private function deleteAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); @@ -390,9 +378,8 @@ class Databases extends Action * @return void * @throws Authorization * @throws Conflict - * @throws DatabaseException * @throws Structure - * @throws Exception + * @throws DatabaseException */ private function createIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void { @@ -453,9 +440,8 @@ class Databases extends Action * @return void * @throws Authorization * @throws Conflict - * @throws DatabaseException * @throws Structure - * @throws Exception + * @throws DatabaseException */ private function deleteIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void { @@ -516,8 +502,6 @@ class Databases extends Action }); $dbForProject->deleteCollection('database_' . $database->getInternalId()); - - $this->deleteAuditLogsByResource('database/' . $database->getId(), $project, $dbForProject); } /** @@ -573,23 +557,8 @@ class Databases extends Action Query::equal('databaseInternalId', [$databaseInternalId]), Query::equal('collectionInternalId', [$collectionInternalId]) ], $dbForProject); - - $this->deleteAuditLogsByResource('database/' . $databaseId . '/collection/' . $collectionId, $project, $dbForProject); } - /** - * @param string $resource - * @param Document $project - * @param Database $dbForProject - * @return void - * @throws Exception - */ - protected function deleteAuditLogsByResource(string $resource, Document $project, Database $dbForProject): void - { - $this->deleteByGroup(Audit::COLLECTION, [ - Query::equal('resource', [$resource]) - ], $dbForProject); - } /** * @param string $collection collectionID diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 9ea8133cf5..700a480065 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -119,10 +119,6 @@ class Deletes extends Action if (!$project->isEmpty()) { $this->deleteAuditLogs($project, $getProjectDB, $auditRetention); } - - if (!$document->isEmpty()) { - $this->deleteAuditLogsByResource($getProjectDB, 'document/' . $document->getId(), $project); - } break; case DELETE_TYPE_ABUSE: $this->deleteAbuseLogs($project, $getProjectDB, $abuseRetention); @@ -498,13 +494,13 @@ class Deletes extends Action ]; $limit = \count($projectCollectionIds) + 25; - $sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); while (true) { $collections = $dbForProject->listCollections($limit); foreach ($collections as $collection) { - if (! in_array($dsn->getHost(), $sharedTablesKeys) || !\in_array($collection->getId(), $projectCollectionIds)) { + if (\in_array($dsn->getHost(), $sharedTables) || !\in_array($collection->getId(), $projectCollectionIds)) { try { $dbForProject->deleteCollection($collection->getId()); } catch (Throwable $e) { @@ -516,12 +512,13 @@ class Deletes extends Action if (!preg_match('/^_\d+_\d+$/', $collection->getId())) { throw $e; } - } } else { + } + } else { $this->deleteByGroup($collection->getId(), [], database: $dbForProject); } } - if (in_array($dsn->getHost(), $sharedTablesKeys)) { + if (\in_array($dsn->getHost(), $sharedTables)) { $collectionsIds = \array_map(fn ($collection) => $collection->getId(), $collections); if (empty(\array_diff($collectionsIds, $projectCollectionIds))) { @@ -575,8 +572,7 @@ class Deletes extends Action ], $dbForConsole); // Delete metadata table - System::getEnv('_APP_DATABASE_SHARED_TABLES', ''); - if (! in_array($dsn, $sharedTablesKeys)) { + if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject->deleteCollection('_metadata'); } else { $this->deleteByGroup('_metadata', [], $dbForProject); @@ -734,22 +730,6 @@ class Deletes extends Action } } - /** - * @param callable $getProjectDB - * @param string $resource - * @param Document $project - * @return void - * @throws Exception - */ - private function deleteAuditLogsByResource(callable $getProjectDB, string $resource, Document $project): void - { - $dbForProject = $getProjectDB($project); - - $this->deleteByGroup(Audit::COLLECTION, [ - Query::equal('resource', [$resource]) - ], $dbForProject); - } - /** * @param callable $getProjectDB * @param Device $deviceForFunctions diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index f4ff214d0b..ab2d7ba051 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -94,7 +94,7 @@ class Func extends Model ]) ->addRule('schedule', [ 'type' => self::TYPE_STRING, - 'description' => 'Function execution schedult in CRON format.', + 'description' => 'Function execution schedule in CRON format.', 'default' => '', 'example' => '5 4 * * *', ]) From 9bfab69062dc3e3eb01506aa4bbe535999c02fb9 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 20 Oct 2024 15:33:10 +0300 Subject: [PATCH 061/144] debug --- app/controllers/api/projects.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 77eed678d9..a21aa37be6 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -203,7 +203,6 @@ App::post('/v1/projects') $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); $globalCollections = !\in_array($dsn->getHost(), $sharedTablesV1); - if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject ->setSharedTables(true) @@ -224,6 +223,11 @@ App::post('/v1/projects') $create = false; } + var_dump($dsn->getHost()); + var_dump($sharedTablesV1); + var_dump($globalCollections); + var_dump($create); + if ($create || !$globalCollections) { $audit = new Audit($dbForProject); $audit->setup(); From bcb593e6df8c80501ae182b60daf345c4e61d77b Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 20 Oct 2024 15:56:43 +0300 Subject: [PATCH 062/144] debug --- app/controllers/api/projects.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index a21aa37be6..e3a04f1a50 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -224,6 +224,7 @@ App::post('/v1/projects') } var_dump($dsn->getHost()); + var_dump(in_array($dsn->getHost(), $sharedTablesV1)); var_dump($sharedTablesV1); var_dump($globalCollections); var_dump($create); @@ -242,7 +243,7 @@ App::post('/v1/projects') if (($collection['$collection'] ?? '') !== Database::METADATA) { continue; } - + var_dump('trying to create collection ' . $collection['$collection']); $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); $dbForProject->createCollection($key, $attributes, $indexes); From db244937ffface2dbb4f737a08fb0d5bd71ffe96 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 20 Oct 2024 16:10:14 +0300 Subject: [PATCH 063/144] debug --- app/controllers/api/projects.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index e3a04f1a50..ece3989878 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -223,13 +223,16 @@ App::post('/v1/projects') $create = false; } - var_dump($dsn->getHost()); - var_dump(in_array($dsn->getHost(), $sharedTablesV1)); - var_dump($sharedTablesV1); + //var_dump($dsn->getHost()); + //var_dump(in_array($dsn->getHost(), $sharedTablesV1)); + //var_dump($sharedTablesV1); var_dump($globalCollections); var_dump($create); if ($create || !$globalCollections) { + var_dump('#######'); + var_dump($globalCollections); + var_dump($create); $audit = new Audit($dbForProject); $audit->setup(); From 7ab55e0694c908d37d85b7330f1f0fb852d6c85e Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 20 Oct 2024 16:21:39 +0300 Subject: [PATCH 064/144] debug --- app/controllers/api/projects.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index ece3989878..3427e6d5c1 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -223,9 +223,9 @@ App::post('/v1/projects') $create = false; } - //var_dump($dsn->getHost()); - //var_dump(in_array($dsn->getHost(), $sharedTablesV1)); - //var_dump($sharedTablesV1); + var_dump($dsn->getHost()); + var_dump(in_array($dsn->getHost(), $sharedTablesV1)); + var_dump($sharedTablesV1); var_dump($globalCollections); var_dump($create); From d980711c30bec77e9f9df12e02cedc72f2478c6f Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 20 Oct 2024 16:32:19 +0300 Subject: [PATCH 065/144] debug --- app/controllers/api/projects.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 3427e6d5c1..cf58abb238 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -223,12 +223,6 @@ App::post('/v1/projects') $create = false; } - var_dump($dsn->getHost()); - var_dump(in_array($dsn->getHost(), $sharedTablesV1)); - var_dump($sharedTablesV1); - var_dump($globalCollections); - var_dump($create); - if ($create || !$globalCollections) { var_dump('#######'); var_dump($globalCollections); From c853b6593aebe211358fdedeba6bb66dd83ce680 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 20 Oct 2024 17:22:37 +0300 Subject: [PATCH 066/144] debug --- app/controllers/api/projects.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index cf58abb238..492f27a248 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -223,10 +223,9 @@ App::post('/v1/projects') $create = false; } + var_dump($globalCollections); + var_dump($create); if ($create || !$globalCollections) { - var_dump('#######'); - var_dump($globalCollections); - var_dump($create); $audit = new Audit($dbForProject); $audit->setup(); From b2521cf8a33e19634acc5e46fe0126d651149f69 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 20 Oct 2024 17:36:08 +0300 Subject: [PATCH 067/144] debug --- app/controllers/api/projects.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 492f27a248..9fad64a138 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -206,7 +206,8 @@ App::post('/v1/projects') if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject ->setSharedTables(true) - ->setTenant($globalCollections ? null : $project->getInternalId()) + ->setTenant($project->getInternalId()) + //->setTenant($globalCollections ? null : $project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); } else { $dbForProject @@ -217,15 +218,14 @@ App::post('/v1/projects') $create = true; - try { - $dbForProject->create(); - } catch (Duplicate) { - $create = false; - } + //try { + $dbForProject->create(); + //} catch (Duplicate) { + // $create = false; + //} - var_dump($globalCollections); - var_dump($create); - if ($create || !$globalCollections) { + + //if ($create || !$globalCollections) { $audit = new Audit($dbForProject); $audit->setup(); @@ -239,12 +239,12 @@ App::post('/v1/projects') if (($collection['$collection'] ?? '') !== Database::METADATA) { continue; } - var_dump('trying to create collection ' . $collection['$collection']); + $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); $dbForProject->createCollection($key, $attributes, $indexes); } - } + //} // Hook allowing instant project mirroring during migration // Outside of migration, hook is not registered and has no effect From a37aa5551a45b475ab8ef4b3f738bf427891b71b Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 20 Oct 2024 17:59:39 +0300 Subject: [PATCH 068/144] debug --- composer.json | 2 +- composer.lock | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 10f2a12492..50881bec87 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-migrations as 0.53.6", + "utopia-php/database": "0.53.6", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index bc2b3fb5ca..308fc85ebf 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": "5cb1524d4677594554ab26d05b3c38e6", + "content-hash": "a81b2ddbd465059b986947b63435e2bc", "packages": [ { "name": "adhocore/jwt", @@ -1724,16 +1724,16 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-migrations", + "version": "0.53.6", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad" + "reference": "feddc8e808eaea9a11c65cca3f01683def422f52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/efd0f4e8fb5d158486aec0e6fea9561facf0daad", - "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad", + "url": "https://api.github.com/repos/utopia-php/database/zipball/feddc8e808eaea9a11c65cca3f01683def422f52", + "reference": "feddc8e808eaea9a11c65cca3f01683def422f52", "shasum": "" }, "require": { @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/feat-migrations" + "source": "https://github.com/utopia-php/database/tree/0.53.6" }, - "time": "2024-10-15T05:50:09+00:00" + "time": "2024-10-08T02:18:46+00:00" }, { "name": "utopia-php/domains", @@ -7003,18 +7003,9 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [ - { - "package": "utopia-php/database", - "version": "dev-feat-migrations", - "alias": "0.53.6", - "alias_normalized": "0.53.6.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/database": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From 8743330ad86078e787b4b4a1640bcd400fc2a52b Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 21 Oct 2024 09:59:05 +0300 Subject: [PATCH 069/144] debug --- app/controllers/api/projects.php | 18 +++++++++--------- composer.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 9fad64a138..062756bb21 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -203,11 +203,12 @@ App::post('/v1/projects') $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); $globalCollections = !\in_array($dsn->getHost(), $sharedTablesV1); + if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject ->setSharedTables(true) ->setTenant($project->getInternalId()) - //->setTenant($globalCollections ? null : $project->getInternalId()) + ->setTenant($globalCollections ? null : $project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); } else { $dbForProject @@ -218,14 +219,13 @@ App::post('/v1/projects') $create = true; - //try { - $dbForProject->create(); - //} catch (Duplicate) { - // $create = false; - //} + try { + $dbForProject->create(); + } catch (Duplicate) { + $create = false; + } - - //if ($create || !$globalCollections) { + if ($create || !$globalCollections) { $audit = new Audit($dbForProject); $audit->setup(); @@ -244,7 +244,7 @@ App::post('/v1/projects') $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); $dbForProject->createCollection($key, $attributes, $indexes); } - //} + } // Hook allowing instant project mirroring during migration // Outside of migration, hook is not registered and has no effect diff --git a/composer.json b/composer.json index 50881bec87..10f2a12492 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.6", + "utopia-php/database": "dev-feat-migrations as 0.53.6", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", From 6435fa84af5a52bc4fbabf718cce907d1768c9f7 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 21 Oct 2024 10:00:35 +0300 Subject: [PATCH 070/144] debug --- app/controllers/api/projects.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 062756bb21..7e04ee07b7 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -225,6 +225,11 @@ App::post('/v1/projects') $create = false; } + var_dump('$globalCollections = '); + var_dump($globalCollections); + var_dump('$create = '); + var_dump($create); + if ($create || !$globalCollections) { $audit = new Audit($dbForProject); $audit->setup(); From ba0a495d3cf99464f7247ab05e5f49891f0ab625 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 21 Oct 2024 10:01:32 +0300 Subject: [PATCH 071/144] debug --- composer.lock | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/composer.lock b/composer.lock index 308fc85ebf..bc2b3fb5ca 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": "a81b2ddbd465059b986947b63435e2bc", + "content-hash": "5cb1524d4677594554ab26d05b3c38e6", "packages": [ { "name": "adhocore/jwt", @@ -1724,16 +1724,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.6", + "version": "dev-feat-migrations", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "feddc8e808eaea9a11c65cca3f01683def422f52" + "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/feddc8e808eaea9a11c65cca3f01683def422f52", - "reference": "feddc8e808eaea9a11c65cca3f01683def422f52", + "url": "https://api.github.com/repos/utopia-php/database/zipball/efd0f4e8fb5d158486aec0e6fea9561facf0daad", + "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad", "shasum": "" }, "require": { @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.6" + "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-10-08T02:18:46+00:00" + "time": "2024-10-15T05:50:09+00:00" }, { "name": "utopia-php/domains", @@ -7003,9 +7003,18 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-feat-migrations", + "alias": "0.53.6", + "alias_normalized": "0.53.6.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { From a41b76740047bc0a82e945ef2d4f353287a74b5a Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 21 Oct 2024 10:32:53 +0300 Subject: [PATCH 072/144] debug --- app/controllers/api/projects.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 7e04ee07b7..924057b426 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -225,10 +225,7 @@ App::post('/v1/projects') $create = false; } - var_dump('$globalCollections = '); - var_dump($globalCollections); - var_dump('$create = '); - var_dump($create); + if ($create || !$globalCollections) { $audit = new Audit($dbForProject); @@ -247,7 +244,11 @@ App::post('/v1/projects') $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); - $dbForProject->createCollection($key, $attributes, $indexes); + try { + $dbForProject->createCollection($key, $attributes, $indexes); + } catch (Duplicate) { + // Collection already exists + } } } From d979c0c914c635633411b8585cd9b1ef3045241d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 21 Oct 2024 22:43:47 +1300 Subject: [PATCH 073/144] Create metadata document from outside if duplicate on shared tables V1 --- app/controllers/api/projects.php | 16 +++++++++++++++- composer.lock | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index e80e2888b2..7d8ddd8a79 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -234,7 +234,21 @@ App::post('/v1/projects') $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); - $dbForProject->createCollection($key, $attributes, $indexes); + + try { + $dbForProject->createCollection($key, $attributes, $indexes); + } catch (Duplicate) { + if (!$globalCollections) { + $dbForProject->createDocument(Database::METADATA, new Document([ + '$id' => ID::custom($key), + '$permissions' => [Permission::create(Role::any())], + 'name' => $key, + 'attributes' => $attributes, + 'indexes' => $indexes, + 'documentSecurity' => true + ])); + } + } } } diff --git a/composer.lock b/composer.lock index fdce5e2809..e0c0b534b4 100644 --- a/composer.lock +++ b/composer.lock @@ -7038,5 +7038,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } From 3ff5472543850771bac77e0056bd948e90d1f194 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 21 Oct 2024 18:57:11 +0300 Subject: [PATCH 074/144] sync with feat-migration --- app/controllers/api/projects.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 924057b426..b46302be07 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -207,7 +207,6 @@ App::post('/v1/projects') if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject ->setSharedTables(true) - ->setTenant($project->getInternalId()) ->setTenant($globalCollections ? null : $project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); } else { @@ -225,8 +224,6 @@ App::post('/v1/projects') $create = false; } - - if ($create || !$globalCollections) { $audit = new Audit($dbForProject); $audit->setup(); @@ -247,7 +244,16 @@ App::post('/v1/projects') try { $dbForProject->createCollection($key, $attributes, $indexes); } catch (Duplicate) { - // Collection already exists + if (!$globalCollections) { + $dbForProject->createDocument(Database::METADATA, new Document([ + '$id' => ID::custom($key), + '$permissions' => [Permission::create(Role::any())], + 'name' => $key, + 'attributes' => $attributes, + 'indexes' => $indexes, + 'documentSecurity' => true + ])); + } } } } From e687c64ca02de2e7a13aeffd2a3eec8cbdcfbc03 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 21 Oct 2024 18:58:11 +0300 Subject: [PATCH 075/144] sync with feat-migration --- app/controllers/api/projects.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index b46302be07..b04657e07f 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -241,6 +241,7 @@ App::post('/v1/projects') $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); + try { $dbForProject->createCollection($key, $attributes, $indexes); } catch (Duplicate) { From f8b2878943c68ccecc9e6e77b45520b7a5ea0c69 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 22 Oct 2024 11:09:27 +0300 Subject: [PATCH 076/144] sync with feat-migration --- app/controllers/api/functions.php | 4 ++-- app/controllers/api/messaging.php | 10 +++++----- composer.lock | 20 ++++++++++---------- src/Appwrite/Migration/Version/V19.php | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 5942077ae4..42a8e7f8fa 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -250,7 +250,7 @@ App::post('/v1/functions') $schedule = Authorization::skip( fn () => $dbForConsole->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), // Todo replace with projects region + 'region' => $project->getAttribute('region'), 'resourceType' => 'function', 'resourceId' => $function->getId(), 'resourceInternalId' => $function->getInternalId(), @@ -1928,7 +1928,7 @@ App::post('/v1/functions/:functionId/executions') ]; $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => ScheduleExecutions::getSupportedResource(), 'resourceId' => $execution->getId(), 'resourceInternalId' => $execution->getInternalId(), diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 7da0348a8f..315782775a 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2691,7 +2691,7 @@ App::post('/v1/messaging/messages/email') break; case MessageStatus::SCHEDULED: $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -2807,7 +2807,7 @@ App::post('/v1/messaging/messages/sms') break; case MessageStatus::SCHEDULED: $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -2983,7 +2983,7 @@ App::post('/v1/messaging/messages/push') break; case MessageStatus::SCHEDULED: $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3522,7 +3522,7 @@ App::patch('/v1/messaging/messages/sms/:messageId') if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) { $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3686,7 +3686,7 @@ App::patch('/v1/messaging/messages/push/:messageId') if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) { $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), diff --git a/composer.lock b/composer.lock index bc2b3fb5ca..061f669841 100644 --- a/composer.lock +++ b/composer.lock @@ -1728,12 +1728,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad" + "reference": "5b9462f8abc12c2c7ab2dac99aa6f68aa2e27365" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/efd0f4e8fb5d158486aec0e6fea9561facf0daad", - "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad", + "url": "https://api.github.com/repos/utopia-php/database/zipball/5b9462f8abc12c2c7ab2dac99aa6f68aa2e27365", + "reference": "5b9462f8abc12c2c7ab2dac99aa6f68aa2e27365", "shasum": "" }, "require": { @@ -1776,7 +1776,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-10-15T05:50:09+00:00" + "time": "2024-10-22T08:05:24+00:00" }, { "name": "utopia-php/domains", @@ -2124,16 +2124,16 @@ }, { "name": "utopia-php/messaging", - "version": "0.12.1", + "version": "0.12.2", "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "b9dfafb5efc1d12cbee01d03dc98853ef026e35b" + "reference": "f6790fba1fcee12163d51c65d2c226a7856295d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/b9dfafb5efc1d12cbee01d03dc98853ef026e35b", - "reference": "b9dfafb5efc1d12cbee01d03dc98853ef026e35b", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/f6790fba1fcee12163d51c65d2c226a7856295d9", + "reference": "f6790fba1fcee12163d51c65d2c226a7856295d9", "shasum": "" }, "require": { @@ -2169,9 +2169,9 @@ ], "support": { "issues": "https://github.com/utopia-php/messaging/issues", - "source": "https://github.com/utopia-php/messaging/tree/0.12.1" + "source": "https://github.com/utopia-php/messaging/tree/0.12.2" }, - "time": "2024-10-09T08:17:07+00:00" + "time": "2024-10-22T01:02:20+00:00" }, { "name": "utopia-php/migration", diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index 18234ebdc4..039169f3a6 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -731,7 +731,7 @@ class V19 extends Migration if (empty($document->getAttribute('scheduleId', null))) { $schedule = $this->consoleDB->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), // Todo replace with projects region + 'region' => $project->getAttribute('region'), 'resourceType' => 'function', 'resourceId' => $document->getId(), 'resourceInternalId' => $document->getInternalId(), From a56293e01880c2c7142a63203830bef140e62f9a Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Tue, 22 Oct 2024 11:38:05 +0200 Subject: [PATCH 077/144] chore: replace 'Expires' with 'Cache-Control: private' header to avoid CDN caching --- app/controllers/api/avatars.php | 18 +++++++++--------- app/controllers/api/functions.php | 2 +- app/controllers/api/locale.php | 2 +- app/controllers/api/storage.php | 8 ++++---- app/controllers/shared/api.php | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index fcff3e4179..dadd9da5e3 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -55,7 +55,7 @@ $avatarCallback = function (string $type, string $code, int $width, int $height, $output = (empty($output)) ? $type : $output; $data = $image->output($output, $quality); $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + 60 * 60 * 24 * 30) . ' GMT') + ->addHeader('Cache-Control', 'private, max-age=2592000') // 30 days ->setContentType('image/png') ->file($data); unset($image); @@ -275,7 +275,7 @@ App::get('/v1/avatars/image') $data = $image->output($output, $quality); $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + 60 * 60 * 24 * 30) . ' GMT') + ->addHeader('Cache-Control', 'private, max-age=2592000') // 30 days ->setContentType('image/png') ->file($data); unset($image); @@ -409,7 +409,7 @@ App::get('/v1/avatars/favicon') throw new Exception(Exception::AVATAR_ICON_NOT_FOUND, 'Favicon not found'); } $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + 60 * 60 * 24 * 30) . ' GMT') + ->addHeader('Cache-Control', 'private, max-age=2592000') // 30 days ->setContentType('image/x-icon') ->file($data); } @@ -420,7 +420,7 @@ App::get('/v1/avatars/favicon') $data = $image->output($output, $quality); $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + 60 * 60 * 24 * 30) . ' GMT') + ->addHeader('Cache-Control', 'private, max-age=2592000') // 30 days ->setContentType('image/png') ->file($data); unset($image); @@ -461,7 +461,7 @@ App::get('/v1/avatars/qr') $image->crop((int) $size, (int) $size); $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ->setContentType('image/png') ->send($image->output('png', 9)); }); @@ -544,7 +544,7 @@ App::get('/v1/avatars/initials') $image->compositeImage($punch, Imagick::COMPOSITE_COPYOPACITY, 0, 0); $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ->setContentType('image/png') ->file($image->getImageBlob()); }); @@ -751,7 +751,7 @@ App::get('/v1/cards/cloud') } $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ->setContentType('image/png') ->file($baseImage->getImageBlob()); }); @@ -829,7 +829,7 @@ App::get('/v1/cards/cloud-back') } $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ->setContentType('image/png') ->file($baseImage->getImageBlob()); }); @@ -1219,7 +1219,7 @@ App::get('/v1/cards/cloud-og') } $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ->setContentType('image/png') ->file($baseImage->getImageBlob()); }); diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index c3051ef476..396d2048f2 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -994,7 +994,7 @@ App::get('/v1/functions/:functionId/deployments/:deploymentId/download') $response ->setContentType('application/gzip') - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ->addHeader('X-Peak', \memory_get_peak_usage()) ->addHeader('Content-Disposition', 'attachment; filename="' . $deploymentId . '.tar.gz"'); diff --git a/app/controllers/api/locale.php b/app/controllers/api/locale.php index 2917bc8416..1f042d2239 100644 --- a/app/controllers/api/locale.php +++ b/app/controllers/api/locale.php @@ -63,7 +63,7 @@ App::get('/v1/locale') $response ->addHeader('Cache-Control', 'public, max-age=' . $time) - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ; $response->dynamic(new Document($output), Response::MODEL_LOCALE); }); diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index c3d57e5470..5261f9c89a 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -999,7 +999,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') $contentType = (\array_key_exists($output, $outputs)) ? $outputs[$output] : $outputs['jpg']; $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + 60 * 60 * 24 * 30) . ' GMT') + ->addHeader('Cache-Control', 'private, max-age=2592000') // 30 days ->setContentType($contentType) ->file($data) ; @@ -1062,7 +1062,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download') $response ->setContentType($file->getAttribute('mimeType')) - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ->addHeader('X-Peak', \memory_get_peak_usage()) ->addHeader('Content-Disposition', 'attachment; filename="' . $file->getAttribute('name', '') . '"') ; @@ -1212,7 +1212,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view') ->addHeader('Content-Security-Policy', 'script-src none;') ->addHeader('X-Content-Type-Options', 'nosniff') ->addHeader('Content-Disposition', 'inline; filename="' . $file->getAttribute('name', '') . '"') - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ->addHeader('X-Peak', \memory_get_peak_usage()) ; @@ -1366,7 +1366,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/push') ->addHeader('Content-Security-Policy', 'script-src none;') ->addHeader('X-Content-Type-Options', 'nosniff') ->addHeader('Content-Disposition', 'inline; filename="' . $file->getAttribute('name', '') . '"') - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache + ->addHeader('Cache-Control', 'private, max-age=3888000') // 45 days ->addHeader('X-Peak', \memory_get_peak_usage()); $size = $file->getAttribute('sizeOriginal', 0); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index f0d896c95a..7a5de8af19 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -508,7 +508,7 @@ App::init() } $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $timestamp) . ' GMT') + ->addHeader('Cache-Control', sprintf('private, max-age=%d', $timestamp)) ->addHeader('X-Appwrite-Cache', 'hit') ->setContentType($cacheLog->getAttribute('mimeType')) ->send($data); @@ -516,7 +516,7 @@ App::init() $response ->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate') ->addHeader('Pragma', 'no-cache') - ->addHeader('Expires', 0) + ->addHeader('Expires', '0') ->addHeader('X-Appwrite-Cache', 'miss') ; } From 54555cb3cd702399a52b1e8172232611d29aedcb Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 22 Oct 2024 19:39:57 +0300 Subject: [PATCH 078/144] updates --- app/controllers/api/projects.php | 63 ++++++++++--------- composer.json | 2 +- composer.lock | 39 +++++------- src/Appwrite/Platform/Tasks/ScheduleBase.php | 21 ++++--- .../Platform/Tasks/ScheduleExecutions.php | 10 +-- .../Platform/Tasks/ScheduleFunctions.php | 12 ++-- .../Platform/Tasks/ScheduleMessages.php | 12 ++-- 7 files changed, 83 insertions(+), 76 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index b04657e07f..78f2c56cd8 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -207,7 +207,8 @@ App::post('/v1/projects') if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject ->setSharedTables(true) - ->setTenant($globalCollections ? null : $project->getInternalId()) + ->setTenant($project->getInternalId()) + //->setTenant($globalCollections ? null : $project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); } else { $dbForProject @@ -218,46 +219,50 @@ App::post('/v1/projects') $create = true; - try { + // try { $dbForProject->create(); - } catch (Duplicate) { - $create = false; - } + // } catch (Duplicate) { + // $create = false; + //} - if ($create || !$globalCollections) { - $audit = new Audit($dbForProject); - $audit->setup(); + $audit = new Audit($dbForProject); + $audit->setup(); - $abuse = new TimeLimit('', 0, 1, $dbForProject); - $abuse->setup(); + $abuse = new TimeLimit('', 0, 1, $dbForProject); + $abuse->setup(); - /** @var array $collections */ - $collections = Config::getParam('collections', [])['projects'] ?? []; + /** @var array $collections */ + $collections = Config::getParam('collections', [])['projects'] ?? []; - foreach ($collections as $key => $collection) { - if (($collection['$collection'] ?? '') !== Database::METADATA) { - continue; - } + foreach ($collections as $key => $collection) { + if (($collection['$collection'] ?? '') !== Database::METADATA) { + continue; + } - $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); - $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); + $attributes = \array_map(function (array $attribute) { + return new Document($attribute); + }, $collection['attributes']); + + $indexes = \array_map(function (array $index) { + return new Document($index); + }, $collection['indexes']); try { $dbForProject->createCollection($key, $attributes, $indexes); } catch (Duplicate) { - if (!$globalCollections) { - $dbForProject->createDocument(Database::METADATA, new Document([ - '$id' => ID::custom($key), - '$permissions' => [Permission::create(Role::any())], - 'name' => $key, - 'attributes' => $attributes, - 'indexes' => $indexes, - 'documentSecurity' => true - ])); - } +// if (!$globalCollections) { +// $dbForProject->createDocument(Database::METADATA, new Document([ +// '$id' => ID::custom($key), +// '$permissions' => [Permission::create(Role::any())], +// 'name' => $key, +// 'attributes' => $attributes, +// 'indexes' => $indexes, +// 'documentSecurity' => true +// ])); +// } } } - } + // } // Hook allowing instant project mirroring during migration // Outside of migration, hook is not registered and has no effect diff --git a/composer.json b/composer.json index 10f2a12492..50881bec87 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-migrations as 0.53.6", + "utopia-php/database": "0.53.6", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 061f669841..70b3d833c2 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": "5cb1524d4677594554ab26d05b3c38e6", + "content-hash": "a81b2ddbd465059b986947b63435e2bc", "packages": [ { "name": "adhocore/jwt", @@ -1724,16 +1724,16 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-migrations", + "version": "0.53.6", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "5b9462f8abc12c2c7ab2dac99aa6f68aa2e27365" + "reference": "feddc8e808eaea9a11c65cca3f01683def422f52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/5b9462f8abc12c2c7ab2dac99aa6f68aa2e27365", - "reference": "5b9462f8abc12c2c7ab2dac99aa6f68aa2e27365", + "url": "https://api.github.com/repos/utopia-php/database/zipball/feddc8e808eaea9a11c65cca3f01683def422f52", + "reference": "feddc8e808eaea9a11c65cca3f01683def422f52", "shasum": "" }, "require": { @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/feat-migrations" + "source": "https://github.com/utopia-php/database/tree/0.53.6" }, - "time": "2024-10-22T08:05:24+00:00" + "time": "2024-10-08T02:18:46+00:00" }, { "name": "utopia-php/domains", @@ -2341,16 +2341,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.0", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "beeea0f2c9bce14a6869fc5c87a1047cdecb5c52" + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" }, "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/3433a0f1a54988f2a59c735f507745cb2c24638a", + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", "shasum": "" }, "require": { @@ -2385,9 +2385,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.7.1" }, - "time": "2024-05-08T17:00:55+00:00" + "time": "2024-10-22T10:27:49+00:00" }, { "name": "utopia-php/pools", @@ -7003,18 +7003,9 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [ - { - "package": "utopia-php/database", - "version": "dev-feat-migrations", - "alias": "0.53.6", - "alias_normalized": "0.53.6.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/database": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index 8f893b3b2f..a1b85c341f 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -11,7 +11,6 @@ use Utopia\Database\Exception; use Utopia\Database\Query; use Utopia\Platform\Action; use Utopia\Pools\Group; -use Utopia\Queue\Connection; use Utopia\System\System; use function Swoole\Coroutine\run; @@ -26,7 +25,7 @@ abstract class ScheduleBase extends Action abstract public static function getName(): string; abstract public static function getSupportedResource(): string; abstract public static function getCollectionId(): string; - abstract protected function enqueueResources(Connection $queue, Database $dbForConsole); + abstract protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void; public function __construct() { @@ -34,10 +33,10 @@ abstract class ScheduleBase extends Action $this ->desc("Execute {$type}s scheduled in Appwrite") - ->inject('queue') + ->inject('pools') ->inject('dbForConsole') ->inject('getProjectDB') - ->callback(fn (Connection $queue, Database $dbForConsole, callable $getProjectDB) => $this->action($queue, $dbForConsole, $getProjectDB)); + ->callback(fn (Group $pools, Database $dbForConsole, callable $getProjectDB) => $this->action($pools, $dbForConsole, $getProjectDB)); } /** @@ -45,7 +44,7 @@ abstract class ScheduleBase extends Action * 2. Create timer that sync all changes from 'schedules' collection to local copy. Only reading changes thanks to 'resourceUpdatedAt' attribute * 3. Create timer that prepares coroutines for soon-to-execute schedules. When it's ready, coroutine sleeps until exact time before sending request to worker. */ - public function action(Connection $queue, Database $dbForConsole, callable $getProjectDB): void + public function action(Group $pools, Database $dbForConsole, callable $getProjectDB): void { Console::title(\ucfirst(static::getSupportedResource()) . ' scheduler V1'); Console::success(APP_NAME . ' ' . \ucfirst(static::getSupportedResource()) . ' scheduler v1 has started'); @@ -114,15 +113,17 @@ abstract class ScheduleBase extends Action $latestDocument = \end($results); } + $pools->reclaim(); + Console::success("{$total} resources were loaded in " . (\microtime(true) - $loadStart) . " seconds"); Console::success("Starting timers at " . DateTime::now()); - run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $queue) { + run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools, $getProjectDB) { /** * The timer synchronize $schedules copy with database collection. */ - Timer::tick(static::UPDATE_TIMER * 1000, function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $queue) { + Timer::tick(static::UPDATE_TIMER * 1000, function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools) { $time = DateTime::now(); $timerStart = \microtime(true); @@ -171,15 +172,17 @@ abstract class ScheduleBase extends Action $lastSyncUpdate = $time; $timerEnd = \microtime(true); + $pools->reclaim(); + Console::log("Sync tick: {$total} schedules were updated in " . ($timerEnd - $timerStart) . " seconds"); }); Timer::tick( static::ENQUEUE_TIMER * 1000, - fn () => $this->enqueueResources($queue, $dbForConsole) + fn () => $this->enqueueResources($pools, $dbForConsole, $getProjectDB) ); - $this->enqueueResources($queue, $dbForConsole); + $this->enqueueResources($pools, $dbForConsole, $getProjectDB); }); } } diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 6bbc4ab65a..73a2814397 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -6,7 +6,6 @@ use Appwrite\Event\Func; use Swoole\Coroutine as Co; use Utopia\Database\Database; use Utopia\Pools\Group; -use Utopia\Queue\Connection; class ScheduleExecutions extends ScheduleBase { @@ -28,10 +27,11 @@ class ScheduleExecutions extends ScheduleBase return 'executions'; } - protected function enqueueResources(Connection $queue, Database $dbForConsole): void + protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void { - - $queueForFunctions = new Func($queue); + $queue = $pools->get('queue')->pop(); + $connection = $queue->getResource(); + $queueForFunctions = new Func($connection); $intervalEnd = (new \DateTime())->modify('+' . self::ENQUEUE_TIMER . ' seconds'); foreach ($this->schedules as $schedule) { @@ -81,5 +81,7 @@ class ScheduleExecutions extends ScheduleBase unset($this->schedules[$schedule['$internalId']]); } + + $queue->reclaim(); } } diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index d1ee5a6e93..4d57902330 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -8,7 +8,6 @@ use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Pools\Group; -use Utopia\Queue\Connection; class ScheduleFunctions extends ScheduleBase { @@ -32,7 +31,7 @@ class ScheduleFunctions extends ScheduleBase return 'functions'; } - protected function enqueueResources(Connection $queue, Database $dbForConsole): void + protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void { $timerStart = \microtime(true); $time = DateTime::now(); @@ -71,9 +70,12 @@ class ScheduleFunctions extends ScheduleBase } foreach ($delayedExecutions as $delay => $scheduleKeys) { - \go(function () use ($delay, $scheduleKeys, $queue) { + \go(function () use ($delay, $scheduleKeys, $pools) { \sleep($delay); // in seconds + $queue = $pools->get('queue')->pop(); + $connection = $queue->getResource(); + foreach ($scheduleKeys as $scheduleKey) { // Ensure schedule was not deleted if (!\array_key_exists($scheduleKey, $this->schedules)) { @@ -82,7 +84,7 @@ class ScheduleFunctions extends ScheduleBase $schedule = $this->schedules[$scheduleKey]; - $queueForFunctions = new Func($queue); + $queueForFunctions = new Func($connection); $queueForFunctions ->setType('schedule') @@ -92,6 +94,8 @@ class ScheduleFunctions extends ScheduleBase ->setProject($schedule['project']) ->trigger(); } + + $queue->reclaim(); }); } diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 4f58a58177..b9d8e2a282 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -5,7 +5,6 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Messaging; use Utopia\Database\Database; use Utopia\Pools\Group; -use Utopia\Queue\Connection; class ScheduleMessages extends ScheduleBase { @@ -27,7 +26,7 @@ class ScheduleMessages extends ScheduleBase return 'messages'; } - protected function enqueueResources(Connection $queue, Database $dbForConsole): void + protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void { foreach ($this->schedules as $schedule) { if (!$schedule['active']) { @@ -41,9 +40,10 @@ class ScheduleMessages extends ScheduleBase continue; } - \go(function () use ($schedule, $queue, $dbForConsole) { - - $queueForMessaging = new Messaging($queue); + \go(function () use ($schedule, $pools, $dbForConsole) { + $queue = $pools->get('queue')->pop(); + $connection = $queue->getResource(); + $queueForMessaging = new Messaging($connection); $queueForMessaging ->setType(MESSAGE_SEND_TYPE_EXTERNAL) @@ -56,6 +56,8 @@ class ScheduleMessages extends ScheduleBase $schedule['$id'], ); + $queue->reclaim(); + unset($this->schedules[$schedule['$internalId']]); }); } From 7be7b3389c2d1815cf09f45b1f8850512803c918 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 22 Oct 2024 21:31:32 +0300 Subject: [PATCH 079/144] debug --- app/controllers/api/projects.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 78f2c56cd8..c8c3928ebc 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -123,7 +123,7 @@ App::post('/v1/projects') } $databases = Config::getParam('pools-database', []); - + var_dump($databases); $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); $index = \array_search($databaseOverride, $databases); if ($index !== false) { @@ -198,6 +198,9 @@ App::post('/v1/projects') $dsn = new DSN('mysql://' . $dsn); } + + var_dump($dsn->getHost()); + $adapter = $pools->get($dsn->getHost())->pop()->getResource(); $dbForProject = new Database($adapter, $cache); $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); From ae4edf119f4f5d12b1d07ed27002e6ced7d3a135 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 22 Oct 2024 19:49:10 +0000 Subject: [PATCH 080/144] chore: linter --- composer.lock | 24 +++++++++---------- .../Platform/Workers/Certificates.php | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/composer.lock b/composer.lock index 9079512e60..0b83648f74 100644 --- a/composer.lock +++ b/composer.lock @@ -2124,16 +2124,16 @@ }, { "name": "utopia-php/messaging", - "version": "0.12.1", + "version": "0.12.2", "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "b9dfafb5efc1d12cbee01d03dc98853ef026e35b" + "reference": "f6790fba1fcee12163d51c65d2c226a7856295d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/b9dfafb5efc1d12cbee01d03dc98853ef026e35b", - "reference": "b9dfafb5efc1d12cbee01d03dc98853ef026e35b", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/f6790fba1fcee12163d51c65d2c226a7856295d9", + "reference": "f6790fba1fcee12163d51c65d2c226a7856295d9", "shasum": "" }, "require": { @@ -2169,9 +2169,9 @@ ], "support": { "issues": "https://github.com/utopia-php/messaging/issues", - "source": "https://github.com/utopia-php/messaging/tree/0.12.1" + "source": "https://github.com/utopia-php/messaging/tree/0.12.2" }, - "time": "2024-10-09T08:17:07+00:00" + "time": "2024-10-22T01:02:20+00:00" }, { "name": "utopia-php/migration", @@ -2341,16 +2341,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.0", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "beeea0f2c9bce14a6869fc5c87a1047cdecb5c52" + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" }, "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/3433a0f1a54988f2a59c735f507745cb2c24638a", + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", "shasum": "" }, "require": { @@ -2385,9 +2385,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.7.1" }, - "time": "2024-05-08T17:00:55+00:00" + "time": "2024-10-22T10:27:49+00:00" }, { "name": "utopia-php/pools", diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index ddb5130838..c7f72b3e3c 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -160,14 +160,14 @@ class Certificates extends Action try { // Generate certificate files using Let's Encrypt - $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); + $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); // Give certificates to Traefik $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); } catch (\Throwable $th) { Console::error('Failed to generate Lets Encrypt certificate'); } - + // Command succeeded, store all data into document $logs = 'Certificate successfully generated.'; $certificate->setAttribute('logs', \mb_strcut($logs, 0, 1000000));// Limit to 1MB From 4a003f2826c59de420222512cf42137610683540 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 23 Oct 2024 17:41:44 +1300 Subject: [PATCH 081/144] Force create audit/abuse metadata documents for shared tables v1 --- app/controllers/api/projects.php | 24 ++++++++++++++++ composer.json | 4 +-- composer.lock | 48 +++++++++++++++++--------------- 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 2f8ead3f2e..b62d84931c 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -225,6 +225,30 @@ App::post('/v1/projects') $abuse = new TimeLimit('', 0, 1, $dbForProject); $abuse->setup(); + if (!$globalCollections) { + $attributes = \array_map(fn ($attribute) => new Document($attribute), TimeLimit::ATTRIBUTES); + $indexes = \array_map(fn (array $index) => new Document($index), TimeLimit::INDEXES); + $dbForProject->createDocument(Database::METADATA, new Document([ + '$id' => ID::custom('audit'), + '$permissions' => [Permission::create(Role::any())], + 'name' => 'audit', + 'attributes' => $attributes, + 'indexes' => $indexes, + 'documentSecurity' => true + ])); + + $attributes = \array_map(fn ($attribute) => new Document($attribute), Audit::ATTRIBUTES); + $indexes = \array_map(fn (array $index) => new Document($index), Audit::INDEXES); + $dbForProject->createDocument(Database::METADATA, new Document([ + '$id' => ID::custom('abuse'), + '$permissions' => [Permission::create(Role::any())], + 'name' => 'abuse', + 'attributes' => $attributes, + 'indexes' => $indexes, + 'documentSecurity' => true + ])); + } + /** @var array $collections */ $collections = Config::getParam('collections', [])['projects'] ?? []; diff --git a/composer.json b/composer.json index 96c9d8280a..036dc69a3d 100644 --- a/composer.json +++ b/composer.json @@ -45,9 +45,9 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.16.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "0.43.*", + "utopia-php/abuse": "0.43.x-dev", "utopia-php/analytics": "0.10.*", - "utopia-php/audit": "0.43.*", + "utopia-php/audit": "0.43.x-dev", "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", diff --git a/composer.lock b/composer.lock index 65bfce41f5..913c9ed05f 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": "f4a0801b367486bf7105e1f39efa9121", + "content-hash": "d45358f3de2b639c1aab4ccfd5168a1c", "packages": [ { "name": "adhocore/jwt", @@ -1430,16 +1430,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.43.0", + "version": "0.43.x-dev", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "6346a3b4c5177a43160035a7289e30fdfb0790d6" + "reference": "e404c21e8dcf6a310bc83cf1d74e716b105598fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/6346a3b4c5177a43160035a7289e30fdfb0790d6", - "reference": "6346a3b4c5177a43160035a7289e30fdfb0790d6", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/e404c21e8dcf6a310bc83cf1d74e716b105598fa", + "reference": "e404c21e8dcf6a310bc83cf1d74e716b105598fa", "shasum": "" }, "require": { @@ -1475,9 +1475,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.43.0" + "source": "https://github.com/utopia-php/abuse/tree/0.43.x" }, - "time": "2024-08-30T05:17:23+00:00" + "time": "2024-10-23T04:29:12+00:00" }, { "name": "utopia-php/analytics", @@ -1527,16 +1527,16 @@ }, { "name": "utopia-php/audit", - "version": "0.43.0", + "version": "0.43.x-dev", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "cef22b5dc6a6d28fcd522f41c7bf7ded4a4dfd3e" + "reference": "04a47dd1f5f92e2d50e971a06bcc9e759325d277" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/cef22b5dc6a6d28fcd522f41c7bf7ded4a4dfd3e", - "reference": "cef22b5dc6a6d28fcd522f41c7bf7ded4a4dfd3e", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/04a47dd1f5f92e2d50e971a06bcc9e759325d277", + "reference": "04a47dd1f5f92e2d50e971a06bcc9e759325d277", "shasum": "" }, "require": { @@ -1568,9 +1568,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.43.0" + "source": "https://github.com/utopia-php/audit/tree/0.43.x" }, - "time": "2024-08-30T05:17:36+00:00" + "time": "2024-10-23T04:27:59+00:00" }, { "name": "utopia-php/cache", @@ -1728,12 +1728,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad" + "reference": "7bd224ae817776f078e7d22f7c8ee124d465e1cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/efd0f4e8fb5d158486aec0e6fea9561facf0daad", - "reference": "efd0f4e8fb5d158486aec0e6fea9561facf0daad", + "url": "https://api.github.com/repos/utopia-php/database/zipball/7bd224ae817776f078e7d22f7c8ee124d465e1cd", + "reference": "7bd224ae817776f078e7d22f7c8ee124d465e1cd", "shasum": "" }, "require": { @@ -1776,7 +1776,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-10-15T05:50:09+00:00" + "time": "2024-10-22T09:49:03+00:00" }, { "name": "utopia-php/domains", @@ -2341,16 +2341,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.0", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "beeea0f2c9bce14a6869fc5c87a1047cdecb5c52" + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" }, "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/3433a0f1a54988f2a59c735f507745cb2c24638a", + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", "shasum": "" }, "require": { @@ -2385,9 +2385,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.7.1" }, - "time": "2024-05-08T17:00:55+00:00" + "time": "2024-10-22T10:27:49+00:00" }, { "name": "utopia-php/pools", @@ -7013,6 +7013,8 @@ ], "minimum-stability": "stable", "stability-flags": { + "utopia-php/abuse": 20, + "utopia-php/audit": 20, "utopia-php/database": 20 }, "prefer-stable": false, From 8210808db0c2f1a9e0ca2ee59103fa365028120c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 23 Oct 2024 18:00:06 +1300 Subject: [PATCH 082/144] Improve logic --- app/controllers/api/projects.php | 76 +++++++++++++++++--------------- docker-compose.yml | 1 + 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index b62d84931c..4e7f746636 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -196,12 +196,16 @@ App::post('/v1/projects') $dbForProject = new Database($adapter, $cache); $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); - $globalCollections = !\in_array($dsn->getHost(), $sharedTablesV1); - if (\in_array($dsn->getHost(), $sharedTables)) { + $projectTables = !\in_array($dsn->getHost(), $sharedTables); + $sharedTablesV1 = \in_array($dsn->getHost(), $sharedTablesV1); + $sharedTablesV2 = !$projectTables && !$sharedTablesV1; + $sharedTables = $sharedTablesV1 || $sharedTablesV2; + + if ($sharedTables) { $dbForProject ->setSharedTables(true) - ->setTenant($globalCollections ? null : $project->getInternalId()) + ->setTenant($sharedTablesV1 ? $project->getInternalId() : null) ->setNamespace($dsn->getParam('namespace')); } else { $dbForProject @@ -218,37 +222,39 @@ App::post('/v1/projects') $create = false; } - if ($create || !$globalCollections) { + if ($create || $projectTables) { $audit = new Audit($dbForProject); $audit->setup(); $abuse = new TimeLimit('', 0, 1, $dbForProject); $abuse->setup(); + } - if (!$globalCollections) { - $attributes = \array_map(fn ($attribute) => new Document($attribute), TimeLimit::ATTRIBUTES); - $indexes = \array_map(fn (array $index) => new Document($index), TimeLimit::INDEXES); - $dbForProject->createDocument(Database::METADATA, new Document([ - '$id' => ID::custom('audit'), - '$permissions' => [Permission::create(Role::any())], - 'name' => 'audit', - 'attributes' => $attributes, - 'indexes' => $indexes, - 'documentSecurity' => true - ])); + if (!$create && $sharedTablesV1) { + $attributes = \array_map(fn ($attribute) => new Document($attribute), TimeLimit::ATTRIBUTES); + $indexes = \array_map(fn (array $index) => new Document($index), TimeLimit::INDEXES); + $dbForProject->createDocument(Database::METADATA, new Document([ + '$id' => ID::custom('audit'), + '$permissions' => [Permission::create(Role::any())], + 'name' => 'audit', + 'attributes' => $attributes, + 'indexes' => $indexes, + 'documentSecurity' => true + ])); - $attributes = \array_map(fn ($attribute) => new Document($attribute), Audit::ATTRIBUTES); - $indexes = \array_map(fn (array $index) => new Document($index), Audit::INDEXES); - $dbForProject->createDocument(Database::METADATA, new Document([ - '$id' => ID::custom('abuse'), - '$permissions' => [Permission::create(Role::any())], - 'name' => 'abuse', - 'attributes' => $attributes, - 'indexes' => $indexes, - 'documentSecurity' => true - ])); - } + $attributes = \array_map(fn ($attribute) => new Document($attribute), Audit::ATTRIBUTES); + $indexes = \array_map(fn (array $index) => new Document($index), Audit::INDEXES); + $dbForProject->createDocument(Database::METADATA, new Document([ + '$id' => ID::custom('abuse'), + '$permissions' => [Permission::create(Role::any())], + 'name' => 'abuse', + 'attributes' => $attributes, + 'indexes' => $indexes, + 'documentSecurity' => true + ])); + } + if ($create || $sharedTablesV1) { /** @var array $collections */ $collections = Config::getParam('collections', [])['projects'] ?? []; @@ -263,16 +269,14 @@ App::post('/v1/projects') try { $dbForProject->createCollection($key, $attributes, $indexes); } catch (Duplicate) { - if (!$globalCollections) { - $dbForProject->createDocument(Database::METADATA, new Document([ - '$id' => ID::custom($key), - '$permissions' => [Permission::create(Role::any())], - 'name' => $key, - 'attributes' => $attributes, - 'indexes' => $indexes, - 'documentSecurity' => true - ])); - } + $dbForProject->createDocument(Database::METADATA, new Document([ + '$id' => ID::custom($key), + '$permissions' => [Permission::create(Role::any())], + 'name' => $key, + 'attributes' => $attributes, + 'indexes' => $indexes, + 'documentSecurity' => true + ])); } } } diff --git a/docker-compose.yml b/docker-compose.yml index 479ca38b8f..ebe965891f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -192,6 +192,7 @@ services: - _APP_EXPERIMENT_LOGGING_PROVIDER - _APP_EXPERIMENT_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES + - _APP_DATABASE_SHARED_TABLES_V1 appwrite-console: <<: *x-logging From eca8d116c28d82adec1baf9f55726ca3abd19a8e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 23 Oct 2024 18:10:41 +1300 Subject: [PATCH 083/144] Fix attributes --- app/controllers/api/projects.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 4e7f746636..4a8710f573 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -231,8 +231,8 @@ App::post('/v1/projects') } if (!$create && $sharedTablesV1) { - $attributes = \array_map(fn ($attribute) => new Document($attribute), TimeLimit::ATTRIBUTES); - $indexes = \array_map(fn (array $index) => new Document($index), TimeLimit::INDEXES); + $attributes = \array_map(fn ($attribute) => new Document($attribute), Audit::ATTRIBUTES); + $indexes = \array_map(fn (array $index) => new Document($index), Audit::INDEXES); $dbForProject->createDocument(Database::METADATA, new Document([ '$id' => ID::custom('audit'), '$permissions' => [Permission::create(Role::any())], @@ -242,8 +242,8 @@ App::post('/v1/projects') 'documentSecurity' => true ])); - $attributes = \array_map(fn ($attribute) => new Document($attribute), Audit::ATTRIBUTES); - $indexes = \array_map(fn (array $index) => new Document($index), Audit::INDEXES); + $attributes = \array_map(fn ($attribute) => new Document($attribute), TimeLimit::ATTRIBUTES); + $indexes = \array_map(fn (array $index) => new Document($index), TimeLimit::INDEXES); $dbForProject->createDocument(Database::METADATA, new Document([ '$id' => ID::custom('abuse'), '$permissions' => [Permission::create(Role::any())], From 013d95ebf3b689119e1c3aa7db9b8d10700a0b8d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 23 Oct 2024 18:42:00 +1300 Subject: [PATCH 084/144] Update audit and abuse --- composer.json | 4 ++-- composer.lock | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 036dc69a3d..96c9d8280a 100644 --- a/composer.json +++ b/composer.json @@ -45,9 +45,9 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.16.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "0.43.x-dev", + "utopia-php/abuse": "0.43.*", "utopia-php/analytics": "0.10.*", - "utopia-php/audit": "0.43.x-dev", + "utopia-php/audit": "0.43.*", "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", diff --git a/composer.lock b/composer.lock index 913c9ed05f..d4137b89fd 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": "d45358f3de2b639c1aab4ccfd5168a1c", + "content-hash": "f4a0801b367486bf7105e1f39efa9121", "packages": [ { "name": "adhocore/jwt", @@ -1430,7 +1430,7 @@ }, { "name": "utopia-php/abuse", - "version": "0.43.x-dev", + "version": "0.43.1", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", @@ -1475,7 +1475,7 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.43.x" + "source": "https://github.com/utopia-php/abuse/tree/0.43.1" }, "time": "2024-10-23T04:29:12+00:00" }, @@ -1527,7 +1527,7 @@ }, { "name": "utopia-php/audit", - "version": "0.43.x-dev", + "version": "0.43.1", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", @@ -1568,7 +1568,7 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.43.x" + "source": "https://github.com/utopia-php/audit/tree/0.43.1" }, "time": "2024-10-23T04:27:59+00:00" }, @@ -7013,8 +7013,6 @@ ], "minimum-stability": "stable", "stability-flags": { - "utopia-php/abuse": 20, - "utopia-php/audit": 20, "utopia-php/database": 20 }, "prefer-stable": false, From cf32ba0351b9cfd77820970fdccbc7a7067e180d Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 27 Oct 2024 18:10:30 +0200 Subject: [PATCH 085/144] debug --- app/controllers/api/projects.php | 4 ---- src/Appwrite/Event/Event.php | 3 ++- src/Appwrite/Platform/Workers/Certificates.php | 1 - src/Appwrite/Platform/Workers/Databases.php | 4 +++- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index c8c3928ebc..f051bd6b96 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -123,7 +123,6 @@ App::post('/v1/projects') } $databases = Config::getParam('pools-database', []); - var_dump($databases); $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); $index = \array_search($databaseOverride, $databases); if ($index !== false) { @@ -198,9 +197,6 @@ App::post('/v1/projects') $dsn = new DSN('mysql://' . $dsn); } - - var_dump($dsn->getHost()); - $adapter = $pools->get($dsn->getHost())->pop()->getResource(); $dbForProject = new Database($adapter, $cache); $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 468b30e7a9..9445ea4129 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -115,7 +115,8 @@ class Event public function getSourceRegion(): string { - return System::getEnv('_APP_REGION', 'default'); + var_dump('event Source Region='.System::getEnv('_APP_REGION')); + return System::getEnv('_APP_REGION'); } /** diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 2261912551..dcc42a87fc 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -174,7 +174,6 @@ class Certificates extends Action $logs = 'Certificate successfully generated.'; $certificate->setAttribute('logs', \mb_strcut($logs, 0, 1000000));// Limit to 1MB - var_dump($certificate); // Give certificates to Traefik $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index c9023318c7..c1d185ca06 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -17,6 +17,7 @@ use Utopia\Database\Query; use Utopia\Logger\Log; use Utopia\Platform\Action; use Utopia\Queue\Message; +use Utopia\System\System; class Databases extends Action { @@ -67,7 +68,7 @@ class Databases extends Action $collection = new Document($payload['collection'] ?? []); $document = new Document($payload['document'] ?? []); $database = new Document($payload['database'] ?? []); - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; + $this->sourceRegion = $payload['sourceRegion'] ?? null; $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); @@ -618,6 +619,7 @@ class Databases extends Action array $events, callable $realtimeConnection ): void { + var_dump('Send region='.$this->sourceRegion); $target = Realtime::fromPayload( // Pass first, most verbose event pattern event: $events[0], From 66bfc5748b4219edeefac9baa1c5786cbfb13de0 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 28 Oct 2024 11:15:41 +0200 Subject: [PATCH 086/144] injecting poolForQueue to schedulers --- app/cli.php | 4 ++++ src/Appwrite/Platform/Tasks/ScheduleBase.php | 21 ++++++++++--------- .../Platform/Tasks/ScheduleExecutions.php | 5 +++-- .../Platform/Tasks/ScheduleFunctions.php | 6 +++--- .../Platform/Tasks/ScheduleMessages.php | 7 ++++--- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/app/cli.php b/app/cli.php index f8a2d6ef87..0b76afc2e1 100644 --- a/app/cli.php +++ b/app/cli.php @@ -163,6 +163,10 @@ CLI::setResource('queue', function (Group $pools) { return $pools->get('queue')->pop()->getResource(); }, ['pools']); +CLI::setResource('poolForQueue', function (Group $pools) { + return $pools->get('queue'); +}, ['pools']); + CLI::setResource('queueForFunctions', function (Connection $queue) { return new Func($queue); }, ['queue']); diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index a1b85c341f..a7015405ab 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -11,6 +11,7 @@ use Utopia\Database\Exception; use Utopia\Database\Query; use Utopia\Platform\Action; use Utopia\Pools\Group; +use Utopia\Pools\Pool; use Utopia\System\System; use function Swoole\Coroutine\run; @@ -25,7 +26,7 @@ abstract class ScheduleBase extends Action abstract public static function getName(): string; abstract public static function getSupportedResource(): string; abstract public static function getCollectionId(): string; - abstract protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void; + abstract protected function enqueueResources(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void; public function __construct() { @@ -33,10 +34,10 @@ abstract class ScheduleBase extends Action $this ->desc("Execute {$type}s scheduled in Appwrite") - ->inject('pools') + ->inject('queuePool') ->inject('dbForConsole') ->inject('getProjectDB') - ->callback(fn (Group $pools, Database $dbForConsole, callable $getProjectDB) => $this->action($pools, $dbForConsole, $getProjectDB)); + ->callback(fn (Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB) => $this->action($poolForQueue, $dbForConsole, $getProjectDB)); } /** @@ -44,7 +45,7 @@ abstract class ScheduleBase extends Action * 2. Create timer that sync all changes from 'schedules' collection to local copy. Only reading changes thanks to 'resourceUpdatedAt' attribute * 3. Create timer that prepares coroutines for soon-to-execute schedules. When it's ready, coroutine sleeps until exact time before sending request to worker. */ - public function action(Group $pools, Database $dbForConsole, callable $getProjectDB): void + public function action(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void { Console::title(\ucfirst(static::getSupportedResource()) . ' scheduler V1'); Console::success(APP_NAME . ' ' . \ucfirst(static::getSupportedResource()) . ' scheduler v1 has started'); @@ -113,17 +114,17 @@ abstract class ScheduleBase extends Action $latestDocument = \end($results); } - $pools->reclaim(); + $poolForQueue->reclaim(); Console::success("{$total} resources were loaded in " . (\microtime(true) - $loadStart) . " seconds"); Console::success("Starting timers at " . DateTime::now()); - run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools, $getProjectDB) { + run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $poolForQueue, $getProjectDB) { /** * The timer synchronize $schedules copy with database collection. */ - Timer::tick(static::UPDATE_TIMER * 1000, function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools) { + Timer::tick(static::UPDATE_TIMER * 1000, function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $poolForQueue) { $time = DateTime::now(); $timerStart = \microtime(true); @@ -172,17 +173,17 @@ abstract class ScheduleBase extends Action $lastSyncUpdate = $time; $timerEnd = \microtime(true); - $pools->reclaim(); + $poolForQueue->reclaim(); Console::log("Sync tick: {$total} schedules were updated in " . ($timerEnd - $timerStart) . " seconds"); }); Timer::tick( static::ENQUEUE_TIMER * 1000, - fn () => $this->enqueueResources($pools, $dbForConsole, $getProjectDB) + fn () => $this->enqueueResources($poolForQueue, $dbForConsole, $getProjectDB) ); - $this->enqueueResources($pools, $dbForConsole, $getProjectDB); + $this->enqueueResources($poolForQueue, $dbForConsole, $getProjectDB); }); } } diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 73a2814397..3996c54fed 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -6,6 +6,7 @@ use Appwrite\Event\Func; use Swoole\Coroutine as Co; use Utopia\Database\Database; use Utopia\Pools\Group; +use Utopia\Pools\Pool; class ScheduleExecutions extends ScheduleBase { @@ -27,9 +28,9 @@ class ScheduleExecutions extends ScheduleBase return 'executions'; } - protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void + protected function enqueueResources(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void { - $queue = $pools->get('queue')->pop(); + $queue = $poolForQueue->pop(); $connection = $queue->getResource(); $queueForFunctions = new Func($connection); $intervalEnd = (new \DateTime())->modify('+' . self::ENQUEUE_TIMER . ' seconds'); diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index 4d57902330..ff8d99c8e5 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -31,7 +31,7 @@ class ScheduleFunctions extends ScheduleBase return 'functions'; } - protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void + protected function enqueueResources(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void { $timerStart = \microtime(true); $time = DateTime::now(); @@ -70,10 +70,10 @@ class ScheduleFunctions extends ScheduleBase } foreach ($delayedExecutions as $delay => $scheduleKeys) { - \go(function () use ($delay, $scheduleKeys, $pools) { + \go(function () use ($delay, $scheduleKeys, $poolForQueue) { \sleep($delay); // in seconds - $queue = $pools->get('queue')->pop(); + $queue = $poolForQueue->pop(); $connection = $queue->getResource(); foreach ($scheduleKeys as $scheduleKey) { diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index b9d8e2a282..79c2c44ec9 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -5,6 +5,7 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Messaging; use Utopia\Database\Database; use Utopia\Pools\Group; +use Utopia\Pools\Pool; class ScheduleMessages extends ScheduleBase { @@ -26,7 +27,7 @@ class ScheduleMessages extends ScheduleBase return 'messages'; } - protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void + protected function enqueueResources(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void { foreach ($this->schedules as $schedule) { if (!$schedule['active']) { @@ -40,8 +41,8 @@ class ScheduleMessages extends ScheduleBase continue; } - \go(function () use ($schedule, $pools, $dbForConsole) { - $queue = $pools->get('queue')->pop(); + \go(function () use ($schedule, $poolForQueue, $dbForConsole) { + $queue = $poolForQueue->pop(); $connection = $queue->getResource(); $queueForMessaging = new Messaging($connection); From 12458af84ab32645f93e18034729923a388d6b6d Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 28 Oct 2024 11:34:02 +0200 Subject: [PATCH 087/144] injecting poolForQueue to schedulers --- src/Appwrite/Platform/Tasks/ScheduleFunctions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index ff8d99c8e5..7d12d9ea0a 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -8,6 +8,7 @@ use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Pools\Group; +use Utopia\Pools\Pool; class ScheduleFunctions extends ScheduleBase { From 509f06c2f00b4b3aa17d76b11d43cca1b1de2e25 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 28 Oct 2024 11:41:59 +0200 Subject: [PATCH 088/144] injecting poolForQueue to schedulers --- src/Appwrite/Platform/Tasks/ScheduleBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index a7015405ab..0403afa7cb 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -34,7 +34,7 @@ abstract class ScheduleBase extends Action $this ->desc("Execute {$type}s scheduled in Appwrite") - ->inject('queuePool') + ->inject('poolForQueue') ->inject('dbForConsole') ->inject('getProjectDB') ->callback(fn (Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB) => $this->action($poolForQueue, $dbForConsole, $getProjectDB)); From 118252d3affbad0e7ae3df959d7b265847812bc8 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 28 Oct 2024 12:04:58 +0200 Subject: [PATCH 089/144] injecting poolForQueue to schedulers --- src/Appwrite/Platform/Tasks/ScheduleBase.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleExecutions.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleFunctions.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleMessages.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index 0403afa7cb..abe614829f 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -26,7 +26,7 @@ abstract class ScheduleBase extends Action abstract public static function getName(): string; abstract public static function getSupportedResource(): string; abstract public static function getCollectionId(): string; - abstract protected function enqueueResources(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void; + abstract protected function enqueueResources(\Utopia\Pools\Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void; public function __construct() { diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 3996c54fed..58fc07b019 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -28,7 +28,7 @@ class ScheduleExecutions extends ScheduleBase return 'executions'; } - protected function enqueueResources(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void + protected function enqueueResources(\Utopia\Pools\Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void { $queue = $poolForQueue->pop(); $connection = $queue->getResource(); diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index 7d12d9ea0a..8095e812a9 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -32,7 +32,7 @@ class ScheduleFunctions extends ScheduleBase return 'functions'; } - protected function enqueueResources(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void + protected function enqueueResources(\Utopia\Pools\Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void { $timerStart = \microtime(true); $time = DateTime::now(); diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 79c2c44ec9..3167e29f7a 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -27,7 +27,7 @@ class ScheduleMessages extends ScheduleBase return 'messages'; } - protected function enqueueResources(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void + protected function enqueueResources(\Utopia\Pools\Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void { foreach ($this->schedules as $schedule) { if (!$schedule['active']) { From 4e37699e25f172c28795ade10d6e10163b402327 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 29 Oct 2024 11:15:55 +0200 Subject: [PATCH 090/144] debug --- src/Appwrite/Messaging/Adapter/Realtime.php | 3 ++- src/Appwrite/Platform/Workers/Databases.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Messaging/Adapter/Realtime.php b/src/Appwrite/Messaging/Adapter/Realtime.php index f1eaa97048..cf554e1c29 100644 --- a/src/Appwrite/Messaging/Adapter/Realtime.php +++ b/src/Appwrite/Messaging/Adapter/Realtime.php @@ -140,7 +140,8 @@ class Realtime extends Adapter $permissionsChanged = array_key_exists('permissionsChanged', $options) && $options['permissionsChanged']; $userId = array_key_exists('userId', $options) ? $options['userId'] : null; - + var_dump($redis->getHost()); + var_dump($channels); $redis->publish('realtime', json_encode([ 'project' => $projectId, 'roles' => $roles, diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index c1d185ca06..0bb448e4a3 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -619,7 +619,7 @@ class Databases extends Action array $events, callable $realtimeConnection ): void { - var_dump('Send region='.$this->sourceRegion); + var_dump('Send message to realtime region='.$this->sourceRegion); $target = Realtime::fromPayload( // Pass first, most verbose event pattern event: $events[0], From cdbd72ec3dd58b64cc01554fab029ae1a508697d Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 31 Oct 2024 10:06:52 +0200 Subject: [PATCH 091/144] sync against 1.6.x --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 13b018df0f..ccd33e621d 100755 --- a/Dockerfile +++ b/Dockerfile @@ -92,10 +92,10 @@ RUN chmod +x /usr/local/bin/doctor && \ RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/ # Enable Extensions -RUN if [ "$DEBUG" == "true" ]; then cp /usr/src/code/dev/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini; fi -RUN if [ "$DEBUG" == "true" ]; then mkdir -p /tmp/xdebug; fi -RUN if [ "$DEBUG" = "false" ]; then rm -rf /usr/src/code/dev; fi -RUN if [ "$DEBUG" = "false" ]; then rm -f /usr/local/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so; fi +RUN if [ "$DEBUG" == "true" ]; then cp /usr/src/code/dev/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini; fi && \ + if [ "$DEBUG" == "true" ]; then mkdir -p /tmp/xdebug; fi && \ + if [ "$DEBUG" = "false" ]; then rm -rf /usr/src/code/dev; fi && \ + if [ "$DEBUG" = "false" ]; then rm -f /usr/local/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so; fi EXPOSE 80 From b00b6096219f40d44b703d0c617541c38ce504ab Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 31 Oct 2024 10:22:08 +0200 Subject: [PATCH 092/144] sync against 1.6.x --- composer.json | 2 +- composer.lock | 163 ++++++++++++++++++++++++++------------------------ 2 files changed, 87 insertions(+), 78 deletions(-) diff --git a/composer.json b/composer.json index dd5472a0fa..a625945b56 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "utopia-php/abuse": "0.43.0", "utopia-php/analytics": "0.10.*", "utopia-php/audit": "0.43.0", - "utopia-php/cache": "0.10.*", + "utopia-php/cache": "dev-feat-redis-sync as 0.10.2", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", "utopia-php/database": "0.53.8", diff --git a/composer.lock b/composer.lock index 70b3d833c2..a9d040fecc 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": "a81b2ddbd465059b986947b63435e2bc", + "content-hash": "f245bc714f5b1b539ec9083bb0526bd2", "packages": [ { "name": "adhocore/jwt", @@ -157,21 +157,21 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.15.0", + "version": "0.16.4", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "68ea5bcc24c513a6d641ddf9412bbab13e5dfb94" + "reference": "7e4741337b9373f77210396e68eca539018cabd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/runtimes/zipball/68ea5bcc24c513a6d641ddf9412bbab13e5dfb94", - "reference": "68ea5bcc24c513a6d641ddf9412bbab13e5dfb94", + "url": "https://api.github.com/repos/appwrite/runtimes/zipball/7e4741337b9373f77210396e68eca539018cabd1", + "reference": "7e4741337b9373f77210396e68eca539018cabd1", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/system": "0.8.*" + "utopia-php/system": "0.9.*" }, "require-dev": { "laravel/pint": "^1.15", @@ -206,22 +206,22 @@ ], "support": { "issues": "https://github.com/appwrite/runtimes/issues", - "source": "https://github.com/appwrite/runtimes/tree/0.15.0" + "source": "https://github.com/appwrite/runtimes/tree/0.16.4" }, - "time": "2024-08-21T10:23:45+00:00" + "time": "2024-10-26T10:39:59+00:00" }, { "name": "beberlei/assert", - "version": "v3.3.2", + "version": "v3.3.3", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "cb70015c04be1baee6f5f5c953703347c0ac1655" + "reference": "b5fd8eacd8915a1b627b8bfc027803f1939734dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/cb70015c04be1baee6f5f5c953703347c0ac1655", - "reference": "cb70015c04be1baee6f5f5c953703347c0ac1655", + "url": "https://api.github.com/repos/beberlei/assert/zipball/b5fd8eacd8915a1b627b8bfc027803f1939734dd", + "reference": "b5fd8eacd8915a1b627b8bfc027803f1939734dd", "shasum": "" }, "require": { @@ -229,7 +229,7 @@ "ext-json": "*", "ext-mbstring": "*", "ext-simplexml": "*", - "php": "^7.0 || ^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "*", @@ -273,9 +273,9 @@ ], "support": { "issues": "https://github.com/beberlei/assert/issues", - "source": "https://github.com/beberlei/assert/tree/v3.3.2" + "source": "https://github.com/beberlei/assert/tree/v3.3.3" }, - "time": "2021-12-16T21:41:27+00:00" + "time": "2024-07-15T13:18:35+00:00" }, { "name": "chillerlan/php-qrcode", @@ -1574,16 +1574,16 @@ }, { "name": "utopia-php/cache", - "version": "0.10.2", + "version": "dev-feat-redis-sync", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247" + "reference": "572f3224f963a5fbd4bbb79d815b7e798a1666ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cache/zipball/b22c6eb6d308de246b023efd0fc9758aee8b8247", - "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247", + "url": "https://api.github.com/repos/utopia-php/cache/zipball/572f3224f963a5fbd4bbb79d815b7e798a1666ed", + "reference": "572f3224f963a5fbd4bbb79d815b7e798a1666ed", "shasum": "" }, "require": { @@ -1618,9 +1618,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cache/issues", - "source": "https://github.com/utopia-php/cache/tree/0.10.2" + "source": "https://github.com/utopia-php/cache/tree/feat-redis-sync" }, - "time": "2024-06-25T20:36:35+00:00" + "time": "2024-10-06T13:11:23+00:00" }, { "name": "utopia-php/cli", @@ -1724,16 +1724,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.6", + "version": "0.53.8", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "feddc8e808eaea9a11c65cca3f01683def422f52" + "reference": "f4f9297d633b9f8407c6261535549bfd6024a468" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/feddc8e808eaea9a11c65cca3f01683def422f52", - "reference": "feddc8e808eaea9a11c65cca3f01683def422f52", + "url": "https://api.github.com/repos/utopia-php/database/zipball/f4f9297d633b9f8407c6261535549bfd6024a468", + "reference": "f4f9297d633b9f8407c6261535549bfd6024a468", "shasum": "" }, "require": { @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.6" + "source": "https://github.com/utopia-php/database/tree/0.53.8" }, - "time": "2024-10-08T02:18:46+00:00" + "time": "2024-10-16T08:16:33+00:00" }, { "name": "utopia-php/domains", @@ -2175,16 +2175,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.9", + "version": "0.6.11", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "ce97cdf2ca82e7cec78e2ed484ef2c71ebe8744b" + "reference": "4d167914d3f7fa1fe816b2b2c6f221e70166bfd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/ce97cdf2ca82e7cec78e2ed484ef2c71ebe8744b", - "reference": "ce97cdf2ca82e7cec78e2ed484ef2c71ebe8744b", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/4d167914d3f7fa1fe816b2b2c6f221e70166bfd7", + "reference": "4d167914d3f7fa1fe816b2b2c6f221e70166bfd7", "shasum": "" }, "require": { @@ -2225,9 +2225,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.9" + "source": "https://github.com/utopia-php/migration/tree/0.6.11" }, - "time": "2024-10-16T08:33:21+00:00" + "time": "2024-10-31T06:19:57+00:00" }, { "name": "utopia-php/mongo", @@ -2714,16 +2714,16 @@ }, { "name": "utopia-php/system", - "version": "0.8.0", + "version": "0.9.0", "source": { "type": "git", "url": "https://github.com/utopia-php/system.git", - "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e" + "reference": "8e4a7edaf2dfeb4c9524e9f766d27754f2c4b64d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/system/zipball/a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", - "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", + "url": "https://api.github.com/repos/utopia-php/system/zipball/8e4a7edaf2dfeb4c9524e9f766d27754f2c4b64d", + "reference": "8e4a7edaf2dfeb4c9524e9f766d27754f2c4b64d", "shasum": "" }, "require": { @@ -2764,9 +2764,9 @@ ], "support": { "issues": "https://github.com/utopia-php/system/issues", - "source": "https://github.com/utopia-php/system/tree/0.8.0" + "source": "https://github.com/utopia-php/system/tree/0.9.0" }, - "time": "2024-04-01T10:22:28+00:00" + "time": "2024-10-09T14:44:01+00:00" }, { "name": "utopia-php/vcs", @@ -5875,16 +5875,16 @@ }, { "name": "symfony/console", - "version": "v7.1.5", + "version": "v7.1.6", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee" + "reference": "bb5192af6edc797cbab5c8e8ecfea2fe5f421e57" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0fa539d12b3ccf068a722bbbffa07ca7079af9ee", - "reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee", + "url": "https://api.github.com/repos/symfony/console/zipball/bb5192af6edc797cbab5c8e8ecfea2fe5f421e57", + "reference": "bb5192af6edc797cbab5c8e8ecfea2fe5f421e57", "shasum": "" }, "require": { @@ -5948,7 +5948,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.5" + "source": "https://github.com/symfony/console/tree/v7.1.6" }, "funding": [ { @@ -5964,7 +5964,7 @@ "type": "tidelift" } ], - "time": "2024-09-20T08:28:38+00:00" + "time": "2024-10-09T08:46:59+00:00" }, { "name": "symfony/deprecation-contracts", @@ -6035,16 +6035,16 @@ }, { "name": "symfony/filesystem", - "version": "v7.1.5", + "version": "v7.1.6", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a" + "reference": "c835867b3c62bb05c7fe3d637c871c7ae52024d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/61fe0566189bf32e8cfee78335d8776f64a66f5a", - "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/c835867b3c62bb05c7fe3d637c871c7ae52024d4", + "reference": "c835867b3c62bb05c7fe3d637c871c7ae52024d4", "shasum": "" }, "require": { @@ -6081,7 +6081,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.1.5" + "source": "https://github.com/symfony/filesystem/tree/v7.1.6" }, "funding": [ { @@ -6097,20 +6097,20 @@ "type": "tidelift" } ], - "time": "2024-09-17T09:16:35+00:00" + "time": "2024-10-25T15:11:02+00:00" }, { "name": "symfony/finder", - "version": "v7.1.4", + "version": "v7.1.6", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "d95bbf319f7d052082fb7af147e0f835a695e823" + "reference": "2cb89664897be33f78c65d3d2845954c8d7a43b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/d95bbf319f7d052082fb7af147e0f835a695e823", - "reference": "d95bbf319f7d052082fb7af147e0f835a695e823", + "url": "https://api.github.com/repos/symfony/finder/zipball/2cb89664897be33f78c65d3d2845954c8d7a43b8", + "reference": "2cb89664897be33f78c65d3d2845954c8d7a43b8", "shasum": "" }, "require": { @@ -6145,7 +6145,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.1.4" + "source": "https://github.com/symfony/finder/tree/v7.1.6" }, "funding": [ { @@ -6161,20 +6161,20 @@ "type": "tidelift" } ], - "time": "2024-08-13T14:28:19+00:00" + "time": "2024-10-01T08:31:23+00:00" }, { "name": "symfony/options-resolver", - "version": "v7.1.1", + "version": "v7.1.6", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "47aa818121ed3950acd2b58d1d37d08a94f9bf55" + "reference": "85e95eeede2d41cd146146e98c9c81d9214cae85" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/47aa818121ed3950acd2b58d1d37d08a94f9bf55", - "reference": "47aa818121ed3950acd2b58d1d37d08a94f9bf55", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/85e95eeede2d41cd146146e98c9c81d9214cae85", + "reference": "85e95eeede2d41cd146146e98c9c81d9214cae85", "shasum": "" }, "require": { @@ -6212,7 +6212,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v7.1.1" + "source": "https://github.com/symfony/options-resolver/tree/v7.1.6" }, "funding": [ { @@ -6228,7 +6228,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/polyfill-ctype", @@ -6546,16 +6546,16 @@ }, { "name": "symfony/process", - "version": "v7.1.5", + "version": "v7.1.6", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "5c03ee6369281177f07f7c68252a280beccba847" + "reference": "6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/5c03ee6369281177f07f7c68252a280beccba847", - "reference": "5c03ee6369281177f07f7c68252a280beccba847", + "url": "https://api.github.com/repos/symfony/process/zipball/6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e", + "reference": "6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e", "shasum": "" }, "require": { @@ -6587,7 +6587,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.1.5" + "source": "https://github.com/symfony/process/tree/v7.1.6" }, "funding": [ { @@ -6603,7 +6603,7 @@ "type": "tidelift" } ], - "time": "2024-09-19T21:48:23+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/service-contracts", @@ -6690,16 +6690,16 @@ }, { "name": "symfony/string", - "version": "v7.1.5", + "version": "v7.1.6", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306" + "reference": "61b72d66bf96c360a727ae6232df5ac83c71f626" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/d66f9c343fa894ec2037cc928381df90a7ad4306", - "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306", + "url": "https://api.github.com/repos/symfony/string/zipball/61b72d66bf96c360a727ae6232df5ac83c71f626", + "reference": "61b72d66bf96c360a727ae6232df5ac83c71f626", "shasum": "" }, "require": { @@ -6757,7 +6757,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.5" + "source": "https://github.com/symfony/string/tree/v7.1.6" }, "funding": [ { @@ -6773,7 +6773,7 @@ "type": "tidelift" } ], - "time": "2024-09-20T08:28:38+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "textalk/websocket", @@ -7003,9 +7003,18 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/cache", + "version": "dev-feat-redis-sync", + "alias": "0.10.2", + "alias_normalized": "0.10.2.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/cache": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { From 16a2d618745e5d0487750a7262d6d04270f1f127 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 31 Oct 2024 17:43:49 +0200 Subject: [PATCH 093/144] Rollback cross regions connections --- app/cli.php | 8 --- app/controllers/shared/api.php | 17 +++--- app/init.php | 39 +++++--------- app/realtime.php | 13 ++--- app/worker.php | 25 ++++----- src/Appwrite/Messaging/Adapter/Realtime.php | 11 ++-- src/Appwrite/Platform/Tasks/ScheduleBase.php | 21 ++++---- .../Platform/Tasks/ScheduleExecutions.php | 5 +- .../Platform/Tasks/ScheduleFunctions.php | 7 ++- .../Platform/Tasks/ScheduleMessages.php | 7 ++- src/Appwrite/Platform/Workers/Builds.php | 24 +++------ .../Platform/Workers/Certificates.php | 53 +++++++------------ src/Appwrite/Platform/Workers/Databases.php | 49 ++++++----------- src/Appwrite/Platform/Workers/Deletes.php | 1 - src/Appwrite/Platform/Workers/Functions.php | 19 +------ src/Appwrite/Platform/Workers/Messaging.php | 2 +- src/Appwrite/Platform/Workers/Migrations.php | 50 +++++++---------- 17 files changed, 119 insertions(+), 232 deletions(-) diff --git a/app/cli.php b/app/cli.php index 0b76afc2e1..ca635d9543 100644 --- a/app/cli.php +++ b/app/cli.php @@ -162,23 +162,15 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, CLI::setResource('queue', function (Group $pools) { return $pools->get('queue')->pop()->getResource(); }, ['pools']); - -CLI::setResource('poolForQueue', function (Group $pools) { - return $pools->get('queue'); -}, ['pools']); - CLI::setResource('queueForFunctions', function (Connection $queue) { return new Func($queue); }, ['queue']); - CLI::setResource('queueForDeletes', function (Connection $queue) { return new Delete($queue); }, ['queue']); - CLI::setResource('queueForCertificates', function (Connection $queue) { return new Certificate($queue); }, ['queue']); - CLI::setResource('logError', function (Registry $register) { return function (Throwable $error, string $namespace, string $action) use ($register) { $logger = $register->get('logger'); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index f4be41544d..81af833c9f 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -162,7 +162,6 @@ App::init() ->inject('mode') ->inject('team') ->action(function (App $utopia, Request $request, Database $dbForConsole, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team) { - $route = $utopia->getRoute(); if ($project->isEmpty()) { @@ -364,6 +363,7 @@ App::init() ->inject('dbForProject') ->inject('mode') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Usage $queueForUsage, Database $dbForProject, string $mode) use ($databaseListener) { + $route = $utopia->getRoute(); if ( @@ -461,7 +461,6 @@ App::init() ->on(Database::EVENT_DOCUMENT_DELETE, 'calculate-usage', fn ($event, $document) => $databaseListener($event, $document, $project, $queueForUsage, $dbForProject)); $useCache = $route->getLabel('cache', false); - if ($useCache) { $key = md5($request->getURI() . '*' . implode('*', $request->getParams()) . '*' . APP_CACHE_BUSTER); $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); @@ -470,8 +469,8 @@ App::init() ); $timestamp = 60 * 60 * 24 * 30; $data = $cache->load($key, $timestamp); + if (!empty($data) && !$cacheLog->isEmpty()) { - $timerStart = \microtime(true); $parts = explode('/', $cacheLog->getAttribute('resourceType')); $type = $parts[0] ?? null; @@ -552,7 +551,6 @@ App::shutdown() ->inject('project') ->inject('dbForProject') ->action(function (App $utopia, Request $request, Response $response, Document $project, Database $dbForProject) { - $route = $utopia->getRoute(); $sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS_DEFAULT; $session = $response->getPayload(); $userId = $session['userId'] ?? ''; @@ -597,9 +595,8 @@ App::shutdown() ->inject('queueForFunctions') ->inject('mode') ->inject('dbForConsole') - ->inject('realtimeConnection') - ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole, callable $realtimeConnection) use ($parseLabel) { - $route = $utopia->getRoute(); + ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole) use ($parseLabel) { + $responsePayload = $response->getPayload(); if (!empty($queueForEvents->getEvent())) { @@ -645,7 +642,6 @@ App::shutdown() ); Realtime::send( - redis: $realtimeConnection($queueForEvents->getSourceRegion()), projectId: $target['projectId'] ?? $project->getId(), payload: $queueForEvents->getRealtimePayload(), events: $allEvents, @@ -713,11 +709,9 @@ App::shutdown() * Cache label */ $useCache = $route->getLabel('cache', false); - if ($useCache) { $resource = $resourceType = null; $data = $response->getPayload(); - if (!empty($data['payload'])) { $pattern = $route->getLabel('cache.resource', null); if (!empty($pattern)) { @@ -734,7 +728,6 @@ App::shutdown() $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); $accessedAt = $cacheLog->getAttribute('accessedAt', ''); $now = DateTime::now(); - if ($cacheLog->isEmpty()) { Authorization::skip(fn () => $dbForProject->createDocument('cache', new Document([ '$id' => $key, @@ -761,6 +754,8 @@ App::shutdown() } } + + if ($project->getId() !== 'console') { if (!Auth::isPrivilegedUser(Authorization::getRoles())) { $fileSize = 0; diff --git a/app/init.php b/app/init.php index 09c919dade..d6f7d8c984 100644 --- a/app/init.php +++ b/app/init.php @@ -1530,33 +1530,23 @@ App::setResource('deviceForLocal', function () { return new Local(); }); -App::setResource('deviceForFiles', function ($project, $connectionString) { - return getDevice(APP_STORAGE_UPLOADS.'/app-'.$project->getId(), $connectionString); -}, ['project', 'connectionString']); +App::setResource('deviceForFiles', function ($project) { + return getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); +}, ['project']); -App::setResource('deviceForFunctions', function ($project, $connectionString) { - return getDevice(APP_STORAGE_FUNCTIONS.'/app-'.$project->getId(), $connectionString); -}, ['project', 'connectionString']); +App::setResource('deviceForFunctions', function ($project) { + return getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()); +}, ['project']); -App::setResource('deviceForBuilds', function ($project, $connectionString) { - return getDevice(APP_STORAGE_BUILDS.'/app-'.$project->getId(), $connectionString); -}, ['project', 'connectionString']); +App::setResource('deviceForBuilds', function ($project) { + return getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()); +}, ['project']); -App::setResource('connectionString', function () { - return System::getEnv('_APP_CONNECTIONS_STORAGE', ''); -}); - -App::setResource('realtimeConnection',function ($pools) { - return function () use ($pools) { - return $pools->get('pubsub')->pop()->getResource(); - }; -}, ['pools']); - - -function getDevice(string $root, string $connectionString = ''): Device +function getDevice(string $root, string $connection = ''): Device { + $connection = !empty($connection) ? $connection : System::getEnv('_APP_CONNECTIONS_STORAGE', ''); - if (! empty($connectionString)) { + if (!empty($connection)) { $acl = 'private'; $device = Storage::DEVICE_LOCAL; $accessKey = ''; @@ -1565,7 +1555,7 @@ function getDevice(string $root, string $connectionString = ''): Device $region = ''; try { - $dsn = new DSN($connectionString); + $dsn = new DSN($connection); $device = $dsn->getScheme(); $accessKey = $dsn->getUser() ?? ''; $accessSecret = $dsn->getPassword() ?? ''; @@ -1826,9 +1816,6 @@ App::setResource('team', function (Document $project, Database $dbForConsole, Ap ]); }); - if (!$team) { - $team = new Document([]); - } return $team; }, ['project', 'dbForConsole', 'utopia', 'request']); diff --git a/app/realtime.php b/app/realtime.php index 6ca4639f85..2e95756e76 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -137,17 +137,14 @@ if (!function_exists('getCache')) { } } -if (!function_exists("getPubSub")) { - function getPubSub(): \Redis +if (!function_exists('getRealtime')) { + function getRealtime(): Realtime { - global $register; - - $pools = $register->get('pools'); /** @var \Utopia\Pools\Group $pools */ - return $pools->get('pubsub')->pop()->getResource(); + return new Realtime(); } } -$realtime = new Realtime(); +$realtime = getRealtime(); /** * Table for statistics across all workers. @@ -370,7 +367,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, } $start = time(); - $redis = getPubSub(); /** @var \Redis $redis */ + $redis = $register->get('pools')->get('pubsub')->pop()->getResource(); /** @var Redis $redis */ $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); if ($redis->ping(true)) { diff --git a/app/worker.php b/app/worker.php index e3fd7d1f7b..25defba3f8 100644 --- a/app/worker.php +++ b/app/worker.php @@ -262,20 +262,20 @@ Server::setResource('pools', function (Registry $register) { return $register->get('pools'); }, ['register']); -Server::setResource('deviceForFunctions', function (Document $project, $connectionString) { - return getDevice(APP_STORAGE_FUNCTIONS.'/app-'.$project->getId(), $connectionString); -}, ['project', 'connectionString']); +Server::setResource('deviceForFunctions', function (Document $project) { + return getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()); +}, ['project']); -Server::setResource('deviceForFiles', function (Document $project, $connectionString) { - return getDevice(APP_STORAGE_UPLOADS.'/app-'.$project->getId(), $connectionString); -}, ['project', 'connectionString']); +Server::setResource('deviceForFiles', function (Document $project) { + return getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); +}, ['project']); -Server::setResource('deviceForBuilds', function (Document $project, $connectionString) { - return getDevice(APP_STORAGE_BUILDS.'/app-'.$project->getId(), $connectionString); -}, ['project', 'connectionString']); +Server::setResource('deviceForBuilds', function (Document $project) { + return getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()); +}, ['project']); Server::setResource('deviceForCache', function (Document $project) { - return getDevice(APP_STORAGE_CACHE.'/app-'.$project->getId()); + return getDevice(APP_STORAGE_CACHE . '/app-' . $project->getId()); }, ['project']); Server::setResource( @@ -283,11 +283,6 @@ Server::setResource( fn () => fn (Document $project, string $resourceType, ?string $resourceId) => false ); -Server::setResource('realtimeConnection',function ($pools) { - return function () use ($pools) { - return $pools->get('pubsub')->pop()->getResource(); - }; -}, ['pools']); $pools = $register->get('pools'); $platform = new Appwrite(); diff --git a/src/Appwrite/Messaging/Adapter/Realtime.php b/src/Appwrite/Messaging/Adapter/Realtime.php index 079a02428d..c437d4d487 100644 --- a/src/Appwrite/Messaging/Adapter/Realtime.php +++ b/src/Appwrite/Messaging/Adapter/Realtime.php @@ -122,17 +122,15 @@ class Realtime extends Adapter /** * Sends an event to the Realtime Server - * @param \Redis $redis * @param string $projectId * @param array $payload - * @param array $events + * @param string $event * @param array $channels * @param array $roles * @param array $options * @return void - * @throws \RedisException */ - public static function send(\Redis $redis, string $projectId, array $payload, array $events, array $channels, array $roles, array $options = []): void + public static function send(string $projectId, array $payload, array $events, array $channels, array $roles, array $options = []): void { if (empty($channels) || empty($roles) || empty($projectId)) { return; @@ -140,8 +138,9 @@ class Realtime extends Adapter $permissionsChanged = array_key_exists('permissionsChanged', $options) && $options['permissionsChanged']; $userId = array_key_exists('userId', $options) ? $options['userId'] : null; - var_dump($redis->getHost()); - var_dump($channels); + + $redis = new \Redis(); //TODO: make this part of the constructor + $redis->connect(System::getEnv('_APP_REDIS_HOST', ''), System::getEnv('_APP_REDIS_PORT', '')); $redis->publish('realtime', json_encode([ 'project' => $projectId, 'roles' => $roles, diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index abe614829f..a1b85c341f 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -11,7 +11,6 @@ use Utopia\Database\Exception; use Utopia\Database\Query; use Utopia\Platform\Action; use Utopia\Pools\Group; -use Utopia\Pools\Pool; use Utopia\System\System; use function Swoole\Coroutine\run; @@ -26,7 +25,7 @@ abstract class ScheduleBase extends Action abstract public static function getName(): string; abstract public static function getSupportedResource(): string; abstract public static function getCollectionId(): string; - abstract protected function enqueueResources(\Utopia\Pools\Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void; + abstract protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void; public function __construct() { @@ -34,10 +33,10 @@ abstract class ScheduleBase extends Action $this ->desc("Execute {$type}s scheduled in Appwrite") - ->inject('poolForQueue') + ->inject('pools') ->inject('dbForConsole') ->inject('getProjectDB') - ->callback(fn (Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB) => $this->action($poolForQueue, $dbForConsole, $getProjectDB)); + ->callback(fn (Group $pools, Database $dbForConsole, callable $getProjectDB) => $this->action($pools, $dbForConsole, $getProjectDB)); } /** @@ -45,7 +44,7 @@ abstract class ScheduleBase extends Action * 2. Create timer that sync all changes from 'schedules' collection to local copy. Only reading changes thanks to 'resourceUpdatedAt' attribute * 3. Create timer that prepares coroutines for soon-to-execute schedules. When it's ready, coroutine sleeps until exact time before sending request to worker. */ - public function action(Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void + public function action(Group $pools, Database $dbForConsole, callable $getProjectDB): void { Console::title(\ucfirst(static::getSupportedResource()) . ' scheduler V1'); Console::success(APP_NAME . ' ' . \ucfirst(static::getSupportedResource()) . ' scheduler v1 has started'); @@ -114,17 +113,17 @@ abstract class ScheduleBase extends Action $latestDocument = \end($results); } - $poolForQueue->reclaim(); + $pools->reclaim(); Console::success("{$total} resources were loaded in " . (\microtime(true) - $loadStart) . " seconds"); Console::success("Starting timers at " . DateTime::now()); - run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $poolForQueue, $getProjectDB) { + run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools, $getProjectDB) { /** * The timer synchronize $schedules copy with database collection. */ - Timer::tick(static::UPDATE_TIMER * 1000, function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $poolForQueue) { + Timer::tick(static::UPDATE_TIMER * 1000, function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools) { $time = DateTime::now(); $timerStart = \microtime(true); @@ -173,17 +172,17 @@ abstract class ScheduleBase extends Action $lastSyncUpdate = $time; $timerEnd = \microtime(true); - $poolForQueue->reclaim(); + $pools->reclaim(); Console::log("Sync tick: {$total} schedules were updated in " . ($timerEnd - $timerStart) . " seconds"); }); Timer::tick( static::ENQUEUE_TIMER * 1000, - fn () => $this->enqueueResources($poolForQueue, $dbForConsole, $getProjectDB) + fn () => $this->enqueueResources($pools, $dbForConsole, $getProjectDB) ); - $this->enqueueResources($poolForQueue, $dbForConsole, $getProjectDB); + $this->enqueueResources($pools, $dbForConsole, $getProjectDB); }); } } diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 58fc07b019..73a2814397 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -6,7 +6,6 @@ use Appwrite\Event\Func; use Swoole\Coroutine as Co; use Utopia\Database\Database; use Utopia\Pools\Group; -use Utopia\Pools\Pool; class ScheduleExecutions extends ScheduleBase { @@ -28,9 +27,9 @@ class ScheduleExecutions extends ScheduleBase return 'executions'; } - protected function enqueueResources(\Utopia\Pools\Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void + protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void { - $queue = $poolForQueue->pop(); + $queue = $pools->get('queue')->pop(); $connection = $queue->getResource(); $queueForFunctions = new Func($connection); $intervalEnd = (new \DateTime())->modify('+' . self::ENQUEUE_TIMER . ' seconds'); diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index 8095e812a9..4d57902330 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -8,7 +8,6 @@ use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Pools\Group; -use Utopia\Pools\Pool; class ScheduleFunctions extends ScheduleBase { @@ -32,7 +31,7 @@ class ScheduleFunctions extends ScheduleBase return 'functions'; } - protected function enqueueResources(\Utopia\Pools\Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void + protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void { $timerStart = \microtime(true); $time = DateTime::now(); @@ -71,10 +70,10 @@ class ScheduleFunctions extends ScheduleBase } foreach ($delayedExecutions as $delay => $scheduleKeys) { - \go(function () use ($delay, $scheduleKeys, $poolForQueue) { + \go(function () use ($delay, $scheduleKeys, $pools) { \sleep($delay); // in seconds - $queue = $poolForQueue->pop(); + $queue = $pools->get('queue')->pop(); $connection = $queue->getResource(); foreach ($scheduleKeys as $scheduleKey) { diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 3167e29f7a..b9d8e2a282 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -5,7 +5,6 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Messaging; use Utopia\Database\Database; use Utopia\Pools\Group; -use Utopia\Pools\Pool; class ScheduleMessages extends ScheduleBase { @@ -27,7 +26,7 @@ class ScheduleMessages extends ScheduleBase return 'messages'; } - protected function enqueueResources(\Utopia\Pools\Pool $poolForQueue, Database $dbForConsole, callable $getProjectDB): void + protected function enqueueResources(Group $pools, Database $dbForConsole, callable $getProjectDB): void { foreach ($this->schedules as $schedule) { if (!$schedule['active']) { @@ -41,8 +40,8 @@ class ScheduleMessages extends ScheduleBase continue; } - \go(function () use ($schedule, $poolForQueue, $dbForConsole) { - $queue = $poolForQueue->pop(); + \go(function () use ($schedule, $pools, $dbForConsole) { + $queue = $pools->get('queue')->pop(); $connection = $queue->getResource(); $queueForMessaging = new Messaging($connection); diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 36fe1a6d1a..5dd2f7f886 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -33,11 +33,6 @@ use Utopia\VCS\Adapter\Git\GitHub; class Builds extends Action { - /** - * @var mixed|string - */ - protected string $sourceRegion; - public static function getName(): string { return 'builds'; @@ -59,8 +54,7 @@ class Builds extends Action ->inject('dbForProject') ->inject('deviceForFunctions') ->inject('log') - ->inject('realtimeConnection') - ->callback(fn ($message, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Usage $usage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log, Callable $realtimeConnection) => $this->action($message, $dbForConsole, $queueForEvents, $queueForFunctions, $usage, $cache, $dbForProject, $deviceForFunctions, $log, $realtimeConnection)); + ->callback(fn ($message, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Usage $usage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log) => $this->action($message, $dbForConsole, $queueForEvents, $queueForFunctions, $usage, $cache, $dbForProject, $deviceForFunctions, $log)); } /** @@ -73,11 +67,10 @@ class Builds extends Action * @param Database $dbForProject * @param Device $deviceForFunctions * @param Log $log - * @param callable $realtimeConnection * @return void * @throws \Utopia\Database\Exception */ - public function action(Message $message, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Usage $queueForUsage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log, Callable $realtimeConnection): void + public function action(Message $message, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Usage $queueForUsage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log): void { $payload = $message->getPayload() ?? []; @@ -90,7 +83,6 @@ class Builds extends Action $resource = new Document($payload['resource'] ?? []); $deployment = new Document($payload['deployment'] ?? []); $template = new Document($payload['template'] ?? []); - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); @@ -100,7 +92,7 @@ class Builds extends Action case BUILD_TYPE_RETRY: Console::info('Creating build for deployment: ' . $deployment->getId()); $github = new GitHub($cache); - $this->buildDeployment($deviceForFunctions, $queueForFunctions, $queueForEvents, $queueForUsage, $dbForConsole, $dbForProject, $github, $project, $resource, $deployment, $template, $log, $realtimeConnection); + $this->buildDeployment($deviceForFunctions, $queueForFunctions, $queueForEvents, $queueForUsage, $dbForConsole, $dbForProject, $github, $project, $resource, $deployment, $template, $log); break; default: @@ -125,7 +117,7 @@ class Builds extends Action * @throws \Utopia\Database\Exception * @throws Exception */ - protected function buildDeployment(Device $deviceForFunctions, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Database $dbForConsole, Database $dbForProject, GitHub $github, Document $project, Document $function, Document $deployment, Document $template, Log $log, Callable $realtimeConnection): void + protected function buildDeployment(Device $deviceForFunctions, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Database $dbForConsole, Database $dbForProject, GitHub $github, Document $project, Document $function, Document $deployment, Document $template, Log $log): void { $executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST')); @@ -384,7 +376,6 @@ class Builds extends Action project: $project ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $build->getArrayCopy(), events: $allEvents, @@ -463,7 +454,6 @@ class Builds extends Action ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $build->getArrayCopy(), events: $allEvents, @@ -562,12 +552,12 @@ class Builds extends Action $err = $error; } }), - Co\go(function () use ($realtimeConnection, $executor, $project, $deployment, &$response, &$build, $dbForProject, $allEvents, &$err, &$isCanceled) { + Co\go(function () use ($executor, $project, $deployment, &$response, &$build, $dbForProject, $allEvents, &$err, &$isCanceled) { try { $executor->getLogs( deploymentId: $deployment->getId(), projectId: $project->getId(), - callback: function ($logs) use ($realtimeConnection, &$response, &$err, &$build, $dbForProject, $allEvents, $project, &$isCanceled) { + callback: function ($logs) use (&$response, &$err, &$build, $dbForProject, $allEvents, $project, &$isCanceled) { if ($isCanceled) { return; } @@ -601,7 +591,6 @@ class Builds extends Action project: $project ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $build->getArrayCopy(), events: $allEvents, @@ -704,7 +693,6 @@ class Builds extends Action project: $project ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $build->getArrayCopy(), events: $allEvents, diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index dcc42a87fc..a14f164295 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -30,11 +30,6 @@ use Utopia\System\System; class Certificates extends Action { - /** - * @var mixed|string - */ - protected string $sourceRegion; - public static function getName(): string { return 'certificates'; @@ -53,8 +48,7 @@ class Certificates extends Action ->inject('queueForEvents') ->inject('queueForFunctions') ->inject('log') - ->inject('realtimeConnection') - ->callback(fn (Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, Callable $realtimeConnection) => $this->action($message, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log, $realtimeConnection)); + ->callback(fn (Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log) => $this->action($message, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log)); } /** @@ -64,12 +58,11 @@ class Certificates extends Action * @param Event $queueForEvents * @param Func $queueForFunctions * @param Log $log - * @param callable $realtimeConnection * @return void * @throws Throwable * @throws \Utopia\Database\Exception */ - public function action(Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, Callable $realtimeConnection): void + public function action(Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log): void { $payload = $message->getPayload() ?? []; @@ -80,10 +73,10 @@ class Certificates extends Action $document = new Document($payload['domain'] ?? []); $domain = new Domain($document->getAttribute('domain', '')); $skipRenewCheck = $payload['skipRenewCheck'] ?? false; - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; $log->addTag('domain', $domain->get()); - $this->execute($domain, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log,$realtimeConnection, $skipRenewCheck); + + $this->execute($domain, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log, $skipRenewCheck); } /** @@ -92,17 +85,12 @@ class Certificates extends Action * @param Mail $queueForMails * @param Event $queueForEvents * @param Func $queueForFunctions - * @param Log $log - * @param callable $realtimeConnection * @param bool $skipRenewCheck * @return void - * @throws Authorization - * @throws Conflict - * @throws Structure * @throws Throwable * @throws \Utopia\Database\Exception */ - protected function execute(Domain $domain, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, Callable $realtimeConnection, bool $skipRenewCheck = false): void + private function execute(Domain $domain, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, bool $skipRenewCheck = false): void { /** * 1. Read arguments and validate domain @@ -138,7 +126,7 @@ class Certificates extends Action $certificate = $dbForConsole->findOne('certificates', [Query::equal('domain', [$domain->get()])]); // If we don't have certificate for domain yet, let's create new document. At the end we save it - if (!$certificate) { + if ($certificate->isEmpty()) { $certificate = new Document(); $certificate->setAttribute('domain', $domain->get()); } @@ -174,6 +162,7 @@ class Certificates extends Action $logs = 'Certificate successfully generated.'; $certificate->setAttribute('logs', \mb_strcut($logs, 0, 1000000));// Limit to 1MB + // Give certificates to Traefik $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); @@ -204,7 +193,7 @@ class Certificates extends Action $certificate->setAttribute('updated', DateTime::now()); // Save all changes we made to certificate document into database - $this->saveCertificateDocument($domain->get(), $certificate, $success, $dbForConsole, $queueForEvents, $queueForFunctions, $realtimeConnection); + $this->saveCertificateDocument($domain->get(), $certificate, $success, $dbForConsole, $queueForEvents, $queueForFunctions); } } @@ -223,11 +212,11 @@ class Certificates extends Action * @throws Conflict * @throws Structure */ - protected function saveCertificateDocument(string $domain, Document $certificate, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Callable $realtimeConnection): void + private function saveCertificateDocument(string $domain, Document $certificate, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions): void { // Check if update or insert required $certificateDocument = $dbForConsole->findOne('certificates', [Query::equal('domain', [$domain])]); - if (!empty($certificateDocument) && !$certificateDocument->isEmpty()) { + if (!$certificateDocument->isEmpty()) { // Merge new data with current data $certificate = new Document(\array_merge($certificateDocument->getArrayCopy(), $certificate->getArrayCopy())); $certificate = $dbForConsole->updateDocument('certificates', $certificate->getId(), $certificate); @@ -237,7 +226,7 @@ class Certificates extends Action } $certificateId = $certificate->getId(); - $this->updateDomainDocuments($certificateId, $domain, $success, $dbForConsole, $queueForEvents, $queueForFunctions, $realtimeConnection); + $this->updateDomainDocuments($certificateId, $domain, $success, $dbForConsole, $queueForEvents, $queueForFunctions); } /** @@ -245,7 +234,7 @@ class Certificates extends Action * * @return null|string Returns main domain. If null, there is no main domain yet. */ - protected function getMainDomain(): ?string + private function getMainDomain(): ?string { $envDomain = System::getEnv('_APP_DOMAIN', ''); if (!empty($envDomain) && $envDomain !== 'localhost') { @@ -266,7 +255,7 @@ class Certificates extends Action * @return void * @throws Exception */ - protected function validateDomain(Domain $domain, bool $isMainDomain, Log $log): void + private function validateDomain(Domain $domain, bool $isMainDomain, Log $log): void { if (empty($domain->get())) { throw new Exception('Missing certificate domain.'); @@ -310,7 +299,7 @@ class Certificates extends Action * @return bool True, if certificate needs to be renewed * @throws Exception */ - protected function isRenewRequired(string $domain, Log $log): bool + private function isRenewRequired(string $domain, Log $log): bool { $certPath = APP_STORAGE_CERTIFICATES . '/' . $domain . '/cert.pem'; if (\file_exists($certPath)) { @@ -344,7 +333,7 @@ class Certificates extends Action * @return array Named array with keys 'stdout' and 'stderr', both string * @throws Exception */ - protected function issueCertificate(string $folder, string $domain, string $email): array + private function issueCertificate(string $folder, string $domain, string $email): array { $stdout = ''; $stderr = ''; @@ -374,7 +363,7 @@ class Certificates extends Action * @return string * @throws \Utopia\Database\Exception */ - protected function getRenewDate(string $domain): string + private function getRenewDate(string $domain): string { $certPath = APP_STORAGE_CERTIFICATES . '/' . $domain . '/cert.pem'; $certData = openssl_x509_parse(file_get_contents($certPath)); @@ -392,7 +381,7 @@ class Certificates extends Action * @return void * @throws Exception */ - protected function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void + private function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void { // Prepare folder in storage for domain @@ -443,7 +432,7 @@ class Certificates extends Action * @return void * @throws Exception */ - protected function notifyError(string $domain, string $errorMessage, int $attempt, Mail $queueForMails): void + private function notifyError(string $domain, string $errorMessage, int $attempt, Mail $queueForMails): void { // Log error into console Console::warning('Cannot renew domain (' . $domain . ') on attempt no. ' . $attempt . ' certificate: ' . $errorMessage); @@ -486,14 +475,14 @@ class Certificates extends Action * * @return void */ - protected function updateDomainDocuments(string $certificateId, string $domain, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions, Callable $realtimeConnection): void + private function updateDomainDocuments(string $certificateId, string $domain, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions): void { $rule = $dbForConsole->findOne('rules', [ Query::equal('domain', [$domain]), ]); - if ($rule !== false && !$rule->isEmpty()) { + if (!$rule->isEmpty()) { $rule->setAttribute('certificateId', $certificateId); $rule->setAttribute('status', $success ? 'verified' : 'unverified'); $dbForConsole->updateDocument('rules', $rule->getId(), $rule); @@ -536,7 +525,6 @@ class Certificates extends Action project: $project ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $rule->getArrayCopy(), events: $allEvents, @@ -544,7 +532,6 @@ class Certificates extends Action roles: $target['roles'] ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: $project->getId(), payload: $rule->getArrayCopy(), events: $allEvents, diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 0bb448e4a3..f697e7be13 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -17,15 +17,9 @@ use Utopia\Database\Query; use Utopia\Logger\Log; use Utopia\Platform\Action; use Utopia\Queue\Message; -use Utopia\System\System; class Databases extends Action { - /** - * @var array|mixed - */ - protected string $sourceRegion; - public static function getName(): string { return 'databases'; @@ -42,8 +36,7 @@ class Databases extends Action ->inject('dbForConsole') ->inject('dbForProject') ->inject('log') - ->inject('realtimeConnection') - ->callback(fn (Message $message, Database $dbForConsole, Database $dbForProject, Log $log, callable $realtimeConnection) => $this->action($message, $dbForConsole, $dbForProject, $log, $realtimeConnection)); + ->callback(fn (Message $message, Database $dbForConsole, Database $dbForProject, Log $log) => $this->action($message, $dbForConsole, $dbForProject, $log)); } /** @@ -51,11 +44,10 @@ class Databases extends Action * @param Database $dbForConsole * @param Database $dbForProject * @param Log $log - * @param callable $realtimeConnection * @return void * @throws \Exception */ - public function action(Message $message, Database $dbForConsole, Database $dbForProject, Log $log, callable $realtimeConnection): void + public function action(Message $message, Database $dbForConsole, Database $dbForProject, Log $log): void { $payload = $message->getPayload() ?? []; @@ -68,7 +60,6 @@ class Databases extends Action $collection = new Document($payload['collection'] ?? []); $document = new Document($payload['document'] ?? []); $database = new Document($payload['database'] ?? []); - $this->sourceRegion = $payload['sourceRegion'] ?? null; $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); @@ -82,10 +73,10 @@ class Databases extends Action match (\strval($type)) { DATABASE_TYPE_DELETE_DATABASE => $this->deleteDatabase($database, $project, $dbForProject), DATABASE_TYPE_DELETE_COLLECTION => $this->deleteCollection($database, $collection, $project, $dbForProject), - DATABASE_TYPE_CREATE_ATTRIBUTE => $this->createAttribute($database, $collection, $document, $project, $dbForConsole, $dbForProject, $realtimeConnection), - DATABASE_TYPE_DELETE_ATTRIBUTE => $this->deleteAttribute($database, $collection, $document, $project, $dbForConsole, $dbForProject, $realtimeConnection), - DATABASE_TYPE_CREATE_INDEX => $this->createIndex($database, $collection, $document, $project, $dbForConsole, $dbForProject, $realtimeConnection), - DATABASE_TYPE_DELETE_INDEX => $this->deleteIndex($database, $collection, $document, $project, $dbForConsole, $dbForProject, $realtimeConnection), + DATABASE_TYPE_CREATE_ATTRIBUTE => $this->createAttribute($database, $collection, $document, $project, $dbForConsole, $dbForProject), + DATABASE_TYPE_DELETE_ATTRIBUTE => $this->deleteAttribute($database, $collection, $document, $project, $dbForConsole, $dbForProject), + DATABASE_TYPE_CREATE_INDEX => $this->createIndex($database, $collection, $document, $project, $dbForConsole, $dbForProject), + DATABASE_TYPE_DELETE_INDEX => $this->deleteIndex($database, $collection, $document, $project, $dbForConsole, $dbForProject), default => throw new \Exception('No database operation for type: ' . \strval($type)), }; } @@ -97,13 +88,12 @@ class Databases extends Action * @param Document $project * @param Database $dbForConsole * @param Database $dbForProject - * @param callable $realtimeConnection * @return void * @throws Authorization * @throws Conflict * @throws \Exception */ - private function createAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void + private function createAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); @@ -144,6 +134,7 @@ class Databases extends Action $options = $attribute->getAttribute('options', []); $project = $dbForConsole->getDocument('projects', $projectId); + try { switch ($type) { case Database::VAR_RELATIONSHIP: @@ -203,7 +194,7 @@ class Databases extends Action ); } } finally { - $this->trigger($database, $collection, $attribute, $project, $projectId, $events, $realtimeConnection); + $this->trigger($database, $collection, $attribute, $project, $projectId, $events); } if ($type === Database::VAR_RELATIONSHIP && $options['twoWay']) { @@ -220,7 +211,6 @@ class Databases extends Action * @param Document $project * @param Database $dbForConsole * @param Database $dbForProject - * @param callable $realtimeConnection * @return void * @throws Authorization * @throws Conflict @@ -305,7 +295,7 @@ class Databases extends Action ); } } finally { - $this->trigger($database, $collection, $attribute, $project, $projectId, $events, $realtimeConnection); + $this->trigger($database, $collection, $attribute, $project, $projectId, $events); } // The underlying database removes/rebuilds indexes when attribute is removed @@ -375,14 +365,13 @@ class Databases extends Action * @param Document $project * @param Database $dbForConsole * @param Database $dbForProject - * @param callable $realtimeConnection * @return void * @throws Authorization * @throws Conflict * @throws Structure * @throws DatabaseException */ - private function createIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void + private function createIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); @@ -424,7 +413,7 @@ class Databases extends Action $index->setAttribute('status', 'failed') ); } finally { - $this->trigger($database, $collection, $index, $project, $projectId, $events, $realtimeConnection); + $this->trigger($database, $collection, $index, $project, $projectId, $events); } $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); @@ -437,14 +426,13 @@ class Databases extends Action * @param Document $project * @param Database $dbForConsole * @param Database $dbForProject - * @param callable $realtimeConnection * @return void * @throws Authorization * @throws Conflict * @throws Structure * @throws DatabaseException */ - private function deleteIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject, callable $realtimeConnection): void + private function deleteIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); @@ -483,7 +471,7 @@ class Databases extends Action $index->setAttribute('status', 'stuck') ); } finally { - $this->trigger($database, $collection, $index, $project, $projectId, $events, $realtimeConnection); + $this->trigger($database, $collection, $index, $project, $projectId, $events); } $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collection->getId()); @@ -606,20 +594,14 @@ class Databases extends Action Console::info("Deleted {$count} document by group in " . ($executionEnd - $executionStart) . " seconds"); } - /** - * @throws \RedisException - * @throws Exception - */ protected function trigger( Document $database, Document $collection, Document $attribute, Document $project, string $projectId, - array $events, - callable $realtimeConnection + array $events ): void { - var_dump('Send message to realtime region='.$this->sourceRegion); $target = Realtime::fromPayload( // Pass first, most verbose event pattern event: $events[0], @@ -627,7 +609,6 @@ class Databases extends Action project: $project, ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $attribute->getArrayCopy(), events: $events, diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 700a480065..b9ff2e9609 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -494,7 +494,6 @@ class Deletes extends Action ]; $limit = \count($projectCollectionIds) + 25; - $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); while (true) { $collections = $dbForProject->listCollections($limit); diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index a315239600..72a3334f2f 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -28,11 +28,6 @@ use Utopia\System\System; class Functions extends Action { - /** - * @var mixed|string - */ - protected string $sourceRegion; - public static function getName(): string { return 'functions'; @@ -54,12 +49,10 @@ class Functions extends Action ->inject('queueForUsage') ->inject('log') ->inject('isResourceBlocked') - ->inject('realtimeConnection') - ->callback(fn (Document $project, Message $message, Database $dbForProject, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Log $log, callable $isResourceBlocked, Callable $realtimeConnection) => $this->action($project, $message, $dbForProject, $queueForFunctions, $queueForEvents, $queueForUsage, $log, $isResourceBlocked, $realtimeConnection)); - + ->callback(fn (Document $project, Message $message, Database $dbForProject, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Log $log, callable $isResourceBlocked) => $this->action($project, $message, $dbForProject, $queueForFunctions, $queueForEvents, $queueForUsage, $log, $isResourceBlocked)); } - public function action(Document $project, Message $message, Database $dbForProject, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Log $log, callable $isResourceBlocked, Callable $realtimeConnection): void + public function action(Document $project, Message $message, Database $dbForProject, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Log $log, callable $isResourceBlocked): void { $payload = $message->getPayload() ?? []; @@ -104,8 +97,6 @@ class Functions extends Action return; } - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; - if ($function->isEmpty() && !empty($functionId)) { $function = $dbForProject->getDocument('functions', $functionId); } @@ -143,7 +134,6 @@ class Functions extends Action Console::success('Iterating function: ' . $function->getAttribute('name')); $this->execute( - realtimeConnection: $realtimeConnection, log: $log, dbForProject: $dbForProject, queueForFunctions: $queueForFunctions, @@ -184,7 +174,6 @@ class Functions extends Action $execution = new Document($payload['execution'] ?? []); $user = new Document($payload['user'] ?? []); $this->execute( - realtimeConnection: $realtimeConnection, log: $log, dbForProject: $dbForProject, queueForFunctions: $queueForFunctions, @@ -207,7 +196,6 @@ class Functions extends Action case 'schedule': $execution = new Document($payload['execution'] ?? []); $this->execute( - realtimeConnection: $realtimeConnection, log: $log, dbForProject: $dbForProject, queueForFunctions: $queueForFunctions, @@ -317,7 +305,6 @@ class Functions extends Action * @throws Conflict */ private function execute( - Callable $realtimeConnection, Log $log, Database $dbForProject, Func $queueForFunctions, @@ -610,7 +597,6 @@ class Functions extends Action project: $project ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $execution->getArrayCopy(), events: $allEvents, @@ -618,7 +604,6 @@ class Functions extends Action roles: $target['roles'] ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: $project->getId(), payload: $execution->getArrayCopy(), events: $allEvents, diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 510fec0431..58f6265ff4 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -178,7 +178,7 @@ class Messaging extends Action Query::equal('type', [$providerType]), ]); - if ($default === false || $default->isEmpty()) { + if ($default->isEmpty()) { $dbForProject->updateDocument('messages', $message->getId(), $message->setAttributes([ 'status' => MessageStatus::FAILED, 'deliveryErrors' => ['No enabled provider found.'] diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 283c716379..d430d0eb67 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -36,10 +36,6 @@ class Migrations extends Action protected Database $dbForConsole; protected Document $project; - /** - * @var string - */ - protected string $sourceRegion; public static function getName(): string { @@ -57,14 +53,13 @@ class Migrations extends Action ->inject('dbForProject') ->inject('dbForConsole') ->inject('log') - ->inject('realtimeConnection') - ->callback(fn (Message $message, Database $dbForProject, Database $dbForConsole, Log $log, Callable $realtimeConnection) => $this->action($message, $dbForProject, $dbForConsole, $log, $realtimeConnection)); + ->callback(fn (Message $message, Database $dbForProject, Database $dbForConsole, Log $log) => $this->action($message, $dbForProject, $dbForConsole, $log)); } /** * @throws Exception */ - public function action(Message $message, Database $dbForProject, Database $dbForConsole, Log $log, Callable $realtimeConnection): void + public function action(Message $message, Database $dbForProject, Database $dbForConsole, Log $log): void { $payload = $message->getPayload() ?? []; @@ -80,7 +75,6 @@ class Migrations extends Action return; } - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; $this->dbForProject = $dbForProject; $this->dbForConsole = $dbForConsole; $this->project = $project; @@ -95,7 +89,7 @@ class Migrations extends Action $log->addTag('migrationId', $migration->getId()); $log->addTag('projectId', $project->getId()); - $this->processMigration($migration, $log, $realtimeConnection); + $this->processMigration($migration, $log); } /** @@ -130,7 +124,7 @@ class Migrations extends Action ), SourceAppwrite::getName() => new SourceAppwrite( $credentials['projectId'], - $credentials['endpoint'], + $credentials['endpoint'] === 'http://localhost/v1' ? 'http://appwrite/v1' : $credentials['endpoint'], $credentials['apiKey'], ), default => throw new \Exception('Invalid source type'), @@ -140,16 +134,15 @@ class Migrations extends Action /** * @throws Exception */ - protected function processDestination(Document $migration): Destination + protected function processDestination(Document $migration, string $apiKey): Destination { $destination = $migration->getAttribute('destination'); - $credentials = $migration->getAttribute('credentials'); return match ($destination) { DestinationAppwrite::getName() => new DestinationAppwrite( - $credentials['projectId'], - $credentials['endpoint'], - $credentials['apiKey'], + $this->project->getId(), + 'http://appwrite/v1', + $apiKey, $this->dbForProject, Config::getParam('collections', [])['databases']['collections'], ), @@ -164,7 +157,7 @@ class Migrations extends Action * @throws \Utopia\Database\Exception * @throws Exception */ - protected function updateMigrationDocument(Document $migration, Document $project, Callable $realtimeConnection): Document + protected function updateMigrationDocument(Document $migration, Document $project): Document { /** Trigger Realtime */ $allEvents = Event::generateEvents('migrations.[migrationId].update', [ @@ -178,7 +171,6 @@ class Migrations extends Action ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: 'console', payload: $migration->getArrayCopy(), events: $allEvents, @@ -187,7 +179,6 @@ class Migrations extends Action ); Realtime::send( - redis: $realtimeConnection($this->sourceRegion), projectId: $project->getId(), payload: $migration->getArrayCopy(), events: $allEvents, @@ -261,11 +252,6 @@ class Migrations extends Action } /** - * @param Document $project - * @param Document $migration - * @param Log $log - * @param callable $realtimeConnection - * @return void * @throws Authorization * @throws Conflict * @throws Restricted @@ -273,7 +259,7 @@ class Migrations extends Action * @throws \Utopia\Database\Exception * @throws Exception */ - protected function processMigration(Document $migration, Log $log, Callable $realtimeConnection): void + protected function processMigration(Document $migration, Log $log): void { $project = $this->project; $projectDocument = $this->dbForConsole->getDocument('projects', $project->getId()); @@ -285,8 +271,8 @@ class Migrations extends Action $migration = $this->dbForProject->getDocument('migrations', $migration->getId()); if ( - $migration->getAttribute('source') === SourceAppwrite::getName() || - $migration->getAttribute('destination') === DestinationAppwrite::getName() + $migration->getAttribute('source') === SourceAppwrite::getName() && + empty($migration->getAttribute('credentials', [])) ) { $credentials = $migration->getAttribute('credentials', []); @@ -299,12 +285,12 @@ class Migrations extends Action $migration->setAttribute('stage', 'processing'); $migration->setAttribute('status', 'processing'); - $this->updateMigrationDocument($migration, $projectDocument, $realtimeConnection); + $this->updateMigrationDocument($migration, $projectDocument); $log->addTag('type', $migration->getAttribute('source')); $source = $this->processSource($migration); - $destination = $this->processDestination($migration); + $destination = $this->processDestination($migration, $tempAPIKey->getAttribute('secret')); $source->report(); @@ -315,14 +301,14 @@ class Migrations extends Action /** Start Transfer */ $migration->setAttribute('stage', 'migrating'); - $this->updateMigrationDocument($migration, $projectDocument, $realtimeConnection); + $this->updateMigrationDocument($migration, $projectDocument); $transfer->run( $migration->getAttribute('resources'), function () use ($migration, $transfer, $projectDocument) { $migration->setAttribute('resourceData', json_encode($transfer->getCache())); $migration->setAttribute('statusCounters', json_encode($transfer->getStatusCounters())); - $this->updateMigrationDocument($migration, $projectDocument, $realtimeConnection); + $this->updateMigrationDocument($migration, $projectDocument); }, $migration->getAttribute('resourceId'), $migration->getAttribute('resourceType') @@ -361,7 +347,7 @@ class Migrations extends Action $migration->setAttribute('errors', $errorMessages); $log->addExtra('migrationErrors', json_encode($errorMessages)); - $this->updateMigrationDocument($migration, $projectDocument, $realtimeConnection); + $this->updateMigrationDocument($migration, $projectDocument); return; } @@ -402,7 +388,7 @@ class Migrations extends Action $this->removeAPIKey($tempAPIKey); } - $this->updateMigrationDocument($migration, $projectDocument, $realtimeConnection); + $this->updateMigrationDocument($migration, $projectDocument); if ($migration->getAttribute('status', '') === 'failed') { Console::error('Migration('.$migration->getInternalId().':'.$migration->getId().') failed, Project('.$this->project->getInternalId().':'.$this->project->getId().')'); From 9e07579a52b7e76a08a2a67af5890298f99bae1d Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 31 Oct 2024 21:38:27 +0200 Subject: [PATCH 094/144] Rollback cross regions connections --- src/Appwrite/Platform/Workers/Certificates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index a14f164295..66fc14c2ca 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -381,7 +381,7 @@ class Certificates extends Action * @return void * @throws Exception */ - private function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void + protected function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void { // Prepare folder in storage for domain From 4eafce998d36bce9d3a662f2a784009137600d88 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 3 Nov 2024 14:58:09 +0200 Subject: [PATCH 095/144] Rollback cross regions connections --- src/Appwrite/Event/Build.php | 1 - src/Appwrite/Event/Certificate.php | 1 - src/Appwrite/Event/Database.php | 1 - src/Appwrite/Event/Event.php | 9 --------- src/Appwrite/Event/Func.php | 1 - src/Appwrite/Event/Migration.php | 1 - 6 files changed, 14 deletions(-) diff --git a/src/Appwrite/Event/Build.php b/src/Appwrite/Event/Build.php index 237803a7ff..b8cb62a6f8 100644 --- a/src/Appwrite/Event/Build.php +++ b/src/Appwrite/Event/Build.php @@ -115,7 +115,6 @@ class Build extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ - 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'resource' => $this->resource, 'deployment' => $this->deployment, diff --git a/src/Appwrite/Event/Certificate.php b/src/Appwrite/Event/Certificate.php index 188e6dd27d..85058c96fe 100644 --- a/src/Appwrite/Event/Certificate.php +++ b/src/Appwrite/Event/Certificate.php @@ -77,7 +77,6 @@ class Certificate extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ - 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'domain' => $this->domain, 'skipRenewCheck' => $this->skipRenewCheck diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 4b53b71d99..f5f29f5d04 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -122,7 +122,6 @@ class Database extends Event try { $result = $client->enqueue([ - 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'user' => $this->user, 'type' => $this->type, diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 9445ea4129..0cf28ebe5c 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -111,14 +111,6 @@ class Event return $this->event; } - - - public function getSourceRegion(): string - { - var_dump('event Source Region='.System::getEnv('_APP_REGION')); - return System::getEnv('_APP_REGION'); - } - /** * Set project for this event. * @@ -331,7 +323,6 @@ class Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ - 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'user' => $this->user, 'userId' => $this->userId, diff --git a/src/Appwrite/Event/Func.php b/src/Appwrite/Event/Func.php index b14e781750..4dad5802f7 100644 --- a/src/Appwrite/Event/Func.php +++ b/src/Appwrite/Event/Func.php @@ -222,7 +222,6 @@ class Func extends Event $events = $this->getEvent() ? Event::generateEvents($this->getEvent(), $this->getParams()) : null; return $client->enqueue([ - 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'user' => $this->user, 'userId' => $this->userId, diff --git a/src/Appwrite/Event/Migration.php b/src/Appwrite/Event/Migration.php index dd8db4097e..e57ac3c87c 100644 --- a/src/Appwrite/Event/Migration.php +++ b/src/Appwrite/Event/Migration.php @@ -79,7 +79,6 @@ class Migration extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ - 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'user' => $this->user, 'migration' => $this->migration, From cca0c3ae45864421295b3b48d41998ff36e6680c Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 5 Nov 2024 12:59:11 +0545 Subject: [PATCH 096/144] Make compression param whitelist strict --- app/controllers/api/storage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index dda39a0db0..ed10c84912 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -68,7 +68,7 @@ App::post('/v1/storage/buckets') ->param('enabled', true, new Boolean(true), 'Is bucket enabled? When set to \'disabled\', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.', true) ->param('maximumFileSize', fn (array $plan) => empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000, fn (array $plan) => new Range(1, empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(System::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true, ['plan']) ->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true) - ->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) + ->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD], true), 'Compression algorithm choosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) ->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true) ->param('antivirus', true, new Boolean(true), 'Is virus scanning enabled? For file size above ' . Storage::human(APP_LIMIT_ANTIVIRUS, 0) . ' AntiVirus scanning is skipped even if it\'s enabled', true) ->inject('response') From 028c5366c20b9a88699f88cdf72d1f4627dd9d1e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 5 Nov 2024 08:12:58 +0000 Subject: [PATCH 097/144] make compression nullable and assign default in action - also update the `update bucket` endpoint --- app/controllers/api/storage.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index ed10c84912..911481a1c0 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -74,13 +74,13 @@ App::post('/v1/storage/buckets') ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') - ->action(function (string $bucketId, string $name, ?array $permissions, bool $fileSecurity, bool $enabled, int $maximumFileSize, array $allowedFileExtensions, string $compression, bool $encryption, bool $antivirus, Response $response, Database $dbForProject, Event $queueForEvents) { + ->action(function (string $bucketId, string $name, ?array $permissions, bool $fileSecurity, bool $enabled, int $maximumFileSize, array $allowedFileExtensions, ?string $compression, bool $encryption, bool $antivirus, Response $response, Database $dbForProject, Event $queueForEvents) { $bucketId = $bucketId === 'unique()' ? ID::unique() : $bucketId; // Map aggregate permissions into the multiple permissions they represent. $permissions = Permission::aggregate($permissions); - + $compression ??= Compression::NONE; try { $files = (Config::getParam('collections', [])['buckets'] ?? [])['files'] ?? []; if (empty($files)) { @@ -254,13 +254,13 @@ App::put('/v1/storage/buckets/:bucketId') ->param('enabled', true, new Boolean(true), 'Is bucket enabled? When set to \'disabled\', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.', true) ->param('maximumFileSize', fn (array $plan) => empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000, fn (array $plan) => new Range(1, empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(System::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true, ['plan']) ->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true) - ->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) + ->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD], true), 'Compression algorithm choosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) ->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true) ->param('antivirus', true, new Boolean(true), 'Is virus scanning enabled? For file size above ' . Storage::human(APP_LIMIT_ANTIVIRUS, 0) . ' AntiVirus scanning is skipped even if it\'s enabled', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') - ->action(function (string $bucketId, string $name, ?array $permissions, bool $fileSecurity, bool $enabled, ?int $maximumFileSize, array $allowedFileExtensions, string $compression, bool $encryption, bool $antivirus, Response $response, Database $dbForProject, Event $queueForEvents) { + ->action(function (string $bucketId, string $name, ?array $permissions, bool $fileSecurity, bool $enabled, ?int $maximumFileSize, array $allowedFileExtensions, ?string $compression, bool $encryption, bool $antivirus, Response $response, Database $dbForProject, Event $queueForEvents) { $bucket = $dbForProject->getDocument('buckets', $bucketId); if ($bucket->isEmpty()) { @@ -273,6 +273,7 @@ App::put('/v1/storage/buckets/:bucketId') $enabled ??= $bucket->getAttribute('enabled', true); $encryption ??= $bucket->getAttribute('encryption', true); $antivirus ??= $bucket->getAttribute('antivirus', true); + $compression ??= $bucket->getAttribute('compression', Compression::NONE); // Map aggregate permissions into the multiple permissions they represent. $permissions = Permission::aggregate($permissions); From c2d5e8ec11e41df4801ed5459181bf19b189f8d7 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 5 Nov 2024 12:03:57 +0200 Subject: [PATCH 098/144] Rollback cross regions connections --- src/Appwrite/Messaging/Adapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Messaging/Adapter.php b/src/Appwrite/Messaging/Adapter.php index 6104d27c53..794fd9b3ed 100644 --- a/src/Appwrite/Messaging/Adapter.php +++ b/src/Appwrite/Messaging/Adapter.php @@ -8,5 +8,5 @@ abstract class Adapter abstract public function unsubscribe(mixed $identifier): void; - abstract public static function send(\redis $redis, string $projectId, array $payload, array $events, array $channels, array $roles, array $options): void; + abstract public static function send(string $projectId, array $payload, array $events, array $channels, array $roles, array $options): void; } From 2b3e7f67a488bb91351b60be65d5d1e548a68fb2 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 5 Nov 2024 12:21:16 +0200 Subject: [PATCH 099/144] Rollback cross regions connections --- app/controllers/api/functions.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 6a2ba3540c..785bccb206 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -184,8 +184,7 @@ App::post('/v1/functions') ->inject('queueForBuilds') ->inject('dbForConsole') ->inject('gitHub') - ->inject('realtimeConnection') - ->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $githubgithub, Callable $realtimeConnection) use ($redeployVcs) { + ->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $githubgithub) use ($redeployVcs) { $functionId = ($functionId == 'unique()') ? ID::unique() : $functionId; $allowList = \array_filter(\explode(',', System::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); @@ -376,7 +375,6 @@ App::post('/v1/functions') project: $project ); Realtime::send( - redis: $realtimeConnection($queueForEvents->getSourceRegion()), projectId: 'console', payload: $rule->getArrayCopy(), events: $allEvents, @@ -384,7 +382,6 @@ App::post('/v1/functions') roles: $target['roles'] ); Realtime::send( - redis: $realtimeConnection($queueForEvents->getSourceRegion()), projectId: $project->getId(), payload: $rule->getArrayCopy(), events: $allEvents, From c3a8db0ea4747ff8e714176eda7b8c2ceba027a8 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 5 Nov 2024 17:14:23 +0200 Subject: [PATCH 100/144] Rollback cross regions connections --- app/controllers/api/databases.php | 1 + app/controllers/api/functions.php | 2 +- app/controllers/api/messaging.php | 4 ++-- app/controllers/api/projects.php | 8 +------- app/controllers/general.php | 11 ++--------- app/http.php | 3 +-- src/Appwrite/Event/Database.php | 1 - src/Appwrite/Event/Event.php | 1 - src/Appwrite/Messaging/Adapter.php | 2 -- src/Appwrite/Migration/Version/V19.php | 2 +- src/Appwrite/Platform/Workers/Certificates.php | 2 +- src/Appwrite/Utopia/Response/Model/Func.php | 2 +- 12 files changed, 11 insertions(+), 28 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 9334c449df..70374b5331 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -3,6 +3,7 @@ use Appwrite\Auth\Auth; use Appwrite\Detector\Detector; use Appwrite\Event\Database as EventDatabase; +use Appwrite\Event\Delete; use Appwrite\Event\Event; use Appwrite\Event\Usage; use Appwrite\Extend\Exception; diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 785bccb206..cd35f42e8b 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -184,7 +184,7 @@ App::post('/v1/functions') ->inject('queueForBuilds') ->inject('dbForConsole') ->inject('gitHub') - ->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $githubgithub) use ($redeployVcs) { + ->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) use ($redeployVcs) { $functionId = ($functionId == 'unique()') ? ID::unique() : $functionId; $allowList = \array_filter(\explode(',', System::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 2d5b386c9d..57d3a1ea61 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -3037,7 +3037,7 @@ App::post('/v1/messaging/messages/push') break; case MessageStatus::SCHEDULED: $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => $project->getAttribute('region'), + 'region' => System::getEnv('_APP_REGION', 'default'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3592,7 +3592,7 @@ App::patch('/v1/messaging/messages/sms/:messageId') if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) { $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => $project->getAttribute('region'), + 'region' => System::getEnv('_APP_REGION', 'default'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 7867b42aab..fcbe9dea05 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -124,18 +124,12 @@ App::post('/v1/projects') } $databases = Config::getParam('pools-database', []); + $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); $index = \array_search($databaseOverride, $databases); if ($index !== false) { $dsn = $databases[$index]; } else { - - if ($region !== 'default') { - $databases = array_filter($databases, function ($value) use ($region) { - return str_contains($value, $region); - }); - } - $dsn = $databases[array_rand($databases)]; } diff --git a/app/controllers/general.php b/app/controllers/general.php index e996342cfd..7763566159 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -59,12 +59,6 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo ]) )[0] ?? null; -// var_dump(System::getEnv('_APP_DOMAIN_FUNCTIONS', '')); -// var_dump($host); -// var_dump(APP_HOSTNAME_INTERNAL); -// var_dump($request->getHeader('host')); -// var_dump($request->getHeader('x-forwarded-host')); - if ($route === null) { if ($host === System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain cannot be used for security reasons. Please use any subdomain instead.'); @@ -472,8 +466,7 @@ App::init() /* * Appwrite Router */ - - $host = $request->getHostname() ?? ''; + $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain if ($host !== $mainDomain) { @@ -674,7 +667,6 @@ App::init() ) { throw new AppwriteException(AppwriteException::GENERAL_UNKNOWN_ORIGIN, $originValidator->getDescription()); } - }); App::options() @@ -1030,6 +1022,7 @@ App::get('/.well-known/acme-challenge/*') ->action(function (Request $request, Response $response) { $uriChunks = \explode('/', $request->getURI()); $token = $uriChunks[\count($uriChunks) - 1]; + $validator = new Text(100, allowList: [ ...Text::NUMBERS, ...Text::ALPHABET_LOWER, diff --git a/app/http.php b/app/http.php index 9754263046..f4582ee6b7 100644 --- a/app/http.php +++ b/app/http.php @@ -16,7 +16,6 @@ use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; -use Utopia\Database\Exception\Duplicate; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; @@ -225,7 +224,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg }); }); -$http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) use ($register) { +$http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) use ($register) { App::setResource('swooleRequest', fn () => $swooleRequest); App::setResource('swooleResponse', fn () => $swooleResponse); diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index f5f29f5d04..f9eb7d9a7d 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -108,7 +108,6 @@ class Database extends Event */ public function trigger(): string|bool { - try { $dsn = new DSN($this->getProject()->getAttribute('database')); } catch (\InvalidArgumentException) { diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 0cf28ebe5c..43eda511df 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -6,7 +6,6 @@ use InvalidArgumentException; use Utopia\Database\Document; use Utopia\Queue\Client; use Utopia\Queue\Connection; -use Utopia\System\System; class Event { diff --git a/src/Appwrite/Messaging/Adapter.php b/src/Appwrite/Messaging/Adapter.php index 794fd9b3ed..27dd7f68eb 100644 --- a/src/Appwrite/Messaging/Adapter.php +++ b/src/Appwrite/Messaging/Adapter.php @@ -5,8 +5,6 @@ namespace Appwrite\Messaging; abstract class Adapter { abstract public function subscribe(string $projectId, mixed $identifier, array $roles, array $channels): void; - abstract public function unsubscribe(mixed $identifier): void; - abstract public static function send(string $projectId, array $payload, array $events, array $channels, array $roles, array $options): void; } diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index 039169f3a6..18234ebdc4 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -731,7 +731,7 @@ class V19 extends Migration if (empty($document->getAttribute('scheduleId', null))) { $schedule = $this->consoleDB->createDocument('schedules', new Document([ - 'region' => $project->getAttribute('region'), + 'region' => System::getEnv('_APP_REGION', 'default'), // Todo replace with projects region 'resourceType' => 'function', 'resourceId' => $document->getId(), 'resourceInternalId' => $document->getInternalId(), diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 66fc14c2ca..a14f164295 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -381,7 +381,7 @@ class Certificates extends Action * @return void * @throws Exception */ - protected function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void + private function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void { // Prepare folder in storage for domain diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index ab2d7ba051..f4ff214d0b 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -94,7 +94,7 @@ class Func extends Model ]) ->addRule('schedule', [ 'type' => self::TYPE_STRING, - 'description' => 'Function execution schedule in CRON format.', + 'description' => 'Function execution schedult in CRON format.', 'default' => '', 'example' => '5 4 * * *', ]) From e219ee2d842317fc6200a5556307eadcb5db6fdd Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 6 Nov 2024 10:02:11 +0000 Subject: [PATCH 101/144] upgrade utopia storage --- composer.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/composer.lock b/composer.lock index 6dce436601..39f5753510 100644 --- a/composer.lock +++ b/composer.lock @@ -2608,16 +2608,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.5", + "version": "0.18.6", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919" + "reference": "893ccf06e183f8ece2aed8dbf14d64d6ba036071" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/7d355c5e3ccc8ecebc0266f8ddd30088a43be919", - "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/893ccf06e183f8ece2aed8dbf14d64d6ba036071", + "reference": "893ccf06e183f8ece2aed8dbf14d64d6ba036071", "shasum": "" }, "require": { @@ -2657,9 +2657,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.5" + "source": "https://github.com/utopia-php/storage/tree/0.18.6" }, - "time": "2024-09-04T08:57:27+00:00" + "time": "2024-11-06T09:58:50+00:00" }, { "name": "utopia-php/swoole", @@ -5875,16 +5875,16 @@ }, { "name": "symfony/console", - "version": "v7.1.6", + "version": "v7.1.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "bb5192af6edc797cbab5c8e8ecfea2fe5f421e57" + "reference": "3284aafcac338b6e86fd955ee4d794cbe434151a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/bb5192af6edc797cbab5c8e8ecfea2fe5f421e57", - "reference": "bb5192af6edc797cbab5c8e8ecfea2fe5f421e57", + "url": "https://api.github.com/repos/symfony/console/zipball/3284aafcac338b6e86fd955ee4d794cbe434151a", + "reference": "3284aafcac338b6e86fd955ee4d794cbe434151a", "shasum": "" }, "require": { @@ -5948,7 +5948,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.6" + "source": "https://github.com/symfony/console/tree/v7.1.7" }, "funding": [ { @@ -5964,7 +5964,7 @@ "type": "tidelift" } ], - "time": "2024-10-09T08:46:59+00:00" + "time": "2024-11-05T15:34:55+00:00" }, { "name": "symfony/deprecation-contracts", @@ -6546,16 +6546,16 @@ }, { "name": "symfony/process", - "version": "v7.1.6", + "version": "v7.1.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e" + "reference": "9b8a40b7289767aa7117e957573c2a535efe6585" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e", - "reference": "6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e", + "url": "https://api.github.com/repos/symfony/process/zipball/9b8a40b7289767aa7117e957573c2a535efe6585", + "reference": "9b8a40b7289767aa7117e957573c2a535efe6585", "shasum": "" }, "require": { @@ -6587,7 +6587,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.1.6" + "source": "https://github.com/symfony/process/tree/v7.1.7" }, "funding": [ { @@ -6603,7 +6603,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2024-11-06T09:25:12+00:00" }, { "name": "symfony/service-contracts", From 36bff12939cf18c6194bcc2f6e4a28e1d94ed629 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 11:56:09 +0200 Subject: [PATCH 102/144] project creation fix --- app/controllers/api/projects.php | 90 ++++++++++++++------------------ composer.json | 2 +- 2 files changed, 40 insertions(+), 52 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index fcbe9dea05..7d8ddd8a79 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -31,7 +31,6 @@ use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; use Utopia\Database\Query; use Utopia\Database\Validator\Datetime as DatetimeValidator; -use Utopia\Database\Validator\Query\Cursor; use Utopia\Database\Validator\UID; use Utopia\Domains\Validator\PublicDomain; use Utopia\DSN\DSN; @@ -201,8 +200,7 @@ App::post('/v1/projects') if (\in_array($dsn->getHost(), $sharedTables)) { $dbForProject ->setSharedTables(true) - ->setTenant($project->getInternalId()) - //->setTenant($globalCollections ? null : $project->getInternalId()) + ->setTenant($globalCollections ? null : $project->getInternalId()) ->setNamespace($dsn->getParam('namespace')); } else { $dbForProject @@ -213,50 +211,46 @@ App::post('/v1/projects') $create = true; - // try { + try { $dbForProject->create(); - // } catch (Duplicate) { - // $create = false; - //} + } catch (Duplicate) { + $create = false; + } - $audit = new Audit($dbForProject); - $audit->setup(); + if ($create || !$globalCollections) { + $audit = new Audit($dbForProject); + $audit->setup(); - $abuse = new TimeLimit('', 0, 1, $dbForProject); - $abuse->setup(); + $abuse = new TimeLimit('', 0, 1, $dbForProject); + $abuse->setup(); - /** @var array $collections */ - $collections = Config::getParam('collections', [])['projects'] ?? []; + /** @var array $collections */ + $collections = Config::getParam('collections', [])['projects'] ?? []; - foreach ($collections as $key => $collection) { - if (($collection['$collection'] ?? '') !== Database::METADATA) { - continue; - } + foreach ($collections as $key => $collection) { + if (($collection['$collection'] ?? '') !== Database::METADATA) { + continue; + } - $attributes = \array_map(function (array $attribute) { - return new Document($attribute); - }, $collection['attributes']); - - $indexes = \array_map(function (array $index) { - return new Document($index); - }, $collection['indexes']); + $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); + $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); try { $dbForProject->createCollection($key, $attributes, $indexes); } catch (Duplicate) { -// if (!$globalCollections) { -// $dbForProject->createDocument(Database::METADATA, new Document([ -// '$id' => ID::custom($key), -// '$permissions' => [Permission::create(Role::any())], -// 'name' => $key, -// 'attributes' => $attributes, -// 'indexes' => $indexes, -// 'documentSecurity' => true -// ])); -// } + if (!$globalCollections) { + $dbForProject->createDocument(Database::METADATA, new Document([ + '$id' => ID::custom($key), + '$permissions' => [Permission::create(Role::any())], + 'name' => $key, + 'attributes' => $attributes, + 'indexes' => $indexes, + 'documentSecurity' => true + ])); + } } } - // } + } // Hook allowing instant project mirroring during migration // Outside of migration, hook is not registered and has no effect @@ -302,12 +296,6 @@ App::get('/v1/projects') $cursor = reset($cursor); if ($cursor) { /** @var Query $cursor */ - - $validator = new Cursor(); - if (!$validator->isValid($cursor)) { - throw new Exception(Exception::GENERAL_QUERY_INVALID, $validator->getDescription()); - } - $projectId = $cursor->getValue(); $cursorDocument = $dbForConsole->getDocument('projects', $projectId); @@ -1082,7 +1070,7 @@ App::get('/v1/projects/:projectId/webhooks/:webhookId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($webhook->isEmpty()) { + if ($webhook === false || $webhook->isEmpty()) { throw new Exception(Exception::WEBHOOK_NOT_FOUND); } @@ -1125,7 +1113,7 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($webhook->isEmpty()) { + if ($webhook === false || $webhook->isEmpty()) { throw new Exception(Exception::WEBHOOK_NOT_FOUND); } @@ -1175,7 +1163,7 @@ App::patch('/v1/projects/:projectId/webhooks/:webhookId/signature') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($webhook->isEmpty()) { + if ($webhook === false || $webhook->isEmpty()) { throw new Exception(Exception::WEBHOOK_NOT_FOUND); } @@ -1213,7 +1201,7 @@ App::delete('/v1/projects/:projectId/webhooks/:webhookId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($webhook->isEmpty()) { + if ($webhook === false || $webhook->isEmpty()) { throw new Exception(Exception::WEBHOOK_NOT_FOUND); } @@ -1335,7 +1323,7 @@ App::get('/v1/projects/:projectId/keys/:keyId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($key->isEmpty()) { + if ($key === false || $key->isEmpty()) { throw new Exception(Exception::KEY_NOT_FOUND); } @@ -1372,7 +1360,7 @@ App::put('/v1/projects/:projectId/keys/:keyId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($key->isEmpty()) { + if ($key === false || $key->isEmpty()) { throw new Exception(Exception::KEY_NOT_FOUND); } @@ -1414,7 +1402,7 @@ App::delete('/v1/projects/:projectId/keys/:keyId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($key->isEmpty()) { + if ($key === false || $key->isEmpty()) { throw new Exception(Exception::KEY_NOT_FOUND); } @@ -1572,7 +1560,7 @@ App::get('/v1/projects/:projectId/platforms/:platformId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($platform->isEmpty()) { + if ($platform === false || $platform->isEmpty()) { throw new Exception(Exception::PLATFORM_NOT_FOUND); } @@ -1609,7 +1597,7 @@ App::put('/v1/projects/:projectId/platforms/:platformId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($platform->isEmpty()) { + if ($platform === false || $platform->isEmpty()) { throw new Exception(Exception::PLATFORM_NOT_FOUND); } @@ -1653,7 +1641,7 @@ App::delete('/v1/projects/:projectId/platforms/:platformId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($platform->isEmpty()) { + if ($platform === false || $platform->isEmpty()) { throw new Exception(Exception::PLATFORM_NOT_FOUND); } diff --git a/composer.json b/composer.json index 5fc0cc2f36..d08806ea57 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "dev-feat-redis-sync as 0.10.2", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.9", + "utopia-php/database": "dev-feat-migrations as 0.53.9", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", From 59766b6ce66262cfbd10caeb49aa3c06101a0479 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 12:00:26 +0200 Subject: [PATCH 103/144] composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d08806ea57..6f52cf05a5 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "utopia-php/abuse": "0.43.0", "utopia-php/analytics": "0.10.*", "utopia-php/audit": "0.43.0", - "utopia-php/cache": "dev-feat-redis-sync as 0.10.2", + "utopia-php/cache": "dev-feat-redis-sync as 0.11.0", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", "utopia-php/database": "dev-feat-migrations as 0.53.9", From 2076a429c6c0a6911087d1e3cb7b775c834191b6 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 12:00:44 +0200 Subject: [PATCH 104/144] composer --- composer.lock | 143 ++++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 68 deletions(-) diff --git a/composer.lock b/composer.lock index a9d040fecc..c9050caea5 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": "f245bc714f5b1b539ec9083bb0526bd2", + "content-hash": "3c8f6c1184b149d8640d4e00394e2c62", "packages": [ { "name": "adhocore/jwt", @@ -1724,32 +1724,32 @@ }, { "name": "utopia-php/database", - "version": "0.53.8", + "version": "dev-feat-migrations", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "f4f9297d633b9f8407c6261535549bfd6024a468" + "reference": "ad8f67af4083b5ee78e3e6b59acbb296c4b933e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/f4f9297d633b9f8407c6261535549bfd6024a468", - "reference": "f4f9297d633b9f8407c6261535549bfd6024a468", + "url": "https://api.github.com/repos/utopia-php/database/zipball/ad8f67af4083b5ee78e3e6b59acbb296c4b933e1", + "reference": "ad8f67af4083b5ee78e3e6b59acbb296c4b933e1", "shasum": "" }, "require": { "ext-mbstring": "*", "ext-pdo": "*", - "php": ">=8.0", - "utopia-php/cache": "0.10.*", + "php": ">=8.3", + "utopia-php/cache": "0.11.*", "utopia-php/framework": "0.33.*", "utopia-php/mongo": "0.3.*" }, "require-dev": { "fakerphp/faker": "1.23.*", - "laravel/pint": "1.17.*", - "pcov/clobber": "2.0.*", - "phpstan/phpstan": "1.11.*", - "phpunit/phpunit": "9.6.*", + "laravel/pint": "1.*", + "pcov/clobber": "2.*", + "phpstan/phpstan": "1.*", + "phpunit/phpunit": "9.*", "rregeer/phpunit-coverage-check": "0.3.*", "swoole/ide-helper": "5.1.3", "utopia-php/cli": "0.14.*" @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.8" + "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-10-16T08:16:33+00:00" + "time": "2024-11-06T07:51:47+00:00" }, { "name": "utopia-php/domains", @@ -2495,16 +2495,16 @@ }, { "name": "utopia-php/queue", - "version": "0.7.0", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "917565256eb94bcab7246f7a746b1a486813761b" + "reference": "94c240d9f6383829807ce7b2d737f04b159fd3e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/queue/zipball/917565256eb94bcab7246f7a746b1a486813761b", - "reference": "917565256eb94bcab7246f7a746b1a486813761b", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/94c240d9f6383829807ce7b2d737f04b159fd3e8", + "reference": "94c240d9f6383829807ce7b2d737f04b159fd3e8", "shasum": "" }, "require": { @@ -2550,9 +2550,9 @@ ], "support": { "issues": "https://github.com/utopia-php/queue/issues", - "source": "https://github.com/utopia-php/queue/tree/0.7.0" + "source": "https://github.com/utopia-php/queue/tree/0.7.1" }, - "time": "2024-01-17T19:00:43+00:00" + "time": "2024-11-05T17:00:38+00:00" }, { "name": "utopia-php/registry", @@ -2608,16 +2608,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.5", + "version": "0.18.6", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919" + "reference": "893ccf06e183f8ece2aed8dbf14d64d6ba036071" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/7d355c5e3ccc8ecebc0266f8ddd30088a43be919", - "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/893ccf06e183f8ece2aed8dbf14d64d6ba036071", + "reference": "893ccf06e183f8ece2aed8dbf14d64d6ba036071", "shasum": "" }, "require": { @@ -2657,9 +2657,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.5" + "source": "https://github.com/utopia-php/storage/tree/0.18.6" }, - "time": "2024-09-04T08:57:27+00:00" + "time": "2024-11-06T09:58:50+00:00" }, { "name": "utopia-php/swoole", @@ -2770,22 +2770,22 @@ }, { "name": "utopia-php/vcs", - "version": "0.8.2", + "version": "0.8.3", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18" + "reference": "a032ed0611a8f4467aeaa9484f73223074457337" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", - "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/a032ed0611a8f4467aeaa9484f73223074457337", + "reference": "a032ed0611a8f4467aeaa9484f73223074457337", "shasum": "" }, "require": { "adhocore/jwt": "^1.1", "php": ">=8.0", - "utopia-php/cache": "^0.10.0", + "utopia-php/cache": "^0.11.0", "utopia-php/framework": "0.*.*" }, "require-dev": { @@ -2813,9 +2813,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.8.2" + "source": "https://github.com/utopia-php/vcs/tree/0.8.3" }, - "time": "2024-08-13T14:36:30+00:00" + "time": "2024-11-05T17:10:09+00:00" }, { "name": "utopia-php/websocket", @@ -4004,16 +4004,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.4.1", + "version": "5.5.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c" + "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", - "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0c70d2c566e899666f367ab7b80986beb3581e6f", + "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f", "shasum": "" }, "require": { @@ -4026,13 +4026,13 @@ "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.5", + "mockery/mockery": "~1.3.5 || ~1.6.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.8", "phpstan/phpstan-mockery": "^1.1", "phpstan/phpstan-webmozart-assert": "^1.2", "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^5.13" + "psalm/phar": "^5.26" }, "type": "library", "extra": { @@ -4062,29 +4062,29 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.1" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.5.1" }, - "time": "2024-05-21T05:55:05+00:00" + "time": "2024-11-06T11:58:54+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.8.2", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "153ae662783729388a584b4361f2545e4d841e3c" + "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/153ae662783729388a584b4361f2545e4d841e3c", - "reference": "153ae662783729388a584b4361f2545e4d841e3c", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1fb5ba8d045f5dd984ebded5b1cc66f29459422d", + "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d", "shasum": "" }, "require": { "doctrine/deprecations": "^1.0", "php": "^7.3 || ^8.0", "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.13" + "phpstan/phpdoc-parser": "^1.18" }, "require-dev": { "ext-tokenizer": "*", @@ -4120,9 +4120,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.2" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.9.0" }, - "time": "2024-02-23T11:10:43+00:00" + "time": "2024-11-03T20:11:34+00:00" }, { "name": "phpspec/prophecy", @@ -5875,16 +5875,16 @@ }, { "name": "symfony/console", - "version": "v7.1.6", + "version": "v7.1.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "bb5192af6edc797cbab5c8e8ecfea2fe5f421e57" + "reference": "3284aafcac338b6e86fd955ee4d794cbe434151a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/bb5192af6edc797cbab5c8e8ecfea2fe5f421e57", - "reference": "bb5192af6edc797cbab5c8e8ecfea2fe5f421e57", + "url": "https://api.github.com/repos/symfony/console/zipball/3284aafcac338b6e86fd955ee4d794cbe434151a", + "reference": "3284aafcac338b6e86fd955ee4d794cbe434151a", "shasum": "" }, "require": { @@ -5948,7 +5948,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.6" + "source": "https://github.com/symfony/console/tree/v7.1.7" }, "funding": [ { @@ -5964,7 +5964,7 @@ "type": "tidelift" } ], - "time": "2024-10-09T08:46:59+00:00" + "time": "2024-11-05T15:34:55+00:00" }, { "name": "symfony/deprecation-contracts", @@ -6546,16 +6546,16 @@ }, { "name": "symfony/process", - "version": "v7.1.6", + "version": "v7.1.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e" + "reference": "9b8a40b7289767aa7117e957573c2a535efe6585" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e", - "reference": "6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e", + "url": "https://api.github.com/repos/symfony/process/zipball/9b8a40b7289767aa7117e957573c2a535efe6585", + "reference": "9b8a40b7289767aa7117e957573c2a535efe6585", "shasum": "" }, "require": { @@ -6587,7 +6587,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.1.6" + "source": "https://github.com/symfony/process/tree/v7.1.7" }, "funding": [ { @@ -6603,7 +6603,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2024-11-06T09:25:12+00:00" }, { "name": "symfony/service-contracts", @@ -6876,16 +6876,16 @@ }, { "name": "twig/twig", - "version": "v3.14.0", + "version": "v3.14.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72" + "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72", - "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/f405356d20fb43603bcadc8b09bfb676cb04a379", + "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379", "shasum": "" }, "require": { @@ -6939,7 +6939,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.14.0" + "source": "https://github.com/twigphp/Twig/tree/v3.14.1" }, "funding": [ { @@ -6951,7 +6951,7 @@ "type": "tidelift" } ], - "time": "2024-09-09T17:55:12+00:00" + "time": "2024-11-06T18:17:38+00:00" }, { "name": "webmozart/glob", @@ -7007,13 +7007,20 @@ { "package": "utopia-php/cache", "version": "dev-feat-redis-sync", - "alias": "0.10.2", - "alias_normalized": "0.10.2.0" + "alias": "0.11.0", + "alias_normalized": "0.11.0.0" + }, + { + "package": "utopia-php/database", + "version": "dev-feat-migrations", + "alias": "0.53.9", + "alias_normalized": "0.53.9.0" } ], "minimum-stability": "stable", "stability-flags": { - "utopia-php/cache": 20 + "utopia-php/cache": 20, + "utopia-php/database": 20 }, "prefer-stable": false, "prefer-lowest": false, From eb083a7e10bb397172136f153c5abb70858c3811 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 12:22:18 +0200 Subject: [PATCH 105/144] composer --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index c9050caea5..a87669f262 100644 --- a/composer.lock +++ b/composer.lock @@ -1728,12 +1728,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "ad8f67af4083b5ee78e3e6b59acbb296c4b933e1" + "reference": "b593787982518583cc4795f5c1ef9d2152114572" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/ad8f67af4083b5ee78e3e6b59acbb296c4b933e1", - "reference": "ad8f67af4083b5ee78e3e6b59acbb296c4b933e1", + "url": "https://api.github.com/repos/utopia-php/database/zipball/b593787982518583cc4795f5c1ef9d2152114572", + "reference": "b593787982518583cc4795f5c1ef9d2152114572", "shasum": "" }, "require": { @@ -1776,7 +1776,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-11-06T07:51:47+00:00" + "time": "2024-11-07T10:21:15+00:00" }, { "name": "utopia-php/domains", From 2ed854893dc0b05c8a8afef493e282e02c904c08 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 12:32:48 +0200 Subject: [PATCH 106/144] composer --- composer.json | 2 +- composer.lock | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 6f52cf05a5..ecaf5ab125 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "utopia-php/abuse": "0.43.0", "utopia-php/analytics": "0.10.*", "utopia-php/audit": "0.43.0", - "utopia-php/cache": "dev-feat-redis-sync as 0.11.0", + "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", "utopia-php/database": "dev-feat-migrations as 0.53.9", diff --git a/composer.lock b/composer.lock index a87669f262..d89e07c917 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": "3c8f6c1184b149d8640d4e00394e2c62", + "content-hash": "1b8dd5d381483eb11e28015fc75cdbd7", "packages": [ { "name": "adhocore/jwt", @@ -1574,16 +1574,16 @@ }, { "name": "utopia-php/cache", - "version": "dev-feat-redis-sync", + "version": "0.11.0", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "572f3224f963a5fbd4bbb79d815b7e798a1666ed" + "reference": "8ebcab5aac7606331cef69b0081f6c9eff2e58bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cache/zipball/572f3224f963a5fbd4bbb79d815b7e798a1666ed", - "reference": "572f3224f963a5fbd4bbb79d815b7e798a1666ed", + "url": "https://api.github.com/repos/utopia-php/cache/zipball/8ebcab5aac7606331cef69b0081f6c9eff2e58bc", + "reference": "8ebcab5aac7606331cef69b0081f6c9eff2e58bc", "shasum": "" }, "require": { @@ -1594,7 +1594,7 @@ }, "require-dev": { "laravel/pint": "1.2.*", - "phpstan/phpstan": "1.9.x-dev", + "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^9.3", "vimeo/psalm": "4.13.1" }, @@ -1618,9 +1618,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cache/issues", - "source": "https://github.com/utopia-php/cache/tree/feat-redis-sync" + "source": "https://github.com/utopia-php/cache/tree/0.11.0" }, - "time": "2024-10-06T13:11:23+00:00" + "time": "2024-11-05T16:53:58+00:00" }, { "name": "utopia-php/cli", @@ -7004,12 +7004,6 @@ } ], "aliases": [ - { - "package": "utopia-php/cache", - "version": "dev-feat-redis-sync", - "alias": "0.11.0", - "alias_normalized": "0.11.0.0" - }, { "package": "utopia-php/database", "version": "dev-feat-migrations", @@ -7019,7 +7013,6 @@ ], "minimum-stability": "stable", "stability-flags": { - "utopia-php/cache": 20, "utopia-php/database": 20 }, "prefer-stable": false, From 68d017f452ff1fc284eccc24d1e4eccf0e564d4f Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 12:36:53 +0200 Subject: [PATCH 107/144] composer --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index d89e07c917..f850fbbf65 100644 --- a/composer.lock +++ b/composer.lock @@ -1728,12 +1728,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "b593787982518583cc4795f5c1ef9d2152114572" + "reference": "5af02bf3e3970c1cf0272954f6ee485ad42432e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/b593787982518583cc4795f5c1ef9d2152114572", - "reference": "b593787982518583cc4795f5c1ef9d2152114572", + "url": "https://api.github.com/repos/utopia-php/database/zipball/5af02bf3e3970c1cf0272954f6ee485ad42432e9", + "reference": "5af02bf3e3970c1cf0272954f6ee485ad42432e9", "shasum": "" }, "require": { @@ -1776,7 +1776,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-11-07T10:21:15+00:00" + "time": "2024-11-07T10:32:18+00:00" }, { "name": "utopia-php/domains", From b22188251d140066cba66aac2034c0a78dc41cb3 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 12:41:00 +0200 Subject: [PATCH 108/144] composer --- composer.json | 2 +- composer.lock | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index ecaf5ab125..63d77bef8e 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "utopia-php/abuse": "0.43.0", "utopia-php/analytics": "0.10.*", "utopia-php/audit": "0.43.0", - "utopia-php/cache": "0.11.*", + "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", "utopia-php/database": "dev-feat-migrations as 0.53.9", diff --git a/composer.lock b/composer.lock index f850fbbf65..09a183ec8c 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": "1b8dd5d381483eb11e28015fc75cdbd7", + "content-hash": "a81b69f9e1d6bae201c8c2491c7725c1", "packages": [ { "name": "adhocore/jwt", @@ -1574,16 +1574,16 @@ }, { "name": "utopia-php/cache", - "version": "0.11.0", + "version": "0.10.2", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "8ebcab5aac7606331cef69b0081f6c9eff2e58bc" + "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cache/zipball/8ebcab5aac7606331cef69b0081f6c9eff2e58bc", - "reference": "8ebcab5aac7606331cef69b0081f6c9eff2e58bc", + "url": "https://api.github.com/repos/utopia-php/cache/zipball/b22c6eb6d308de246b023efd0fc9758aee8b8247", + "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247", "shasum": "" }, "require": { @@ -1594,7 +1594,7 @@ }, "require-dev": { "laravel/pint": "1.2.*", - "phpstan/phpstan": "^1.12", + "phpstan/phpstan": "1.9.x-dev", "phpunit/phpunit": "^9.3", "vimeo/psalm": "4.13.1" }, @@ -1618,9 +1618,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cache/issues", - "source": "https://github.com/utopia-php/cache/tree/0.11.0" + "source": "https://github.com/utopia-php/cache/tree/0.10.2" }, - "time": "2024-11-05T16:53:58+00:00" + "time": "2024-06-25T20:36:35+00:00" }, { "name": "utopia-php/cli", @@ -1728,19 +1728,19 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "5af02bf3e3970c1cf0272954f6ee485ad42432e9" + "reference": "88b1975c8aed3493f11648621fba3d9a868f069d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/5af02bf3e3970c1cf0272954f6ee485ad42432e9", - "reference": "5af02bf3e3970c1cf0272954f6ee485ad42432e9", + "url": "https://api.github.com/repos/utopia-php/database/zipball/88b1975c8aed3493f11648621fba3d9a868f069d", + "reference": "88b1975c8aed3493f11648621fba3d9a868f069d", "shasum": "" }, "require": { "ext-mbstring": "*", "ext-pdo": "*", "php": ">=8.3", - "utopia-php/cache": "0.11.*", + "utopia-php/cache": "0.10.*", "utopia-php/framework": "0.33.*", "utopia-php/mongo": "0.3.*" }, @@ -1776,7 +1776,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-11-07T10:32:18+00:00" + "time": "2024-11-07T10:40:20+00:00" }, { "name": "utopia-php/domains", @@ -2770,22 +2770,22 @@ }, { "name": "utopia-php/vcs", - "version": "0.8.3", + "version": "0.8.2", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "a032ed0611a8f4467aeaa9484f73223074457337" + "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/a032ed0611a8f4467aeaa9484f73223074457337", - "reference": "a032ed0611a8f4467aeaa9484f73223074457337", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", + "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", "shasum": "" }, "require": { "adhocore/jwt": "^1.1", "php": ">=8.0", - "utopia-php/cache": "^0.11.0", + "utopia-php/cache": "^0.10.0", "utopia-php/framework": "0.*.*" }, "require-dev": { @@ -2813,9 +2813,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.8.3" + "source": "https://github.com/utopia-php/vcs/tree/0.8.2" }, - "time": "2024-11-05T17:10:09+00:00" + "time": "2024-08-13T14:36:30+00:00" }, { "name": "utopia-php/websocket", From c624d94c455a9fd9017b3b5e7b805b4fc335d226 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 12:44:51 +0200 Subject: [PATCH 109/144] composer --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 63d77bef8e..1872980e33 100644 --- a/composer.json +++ b/composer.json @@ -48,10 +48,10 @@ "utopia-php/abuse": "0.43.0", "utopia-php/analytics": "0.10.*", "utopia-php/audit": "0.43.0", - "utopia-php/cache": "0.10.*", + "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-migrations as 0.53.9", + "utopia-php/database": "dev-feat-migrations as 0.53.16", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", From 39e237dfb4a26da93d257d7dc0fe922e3f4fd3d2 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 12:45:18 +0200 Subject: [PATCH 110/144] composer --- composer.lock | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/composer.lock b/composer.lock index 09a183ec8c..b9eba0df29 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": "a81b69f9e1d6bae201c8c2491c7725c1", + "content-hash": "c9cb216c6ef0500ed6de9b54e359540b", "packages": [ { "name": "adhocore/jwt", @@ -1574,16 +1574,16 @@ }, { "name": "utopia-php/cache", - "version": "0.10.2", + "version": "0.11.0", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247" + "reference": "8ebcab5aac7606331cef69b0081f6c9eff2e58bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cache/zipball/b22c6eb6d308de246b023efd0fc9758aee8b8247", - "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247", + "url": "https://api.github.com/repos/utopia-php/cache/zipball/8ebcab5aac7606331cef69b0081f6c9eff2e58bc", + "reference": "8ebcab5aac7606331cef69b0081f6c9eff2e58bc", "shasum": "" }, "require": { @@ -1594,7 +1594,7 @@ }, "require-dev": { "laravel/pint": "1.2.*", - "phpstan/phpstan": "1.9.x-dev", + "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^9.3", "vimeo/psalm": "4.13.1" }, @@ -1618,9 +1618,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cache/issues", - "source": "https://github.com/utopia-php/cache/tree/0.10.2" + "source": "https://github.com/utopia-php/cache/tree/0.11.0" }, - "time": "2024-06-25T20:36:35+00:00" + "time": "2024-11-05T16:53:58+00:00" }, { "name": "utopia-php/cli", @@ -1728,19 +1728,19 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "88b1975c8aed3493f11648621fba3d9a868f069d" + "reference": "31571bd6adaa9f6bfb31195c49237456b0742ec7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/88b1975c8aed3493f11648621fba3d9a868f069d", - "reference": "88b1975c8aed3493f11648621fba3d9a868f069d", + "url": "https://api.github.com/repos/utopia-php/database/zipball/31571bd6adaa9f6bfb31195c49237456b0742ec7", + "reference": "31571bd6adaa9f6bfb31195c49237456b0742ec7", "shasum": "" }, "require": { "ext-mbstring": "*", "ext-pdo": "*", "php": ">=8.3", - "utopia-php/cache": "0.10.*", + "utopia-php/cache": "0.11.*", "utopia-php/framework": "0.33.*", "utopia-php/mongo": "0.3.*" }, @@ -1776,7 +1776,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-11-07T10:40:20+00:00" + "time": "2024-11-07T10:44:19+00:00" }, { "name": "utopia-php/domains", @@ -2770,22 +2770,22 @@ }, { "name": "utopia-php/vcs", - "version": "0.8.2", + "version": "0.8.3", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18" + "reference": "a032ed0611a8f4467aeaa9484f73223074457337" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", - "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/a032ed0611a8f4467aeaa9484f73223074457337", + "reference": "a032ed0611a8f4467aeaa9484f73223074457337", "shasum": "" }, "require": { "adhocore/jwt": "^1.1", "php": ">=8.0", - "utopia-php/cache": "^0.10.0", + "utopia-php/cache": "^0.11.0", "utopia-php/framework": "0.*.*" }, "require-dev": { @@ -2813,9 +2813,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.8.2" + "source": "https://github.com/utopia-php/vcs/tree/0.8.3" }, - "time": "2024-08-13T14:36:30+00:00" + "time": "2024-11-05T17:10:09+00:00" }, { "name": "utopia-php/websocket", @@ -7007,8 +7007,8 @@ { "package": "utopia-php/database", "version": "dev-feat-migrations", - "alias": "0.53.9", - "alias_normalized": "0.53.9.0" + "alias": "0.53.16", + "alias_normalized": "0.53.16.0" } ], "minimum-stability": "stable", From 76701b0cca8d3d4503dc60e48c6c354147f140ac Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 13:03:45 +0200 Subject: [PATCH 111/144] composer --- composer.lock | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/composer.lock b/composer.lock index b9eba0df29..b98dfec70b 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": "c9cb216c6ef0500ed6de9b54e359540b", + "content-hash": "b358198535c1867eabed7c0f99135a57", "packages": [ { "name": "adhocore/jwt", @@ -1724,16 +1724,16 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-migrations", + "version": "0.53.16", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "31571bd6adaa9f6bfb31195c49237456b0742ec7" + "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/31571bd6adaa9f6bfb31195c49237456b0742ec7", - "reference": "31571bd6adaa9f6bfb31195c49237456b0742ec7", + "url": "https://api.github.com/repos/utopia-php/database/zipball/6661edffeef05b59e16d102b989a72f7f78cf7de", + "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de", "shasum": "" }, "require": { @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/feat-migrations" + "source": "https://github.com/utopia-php/database/tree/0.53.16" }, - "time": "2024-11-07T10:44:19+00:00" + "time": "2024-11-06T03:07:16+00:00" }, { "name": "utopia-php/domains", @@ -7003,18 +7003,9 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [ - { - "package": "utopia-php/database", - "version": "dev-feat-migrations", - "alias": "0.53.16", - "alias_normalized": "0.53.16.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/database": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From f3315c69a0709ca5c7d25a6447e6ea900317dfdc Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 13:19:52 +0200 Subject: [PATCH 112/144] projects.php --- app/controllers/api/projects.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 7d8ddd8a79..15eceb5595 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -118,10 +118,6 @@ App::post('/v1/projects') $projectId = ($projectId == 'unique()') ? ID::unique() : $projectId; - if ($projectId === 'console') { - throw new Exception(Exception::PROJECT_RESERVED_PROJECT, "'console' is a reserved project."); - } - $databases = Config::getParam('pools-database', []); $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); @@ -132,6 +128,10 @@ App::post('/v1/projects') $dsn = $databases[array_rand($databases)]; } + if ($projectId === 'console') { + throw new Exception(Exception::PROJECT_RESERVED_PROJECT, "'console' is a reserved project."); + } + // TODO: Temporary until all projects are using shared tables. $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); @@ -1070,7 +1070,7 @@ App::get('/v1/projects/:projectId/webhooks/:webhookId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($webhook === false || $webhook->isEmpty()) { + if ($webhook->isEmpty()) { throw new Exception(Exception::WEBHOOK_NOT_FOUND); } @@ -1113,7 +1113,7 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($webhook === false || $webhook->isEmpty()) { + if ($webhook->isEmpty()) { throw new Exception(Exception::WEBHOOK_NOT_FOUND); } @@ -1163,7 +1163,7 @@ App::patch('/v1/projects/:projectId/webhooks/:webhookId/signature') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($webhook === false || $webhook->isEmpty()) { + if ($webhook->isEmpty()) { throw new Exception(Exception::WEBHOOK_NOT_FOUND); } @@ -1201,7 +1201,7 @@ App::delete('/v1/projects/:projectId/webhooks/:webhookId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($webhook === false || $webhook->isEmpty()) { + if ($webhook->isEmpty()) { throw new Exception(Exception::WEBHOOK_NOT_FOUND); } @@ -1323,7 +1323,7 @@ App::get('/v1/projects/:projectId/keys/:keyId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($key === false || $key->isEmpty()) { + if ($key->isEmpty()) { throw new Exception(Exception::KEY_NOT_FOUND); } @@ -1360,7 +1360,7 @@ App::put('/v1/projects/:projectId/keys/:keyId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($key === false || $key->isEmpty()) { + if ($key->isEmpty()) { throw new Exception(Exception::KEY_NOT_FOUND); } @@ -1402,7 +1402,7 @@ App::delete('/v1/projects/:projectId/keys/:keyId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($key === false || $key->isEmpty()) { + if ($key->isEmpty()) { throw new Exception(Exception::KEY_NOT_FOUND); } @@ -1560,7 +1560,7 @@ App::get('/v1/projects/:projectId/platforms/:platformId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($platform === false || $platform->isEmpty()) { + if ($platform->isEmpty()) { throw new Exception(Exception::PLATFORM_NOT_FOUND); } @@ -1597,7 +1597,7 @@ App::put('/v1/projects/:projectId/platforms/:platformId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($platform === false || $platform->isEmpty()) { + if ($platform->isEmpty()) { throw new Exception(Exception::PLATFORM_NOT_FOUND); } @@ -1641,7 +1641,7 @@ App::delete('/v1/projects/:projectId/platforms/:platformId') Query::equal('projectInternalId', [$project->getInternalId()]), ]); - if ($platform === false || $platform->isEmpty()) { + if ($platform->isEmpty()) { throw new Exception(Exception::PLATFORM_NOT_FOUND); } From f86bf6fdfdcc52302d68c778c91b9f73d9af70d2 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 7 Nov 2024 13:59:53 +0200 Subject: [PATCH 113/144] updates --- app/controllers/shared/api.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 7d9c4f1c43..f5921bf6e8 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -754,13 +754,10 @@ App::shutdown() Authorization::skip(fn () => $dbForProject->updateDocument('cache', $cacheLog->getId(), $cacheLog)); } - $cache = new Cache( - new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()) - ); - - $timestamp = 60 * 60 * 24 * 30; - $cacheFile = $cache->load($key, $timestamp); - if ($signature !== $cacheLog->getAttribute('signature') || empty($cacheFile)) { + if ($signature !== $cacheLog->getAttribute('signature')) { + $cache = new Cache( + new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()) + ); $cache->save($key, $data['payload']); } } From 773fa6ffd69b873800479a73f5f0e25943065906 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 8 Nov 2024 16:34:07 +1300 Subject: [PATCH 114/144] Update lock --- composer.lock | 144 +++++++++++++++++++++++++------------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/composer.lock b/composer.lock index adfb6228a9..c481f10b00 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": "0628ea4ac360b5730cfed30266be1659", + "content-hash": "5f00a8b5cad77e66ad39ca2638d0cd7a", "packages": [ { "name": "adhocore/jwt", @@ -1574,16 +1574,16 @@ }, { "name": "utopia-php/cache", - "version": "0.10.2", + "version": "0.11.0", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247" + "reference": "8ebcab5aac7606331cef69b0081f6c9eff2e58bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cache/zipball/b22c6eb6d308de246b023efd0fc9758aee8b8247", - "reference": "b22c6eb6d308de246b023efd0fc9758aee8b8247", + "url": "https://api.github.com/repos/utopia-php/cache/zipball/8ebcab5aac7606331cef69b0081f6c9eff2e58bc", + "reference": "8ebcab5aac7606331cef69b0081f6c9eff2e58bc", "shasum": "" }, "require": { @@ -1594,7 +1594,7 @@ }, "require-dev": { "laravel/pint": "1.2.*", - "phpstan/phpstan": "1.9.x-dev", + "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^9.3", "vimeo/psalm": "4.13.1" }, @@ -1618,9 +1618,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cache/issues", - "source": "https://github.com/utopia-php/cache/tree/0.10.2" + "source": "https://github.com/utopia-php/cache/tree/0.11.0" }, - "time": "2024-06-25T20:36:35+00:00" + "time": "2024-11-05T16:53:58+00:00" }, { "name": "utopia-php/cli", @@ -1728,28 +1728,28 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "df574633d6540984e5ae8efab806e3b493acca5b" + "reference": "31571bd6adaa9f6bfb31195c49237456b0742ec7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/df574633d6540984e5ae8efab806e3b493acca5b", - "reference": "df574633d6540984e5ae8efab806e3b493acca5b", + "url": "https://api.github.com/repos/utopia-php/database/zipball/31571bd6adaa9f6bfb31195c49237456b0742ec7", + "reference": "31571bd6adaa9f6bfb31195c49237456b0742ec7", "shasum": "" }, "require": { "ext-mbstring": "*", "ext-pdo": "*", - "php": ">=8.0", - "utopia-php/cache": "0.10.*", + "php": ">=8.3", + "utopia-php/cache": "0.11.*", "utopia-php/framework": "0.33.*", "utopia-php/mongo": "0.3.*" }, "require-dev": { "fakerphp/faker": "1.23.*", - "laravel/pint": "1.17.*", - "pcov/clobber": "2.0.*", - "phpstan/phpstan": "1.11.*", - "phpunit/phpunit": "9.6.*", + "laravel/pint": "1.*", + "pcov/clobber": "2.*", + "phpstan/phpstan": "1.*", + "phpunit/phpunit": "9.*", "rregeer/phpunit-coverage-check": "0.3.*", "swoole/ide-helper": "5.1.3", "utopia-php/cli": "0.14.*" @@ -1776,7 +1776,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/feat-migrations" }, - "time": "2024-10-31T16:26:25+00:00" + "time": "2024-11-07T10:44:19+00:00" }, { "name": "utopia-php/domains", @@ -2495,16 +2495,16 @@ }, { "name": "utopia-php/queue", - "version": "0.7.0", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "917565256eb94bcab7246f7a746b1a486813761b" + "reference": "94c240d9f6383829807ce7b2d737f04b159fd3e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/queue/zipball/917565256eb94bcab7246f7a746b1a486813761b", - "reference": "917565256eb94bcab7246f7a746b1a486813761b", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/94c240d9f6383829807ce7b2d737f04b159fd3e8", + "reference": "94c240d9f6383829807ce7b2d737f04b159fd3e8", "shasum": "" }, "require": { @@ -2550,9 +2550,9 @@ ], "support": { "issues": "https://github.com/utopia-php/queue/issues", - "source": "https://github.com/utopia-php/queue/tree/0.7.0" + "source": "https://github.com/utopia-php/queue/tree/0.7.1" }, - "time": "2024-01-17T19:00:43+00:00" + "time": "2024-11-05T17:00:38+00:00" }, { "name": "utopia-php/registry", @@ -2608,16 +2608,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.5", + "version": "0.18.6", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919" + "reference": "893ccf06e183f8ece2aed8dbf14d64d6ba036071" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/7d355c5e3ccc8ecebc0266f8ddd30088a43be919", - "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/893ccf06e183f8ece2aed8dbf14d64d6ba036071", + "reference": "893ccf06e183f8ece2aed8dbf14d64d6ba036071", "shasum": "" }, "require": { @@ -2657,9 +2657,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.5" + "source": "https://github.com/utopia-php/storage/tree/0.18.6" }, - "time": "2024-09-04T08:57:27+00:00" + "time": "2024-11-06T09:58:50+00:00" }, { "name": "utopia-php/swoole", @@ -2770,22 +2770,22 @@ }, { "name": "utopia-php/vcs", - "version": "0.8.2", + "version": "0.8.3", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18" + "reference": "a032ed0611a8f4467aeaa9484f73223074457337" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", - "reference": "eb9b7eade1a46a4f660e0d5a6304f7fa26ec9d18", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/a032ed0611a8f4467aeaa9484f73223074457337", + "reference": "a032ed0611a8f4467aeaa9484f73223074457337", "shasum": "" }, "require": { "adhocore/jwt": "^1.1", "php": ">=8.0", - "utopia-php/cache": "^0.10.0", + "utopia-php/cache": "^0.11.0", "utopia-php/framework": "0.*.*" }, "require-dev": { @@ -2813,9 +2813,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.8.2" + "source": "https://github.com/utopia-php/vcs/tree/0.8.3" }, - "time": "2024-08-13T14:36:30+00:00" + "time": "2024-11-05T17:10:09+00:00" }, { "name": "utopia-php/websocket", @@ -4004,16 +4004,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.4.1", + "version": "5.5.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c" + "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", - "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0c70d2c566e899666f367ab7b80986beb3581e6f", + "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f", "shasum": "" }, "require": { @@ -4026,13 +4026,13 @@ "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.5", + "mockery/mockery": "~1.3.5 || ~1.6.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.8", "phpstan/phpstan-mockery": "^1.1", "phpstan/phpstan-webmozart-assert": "^1.2", "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^5.13" + "psalm/phar": "^5.26" }, "type": "library", "extra": { @@ -4062,29 +4062,29 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.1" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.5.1" }, - "time": "2024-05-21T05:55:05+00:00" + "time": "2024-11-06T11:58:54+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.8.2", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "153ae662783729388a584b4361f2545e4d841e3c" + "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/153ae662783729388a584b4361f2545e4d841e3c", - "reference": "153ae662783729388a584b4361f2545e4d841e3c", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1fb5ba8d045f5dd984ebded5b1cc66f29459422d", + "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d", "shasum": "" }, "require": { "doctrine/deprecations": "^1.0", "php": "^7.3 || ^8.0", "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.13" + "phpstan/phpdoc-parser": "^1.18" }, "require-dev": { "ext-tokenizer": "*", @@ -4120,9 +4120,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.2" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.9.0" }, - "time": "2024-02-23T11:10:43+00:00" + "time": "2024-11-03T20:11:34+00:00" }, { "name": "phpspec/prophecy", @@ -5875,16 +5875,16 @@ }, { "name": "symfony/console", - "version": "v7.1.6", + "version": "v7.1.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "bb5192af6edc797cbab5c8e8ecfea2fe5f421e57" + "reference": "3284aafcac338b6e86fd955ee4d794cbe434151a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/bb5192af6edc797cbab5c8e8ecfea2fe5f421e57", - "reference": "bb5192af6edc797cbab5c8e8ecfea2fe5f421e57", + "url": "https://api.github.com/repos/symfony/console/zipball/3284aafcac338b6e86fd955ee4d794cbe434151a", + "reference": "3284aafcac338b6e86fd955ee4d794cbe434151a", "shasum": "" }, "require": { @@ -5948,7 +5948,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.6" + "source": "https://github.com/symfony/console/tree/v7.1.7" }, "funding": [ { @@ -5964,7 +5964,7 @@ "type": "tidelift" } ], - "time": "2024-10-09T08:46:59+00:00" + "time": "2024-11-05T15:34:55+00:00" }, { "name": "symfony/deprecation-contracts", @@ -6546,16 +6546,16 @@ }, { "name": "symfony/process", - "version": "v7.1.6", + "version": "v7.1.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e" + "reference": "9b8a40b7289767aa7117e957573c2a535efe6585" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e", - "reference": "6aaa189ddb4ff6b5de8fa3210f2fb42c87b4d12e", + "url": "https://api.github.com/repos/symfony/process/zipball/9b8a40b7289767aa7117e957573c2a535efe6585", + "reference": "9b8a40b7289767aa7117e957573c2a535efe6585", "shasum": "" }, "require": { @@ -6587,7 +6587,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.1.6" + "source": "https://github.com/symfony/process/tree/v7.1.7" }, "funding": [ { @@ -6603,7 +6603,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2024-11-06T09:25:12+00:00" }, { "name": "symfony/service-contracts", @@ -6876,16 +6876,16 @@ }, { "name": "twig/twig", - "version": "v3.14.0", + "version": "v3.14.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72" + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72", - "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", "shasum": "" }, "require": { @@ -6939,7 +6939,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.14.0" + "source": "https://github.com/twigphp/Twig/tree/v3.14.2" }, "funding": [ { @@ -6951,7 +6951,7 @@ "type": "tidelift" } ], - "time": "2024-09-09T17:55:12+00:00" + "time": "2024-11-07T12:36:22+00:00" }, { "name": "webmozart/glob", @@ -7007,8 +7007,8 @@ { "package": "utopia-php/database", "version": "dev-feat-migrations", - "alias": "0.53.9", - "alias_normalized": "0.53.9.0" + "alias": "0.53.16", + "alias_normalized": "0.53.16.0" } ], "minimum-stability": "stable", From 9e69e41e026cb97a8c6f381941c05ece45f5bb07 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 8 Nov 2024 17:04:29 +1300 Subject: [PATCH 115/144] Update lock --- composer.json | 2 +- composer.lock | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index ecc48b626c..2f5c229a5d 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-migrations as 0.53.16", + "utopia-php/database": "0.53.18", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index c481f10b00..182724a85e 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": "5f00a8b5cad77e66ad39ca2638d0cd7a", + "content-hash": "bd9b8f5f8fe295deb07002ca0a953949", "packages": [ { "name": "adhocore/jwt", @@ -1724,16 +1724,16 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-migrations", + "version": "0.53.18", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "31571bd6adaa9f6bfb31195c49237456b0742ec7" + "reference": "895176b61b969d326bf2e36695606b8a33132094" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/31571bd6adaa9f6bfb31195c49237456b0742ec7", - "reference": "31571bd6adaa9f6bfb31195c49237456b0742ec7", + "url": "https://api.github.com/repos/utopia-php/database/zipball/895176b61b969d326bf2e36695606b8a33132094", + "reference": "895176b61b969d326bf2e36695606b8a33132094", "shasum": "" }, "require": { @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/feat-migrations" + "source": "https://github.com/utopia-php/database/tree/0.53.18" }, - "time": "2024-11-07T10:44:19+00:00" + "time": "2024-11-08T04:02:13+00:00" }, { "name": "utopia-php/domains", @@ -7003,18 +7003,9 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [ - { - "package": "utopia-php/database", - "version": "dev-feat-migrations", - "alias": "0.53.16", - "alias_normalized": "0.53.16.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/database": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From b496bcb6dfc2fc66062db8f890db20516af18f4c Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 8 Nov 2024 14:06:02 +0200 Subject: [PATCH 116/144] updates --- composer.lock | 12 ++++++------ src/Appwrite/Platform/Workers/Certificates.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index b98dfec70b..3c6c0ec81a 100644 --- a/composer.lock +++ b/composer.lock @@ -6876,16 +6876,16 @@ }, { "name": "twig/twig", - "version": "v3.14.1", + "version": "v3.14.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379" + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/f405356d20fb43603bcadc8b09bfb676cb04a379", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", "shasum": "" }, "require": { @@ -6939,7 +6939,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.14.1" + "source": "https://github.com/twigphp/Twig/tree/v3.14.2" }, "funding": [ { @@ -6951,7 +6951,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T18:17:38+00:00" + "time": "2024-11-07T12:36:22+00:00" }, { "name": "webmozart/glob", diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index a14f164295..66fc14c2ca 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -381,7 +381,7 @@ class Certificates extends Action * @return void * @throws Exception */ - private function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void + protected function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void { // Prepare folder in storage for domain From b5efbdbb0f7c3d270db540802d5bdaa8893624de Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 8 Nov 2024 14:43:30 +0200 Subject: [PATCH 117/144] updates --- .../Platform/Workers/Certificates.php | 62 +++---------------- 1 file changed, 10 insertions(+), 52 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index f6a8637177..a14f164295 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -22,7 +22,6 @@ use Utopia\Database\Exception\Structure; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Domains\Domain; -use Utopia\Fetch\Client; use Utopia\Locale\Locale; use Utopia\Logger\Log; use Utopia\Platform\Action; @@ -44,18 +43,16 @@ class Certificates extends Action $this ->desc('Certificates worker') ->inject('message') - ->inject('project') ->inject('dbForConsole') ->inject('queueForMails') ->inject('queueForEvents') ->inject('queueForFunctions') ->inject('log') - ->callback(fn (Message $message, Document $project, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log) => $this->action($message, $project, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log)); + ->callback(fn (Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log) => $this->action($message, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log)); } /** * @param Message $message - * @param Document $project * @param Database $dbForConsole * @param Mail $queueForMails * @param Event $queueForEvents @@ -65,7 +62,7 @@ class Certificates extends Action * @throws Throwable * @throws \Utopia\Database\Exception */ - public function action(Message $message, Document $project, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log): void + public function action(Message $message, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log): void { $payload = $message->getPayload() ?? []; @@ -79,7 +76,7 @@ class Certificates extends Action $log->addTag('domain', $domain->get()); - $this->execute($domain, $project, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log, $skipRenewCheck); + $this->execute($domain, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log, $skipRenewCheck); } /** @@ -93,7 +90,7 @@ class Certificates extends Action * @throws Throwable * @throws \Utopia\Database\Exception */ - private function execute(Domain $domain, Document $project, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, bool $skipRenewCheck = false): void + private function execute(Domain $domain, Database $dbForConsole, Mail $queueForMails, Event $queueForEvents, Func $queueForFunctions, Log $log, bool $skipRenewCheck = false): void { /** * 1. Read arguments and validate domain @@ -158,26 +155,16 @@ class Certificates extends Action // Prepare folder name for certbot. Using this helps prevent miss-match in LetsEncrypt configuration when renewing certificate $folder = ID::unique(); - try { - // Generate certificate files using Let's Encrypt - $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); - - // Give certificates to Traefik - $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); - } catch (\Throwable $th) { - Console::error('Failed to generate Lets Encrypt certificate'); - } + // Generate certificate files using Let's Encrypt + $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); // Command succeeded, store all data into document $logs = 'Certificate successfully generated.'; $certificate->setAttribute('logs', \mb_strcut($logs, 0, 1000000));// Limit to 1MB - try { - // TEMP: add custom hostnames to cloudflare - $this->addCustomHostnameToRegistrar($project, $domain->get()); - } catch (\Throwable $th) { - Console::error('Failed to add custom hostname to registrar: ' . $th->getMessage()); - } + + // Give certificates to Traefik + $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); // Update certificate info stored in database $certificate->setAttribute('renewDate', $this->getRenewDate($domain->get())); @@ -210,35 +197,6 @@ class Certificates extends Action } } - /** - * Add custom hostname to Cloudflare registrar - * - * @param Document $project - * @param string $hostname - * @return void - * @throws Exception - */ - private function addCustomHostnameToRegistrar(Document $project, string $hostname): void - { - $client = new Client(); - $client - ->addHeader('content-type', Client::CONTENT_TYPE_APPLICATION_JSON) - ->addHeader('Authorization', 'Bearer ' . System::getEnv('_APP_SYSTEM_CLOUDFLARE_TOKEN')); - - $response = $client->fetch("https://api.cloudflare.com/client/v4/zones/b2d0e62383d3c0f6299efab107af2c7a/custom_hostnames", Client::METHOD_POST, [ - 'hostname' => $hostname, - 'ssl' => [ - "method" => "http", - "type" => "dv", - "wildcard" => false - ] - ]); - - if ($response->getStatusCode() !== 201) { - throw new Exception('Failed to add custom hostname to Cloudflare: ' . $response->getBody()); - } - } - /** * Save certificate data into database. * @@ -423,7 +381,7 @@ class Certificates extends Action * @return void * @throws Exception */ - protected function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void + private function applyCertificateFiles(string $folder, string $domain, array $letsEncryptData): void { // Prepare folder in storage for domain From 627df0d11fc403e2d084dd9746f24b6e4eb46edf Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:24:55 +0100 Subject: [PATCH 118/144] chore: remove redundant compression --- app/http.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/http.php b/app/http.php index 641143694d..b9e3552efd 100644 --- a/app/http.php +++ b/app/http.php @@ -60,8 +60,6 @@ include __DIR__ . '/controllers/general.php'; $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $register) { $app = new App('UTC'); - $app->setCompression(true); - $app->setCompressionMinSize(intval(System::getEnv('_APP_COMPRESSION_MIN_SIZE_BYTES', '1024'))); // 1KB go(function () use ($register, $app) { $pools = $register->get('pools'); From 2f9b44930f7c8a7b1460ed7c9d304c625a77b0a1 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:48:27 +0100 Subject: [PATCH 119/144] Revert "Merge pull request #8946 from appwrite/chore-update-database" This reverts commit c0bd1664be78456a57e766205c902d4f3740fe8a, reversing changes made to b42dd86451ac5bd23e46747fb158c990f4596b74. --- app/config/errors.php | 2 +- app/controllers/api/databases.php | 6 ++--- composer.json | 2 +- composer.lock | 26 +++++++++---------- .../Databases/DatabasesCustomServerTest.php | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index f09d1596eb..3afec4faaf 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -686,7 +686,7 @@ return [ ], Exception::ATTRIBUTE_LIMIT_EXCEEDED => [ 'name' => Exception::ATTRIBUTE_LIMIT_EXCEEDED, - 'description' => 'The maximum number or size of attributes for this collection has been reached.', + 'description' => 'The maximum number of attributes has been reached.', 'code' => 400, ], Exception::ATTRIBUTE_VALUE_INVALID => [ diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index dcf5bbffa5..0114fd343c 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -153,7 +153,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att } catch (DuplicateException) { throw new Exception(Exception::ATTRIBUTE_ALREADY_EXISTS); } catch (LimitException) { - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded'); } catch (\Throwable $e) { $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $collectionId); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $collection->getInternalId()); @@ -197,7 +197,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att throw new Exception(Exception::ATTRIBUTE_ALREADY_EXISTS); } catch (LimitException) { $dbForProject->deleteDocument('attributes', $attribute->getId()); - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded'); } catch (\Throwable $e) { $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $relatedCollection->getId()); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); @@ -393,8 +393,6 @@ function updateAttribute( throw new Exception(Exception::ATTRIBUTE_INVALID_RESIZE); } catch (NotFoundException) { throw new Exception(Exception::ATTRIBUTE_NOT_FOUND); - } catch (LimitException) { - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); } } diff --git a/composer.json b/composer.json index 5c2441fd1b..a04ca51d43 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.19", + "utopia-php/database": "0.53.16", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 097cee9868..2724542a38 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": "5be1b916c221b97b77b0e7f14491aabf", + "content-hash": "b358198535c1867eabed7c0f99135a57", "packages": [ { "name": "adhocore/jwt", @@ -1770,16 +1770,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.19", + "version": "0.53.16", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "48951885f2787df30ad8581a0e94423558619daa" + "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/48951885f2787df30ad8581a0e94423558619daa", - "reference": "48951885f2787df30ad8581a0e94423558619daa", + "url": "https://api.github.com/repos/utopia-php/database/zipball/6661edffeef05b59e16d102b989a72f7f78cf7de", + "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de", "shasum": "" }, "require": { @@ -1820,9 +1820,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.19" + "source": "https://github.com/utopia-php/database/tree/0.53.16" }, - "time": "2024-11-08T07:00:24+00:00" + "time": "2024-11-06T03:07:16+00:00" }, { "name": "utopia-php/domains", @@ -6923,16 +6923,16 @@ }, { "name": "twig/twig", - "version": "v3.14.2", + "version": "v3.14.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a" + "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", - "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/f405356d20fb43603bcadc8b09bfb676cb04a379", + "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379", "shasum": "" }, "require": { @@ -6986,7 +6986,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.14.2" + "source": "https://github.com/twigphp/Twig/tree/v3.14.1" }, "funding": [ { @@ -6998,7 +6998,7 @@ "type": "tidelift" } ], - "time": "2024-11-07T12:36:22+00:00" + "time": "2024-11-06T18:17:38+00:00" }, { "name": "webmozart/glob", diff --git a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php index b501e2119e..7cb8adb815 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php @@ -1362,7 +1362,7 @@ class DatabasesCustomServerTest extends Scope ]); $this->assertEquals(400, $tooWide['headers']['status-code']); - $this->assertEquals('attribute_limit_exceeded', $tooWide['body']['type']); + $this->assertEquals('Attribute limit exceeded', $tooWide['body']['message']); } public function testIndexLimitException() From f6de25622008ad9510a553cfc8969f41b0ab39a3 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:50:33 +0100 Subject: [PATCH 120/144] chore: composer update --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 2724542a38..828153a153 100644 --- a/composer.lock +++ b/composer.lock @@ -6923,16 +6923,16 @@ }, { "name": "twig/twig", - "version": "v3.14.1", + "version": "v3.14.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379" + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/f405356d20fb43603bcadc8b09bfb676cb04a379", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", "shasum": "" }, "require": { @@ -6986,7 +6986,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.14.1" + "source": "https://github.com/twigphp/Twig/tree/v3.14.2" }, "funding": [ { @@ -6998,7 +6998,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T18:17:38+00:00" + "time": "2024-11-07T12:36:22+00:00" }, { "name": "webmozart/glob", From a0280e3c43753f6e6b2fc4997ca9c8847459e77e Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 10 Nov 2024 12:26:34 +0200 Subject: [PATCH 121/144] adding app region to console project --- app/init.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/init.php b/app/init.php index 3744bb055c..f47176caae 100644 --- a/app/init.php +++ b/app/init.php @@ -1334,6 +1334,10 @@ App::setResource('project', function ($dbForConsole, $request, $console) { $project = Authorization::skip(fn () => $dbForConsole->getDocument('projects', $projectId)); + if($project->getAttribute('region') !== System::getEnv('_APP_REGION')){ + throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, 'Project is not accessible in this region. Please make sure you are using the correct endpoint'); + } + return $project; }, ['dbForConsole', 'request', 'console']); @@ -1397,10 +1401,11 @@ App::setResource('console', function () { 'githubSecret' => System::getEnv('_APP_CONSOLE_GITHUB_SECRET', ''), 'githubAppid' => System::getEnv('_APP_CONSOLE_GITHUB_APP_ID', '') ], + 'region' => System::getEnv('_APP_REGION', 'default') ]); }, []); -App::setResource('dbForProject', function (Group $pools, Database $dbForConsole, Cache $cache, Document $project) { +App::setResource('dbForPltroject', function (Group $pools, Database $dbForConsole, Cache $cache, Document $project) { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForConsole; } From a85b43654cec1b02cf7e341cdf6c90af5acf4194 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 11 Nov 2024 15:22:57 +1300 Subject: [PATCH 122/144] Reapply "Update database" This reverts commit b1a1ad618a553efe42157306d2f6c59e6444892c. --- app/config/errors.php | 2 +- app/controllers/api/databases.php | 6 +++-- composer.json | 2 +- composer.lock | 26 +++++++++---------- .../Databases/DatabasesCustomServerTest.php | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index 3afec4faaf..f09d1596eb 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -686,7 +686,7 @@ return [ ], Exception::ATTRIBUTE_LIMIT_EXCEEDED => [ 'name' => Exception::ATTRIBUTE_LIMIT_EXCEEDED, - 'description' => 'The maximum number of attributes has been reached.', + 'description' => 'The maximum number or size of attributes for this collection has been reached.', 'code' => 400, ], Exception::ATTRIBUTE_VALUE_INVALID => [ diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 0114fd343c..dcf5bbffa5 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -153,7 +153,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att } catch (DuplicateException) { throw new Exception(Exception::ATTRIBUTE_ALREADY_EXISTS); } catch (LimitException) { - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded'); + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); } catch (\Throwable $e) { $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $collectionId); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $collection->getInternalId()); @@ -197,7 +197,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att throw new Exception(Exception::ATTRIBUTE_ALREADY_EXISTS); } catch (LimitException) { $dbForProject->deleteDocument('attributes', $attribute->getId()); - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded'); + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); } catch (\Throwable $e) { $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $relatedCollection->getId()); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); @@ -393,6 +393,8 @@ function updateAttribute( throw new Exception(Exception::ATTRIBUTE_INVALID_RESIZE); } catch (NotFoundException) { throw new Exception(Exception::ATTRIBUTE_NOT_FOUND); + } catch (LimitException) { + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); } } diff --git a/composer.json b/composer.json index a04ca51d43..5c2441fd1b 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.16", + "utopia-php/database": "0.53.19", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 691a7e740e..3ceb3e6106 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": "b358198535c1867eabed7c0f99135a57", + "content-hash": "5be1b916c221b97b77b0e7f14491aabf", "packages": [ { "name": "adhocore/jwt", @@ -1770,16 +1770,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.16", + "version": "0.53.19", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de" + "reference": "48951885f2787df30ad8581a0e94423558619daa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/6661edffeef05b59e16d102b989a72f7f78cf7de", - "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de", + "url": "https://api.github.com/repos/utopia-php/database/zipball/48951885f2787df30ad8581a0e94423558619daa", + "reference": "48951885f2787df30ad8581a0e94423558619daa", "shasum": "" }, "require": { @@ -1820,9 +1820,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.16" + "source": "https://github.com/utopia-php/database/tree/0.53.19" }, - "time": "2024-11-06T03:07:16+00:00" + "time": "2024-11-08T07:00:24+00:00" }, { "name": "utopia-php/domains", @@ -6923,16 +6923,16 @@ }, { "name": "twig/twig", - "version": "v3.14.1", + "version": "v3.14.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379" + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/f405356d20fb43603bcadc8b09bfb676cb04a379", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", "shasum": "" }, "require": { @@ -6986,7 +6986,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.14.1" + "source": "https://github.com/twigphp/Twig/tree/v3.14.2" }, "funding": [ { @@ -6998,7 +6998,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T18:17:38+00:00" + "time": "2024-11-07T12:36:22+00:00" }, { "name": "webmozart/glob", diff --git a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php index 7cb8adb815..b501e2119e 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php @@ -1362,7 +1362,7 @@ class DatabasesCustomServerTest extends Scope ]); $this->assertEquals(400, $tooWide['headers']['status-code']); - $this->assertEquals('Attribute limit exceeded', $tooWide['body']['message']); + $this->assertEquals('attribute_limit_exceeded', $tooWide['body']['type']); } public function testIndexLimitException() From b0852aeca3dcc80d78ca63f9e75b365c9e098084 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 11 Nov 2024 23:15:00 +1300 Subject: [PATCH 123/144] Update database --- composer.json | 2 +- composer.lock | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 2f5c229a5d..b82e4a55a3 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.18", + "utopia-php/database": "0.53.19", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 14a3a7ee36..c01ce6545e 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": "bd9b8f5f8fe295deb07002ca0a953949", + "content-hash": "73a05899db73e80a2b9c66dbbfb8562e", "packages": [ { "name": "adhocore/jwt", @@ -1770,16 +1770,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.18", + "version": "0.53.19", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "895176b61b969d326bf2e36695606b8a33132094" + "reference": "48951885f2787df30ad8581a0e94423558619daa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/895176b61b969d326bf2e36695606b8a33132094", - "reference": "895176b61b969d326bf2e36695606b8a33132094", + "url": "https://api.github.com/repos/utopia-php/database/zipball/48951885f2787df30ad8581a0e94423558619daa", + "reference": "48951885f2787df30ad8581a0e94423558619daa", "shasum": "" }, "require": { @@ -1820,9 +1820,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.18" + "source": "https://github.com/utopia-php/database/tree/0.53.19" }, - "time": "2024-11-08T04:02:13+00:00" + "time": "2024-11-08T07:00:24+00:00" }, { "name": "utopia-php/domains", @@ -2542,16 +2542,16 @@ }, { "name": "utopia-php/queue", - "version": "0.7.1", + "version": "0.7.2", "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "94c240d9f6383829807ce7b2d737f04b159fd3e8" + "reference": "40fdd9799d0a11dd33fca06f8223032a47dce2f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/queue/zipball/94c240d9f6383829807ce7b2d737f04b159fd3e8", - "reference": "94c240d9f6383829807ce7b2d737f04b159fd3e8", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/40fdd9799d0a11dd33fca06f8223032a47dce2f6", + "reference": "40fdd9799d0a11dd33fca06f8223032a47dce2f6", "shasum": "" }, "require": { @@ -2597,9 +2597,9 @@ ], "support": { "issues": "https://github.com/utopia-php/queue/issues", - "source": "https://github.com/utopia-php/queue/tree/0.7.1" + "source": "https://github.com/utopia-php/queue/tree/0.7.2" }, - "time": "2024-11-05T17:00:38+00:00" + "time": "2024-11-11T10:04:02+00:00" }, { "name": "utopia-php/registry", @@ -7052,7 +7052,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { From 33037a3ae588d690d180b9480fff1738fe428019 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 13:34:40 +1300 Subject: [PATCH 124/144] Update database --- app/controllers/api/databases.php | 3 ++- composer.json | 2 +- composer.lock | 38 +++++++++++++++---------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 0114fd343c..c1d7e8d11a 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -2627,7 +2627,8 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes') $validator = new IndexValidator( $collection->getAttribute('attributes'), - $dbForProject->getAdapter()->getMaxIndexLength() + $dbForProject->getAdapter()->getMaxIndexLength(), + $dbForProject->getAdapter()->getInternalIndexesKeys(), ); if (!$validator->isValid($index)) { throw new Exception(Exception::INDEX_INVALID, $validator->getDescription()); diff --git a/composer.json b/composer.json index b82e4a55a3..c11f78757b 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.19", + "utopia-php/database": "0.53.20", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index c01ce6545e..e47c49af78 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": "73a05899db73e80a2b9c66dbbfb8562e", + "content-hash": "217b0c1b6c156d51bf5a2674f87a7630", "packages": [ { "name": "adhocore/jwt", @@ -1770,16 +1770,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.19", + "version": "0.53.20", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "48951885f2787df30ad8581a0e94423558619daa" + "reference": "e43f8ee26e06ee8812737e63642dbd7ee7c9dc04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/48951885f2787df30ad8581a0e94423558619daa", - "reference": "48951885f2787df30ad8581a0e94423558619daa", + "url": "https://api.github.com/repos/utopia-php/database/zipball/e43f8ee26e06ee8812737e63642dbd7ee7c9dc04", + "reference": "e43f8ee26e06ee8812737e63642dbd7ee7c9dc04", "shasum": "" }, "require": { @@ -1820,9 +1820,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.19" + "source": "https://github.com/utopia-php/database/tree/0.53.20" }, - "time": "2024-11-08T07:00:24+00:00" + "time": "2024-11-12T00:23:36+00:00" }, { "name": "utopia-php/domains", @@ -2222,16 +2222,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.11", + "version": "0.6.12", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "4d167914d3f7fa1fe816b2b2c6f221e70166bfd7" + "reference": "9a8c905af4cece5c5ec9542a5b534befce067260" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/4d167914d3f7fa1fe816b2b2c6f221e70166bfd7", - "reference": "4d167914d3f7fa1fe816b2b2c6f221e70166bfd7", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/9a8c905af4cece5c5ec9542a5b534befce067260", + "reference": "9a8c905af4cece5c5ec9542a5b534befce067260", "shasum": "" }, "require": { @@ -2272,9 +2272,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.11" + "source": "https://github.com/utopia-php/migration/tree/0.6.12" }, - "time": "2024-10-31T06:19:57+00:00" + "time": "2024-11-12T00:31:53+00:00" }, { "name": "utopia-php/mongo", @@ -2817,16 +2817,16 @@ }, { "name": "utopia-php/vcs", - "version": "0.8.3", + "version": "0.8.5", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "a032ed0611a8f4467aeaa9484f73223074457337" + "reference": "7622330628d53844a3873ca873338150756bab82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/a032ed0611a8f4467aeaa9484f73223074457337", - "reference": "a032ed0611a8f4467aeaa9484f73223074457337", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/7622330628d53844a3873ca873338150756bab82", + "reference": "7622330628d53844a3873ca873338150756bab82", "shasum": "" }, "require": { @@ -2860,9 +2860,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.8.3" + "source": "https://github.com/utopia-php/vcs/tree/0.8.5" }, - "time": "2024-11-05T17:10:09+00:00" + "time": "2024-11-11T18:33:10+00:00" }, { "name": "utopia-php/websocket", From c1a3b29a978a7ef0820e500d5c6b77da13b79ed6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 14:37:03 +1300 Subject: [PATCH 125/144] Temp test all shared tables versions --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 29aa9b0581..2c1f3dadf5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -148,7 +148,10 @@ jobs: - name: Run ${{matrix.service}} Tests run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - - name: Run ${{matrix.service}} Shared Tables Tests + - name: Run ${{matrix.service}} Shared Tables V1 Tests + run: _APP_DATABASE_SHARED_TABLES=database_db_main _APP_DATABASE_SHARED_TABLES_V1=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug + + - name: Run ${{matrix.service}} Shared Tables V2 Tests run: _APP_DATABASE_SHARED_TABLES=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug benchmarking: From 3b19ef6b1e3bb3671b754dc8fd2ae0ec0a80c627 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 15:00:23 +1300 Subject: [PATCH 126/144] Remove V2 tests --- .github/workflows/tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2c1f3dadf5..e13f4cd705 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -151,9 +151,6 @@ jobs: - name: Run ${{matrix.service}} Shared Tables V1 Tests run: _APP_DATABASE_SHARED_TABLES=database_db_main _APP_DATABASE_SHARED_TABLES_V1=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - - name: Run ${{matrix.service}} Shared Tables V2 Tests - run: _APP_DATABASE_SHARED_TABLES=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - benchmarking: name: Benchmark runs-on: ubuntu-latest From e626c2ad450919e7d5335eb6c5884e47bf579000 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 19:14:46 +1300 Subject: [PATCH 127/144] Run in all table modes in parallel --- .github/workflows/tests.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e13f4cd705..5384c0b5f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -127,6 +127,11 @@ jobs: Messaging, Migrations ] + tables-mode: [ + Project, + Shared-V1, + Shared-V2, + ] steps: - name: checkout @@ -145,8 +150,11 @@ jobs: docker compose up -d sleep 30 - - name: Run ${{matrix.service}} Tests - run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug + - name: Run ${{ matrix.service }} tests with ${{ matrix.tables-mode }} table mode + run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug + env: + _APP_DATABASE_SHARED_TABLES: ${{ matrix.table_mode == 'Shared V1' || matrix.table_mode == 'Shared V2' && 'database_db_main' || '' }} + _APP_DATABASE_SHARED_TABLES_V1: ${{ matrix.table_mode == 'Shared V1' && 'database_db_main' || '' }} - name: Run ${{matrix.service}} Shared Tables V1 Tests run: _APP_DATABASE_SHARED_TABLES=database_db_main _APP_DATABASE_SHARED_TABLES_V1=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug From f6ea6d2fc560884a0aa04128e7b861996adb5886 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 19:15:33 +1300 Subject: [PATCH 128/144] Fix matrix --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5384c0b5f0..6b965882fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -128,9 +128,9 @@ jobs: Migrations ] tables-mode: [ - Project, - Shared-V1, - Shared-V2, + 'Project', + 'Shared V1', + 'Shared V2', ] steps: From e715f9e90c279da518c116d69671515051a393fd Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 20:52:25 +1300 Subject: [PATCH 129/144] Remove redundant V1 tests --- .github/workflows/tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6b965882fa..29b3bdd70d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -156,9 +156,6 @@ jobs: _APP_DATABASE_SHARED_TABLES: ${{ matrix.table_mode == 'Shared V1' || matrix.table_mode == 'Shared V2' && 'database_db_main' || '' }} _APP_DATABASE_SHARED_TABLES_V1: ${{ matrix.table_mode == 'Shared V1' && 'database_db_main' || '' }} - - name: Run ${{matrix.service}} Shared Tables V1 Tests - run: _APP_DATABASE_SHARED_TABLES=database_db_main _APP_DATABASE_SHARED_TABLES_V1=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - benchmarking: name: Benchmark runs-on: ubuntu-latest From 6e7dd26f75449cfa21ff0615f364493b717f7126 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:37:15 +0100 Subject: [PATCH 130/144] feat: fix web routes --- app/controllers/general.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 663242882a..b036539860 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -438,7 +438,7 @@ App::init() }); App::init() - ->groups(['api', 'web']) + ->groups(['api']) ->inject('utopia') ->inject('swooleRequest') ->inject('request') From dad8f597cae42dda827cf7f702dcbf762066d696 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:05:51 +0100 Subject: [PATCH 131/144] debug: whitelist console --- app/controllers/general.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index b036539860..26e052fe50 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -63,7 +63,7 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo } if (System::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { - if ($host !== 'localhost' && $host !== APP_HOSTNAME_INTERNAL) { // localhost allowed for proxy, APP_HOSTNAME_INTERNAL allowed for migrations + if ($host !== 'localhost' && $host !== APP_HOSTNAME_INTERNAL && $host !== System::getEnv('_APP_CONSOLE_DOMAIN', '')) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'Router protection does not allow accessing Appwrite over this domain. Please add it as custom domain to your project or disable _APP_OPTIONS_ROUTER_PROTECTION environment variable.'); } } From 900f64bf8ddf2bdf0d475ebca83409572ba0e7ca Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 12 Nov 2024 18:00:38 +0100 Subject: [PATCH 132/144] feat: hack for multi region --- app/controllers/api/projects.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 39300a2d4a..483ebdd7b4 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -136,6 +136,16 @@ App::post('/v1/projects') $dsn = $databases[array_rand($databases)]; } + $dsns = [ + 'fra' => 'database_db_fra1_self_hosted_0_0', + 'syd' => 'database_db_syd1_self_hosted_0_0', + 'nyc' => 'database_db_nyc1_self_hosted_0_0', + ]; + + if (isset($dsns[$region])) { + $dsn = $dsns[$region]; + } + // TODO: Temporary until all projects are using shared tables. $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); From 3f6368f046351b81b05a1633868e164dcb601499 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 21 Nov 2024 23:35:45 +0200 Subject: [PATCH 133/144] adding app region to console project --- src/Appwrite/Platform/Workers/Migrations.php | 43 ++++++++------------ 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index fdd885effa..d430d0eb67 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -16,6 +16,7 @@ use Utopia\Database\Exception\Conflict; use Utopia\Database\Exception\Restricted; use Utopia\Database\Exception\Structure; use Utopia\Database\Helpers\ID; +use Utopia\Logger\Log; use Utopia\Migration\Destination; use Utopia\Migration\Destinations\Appwrite as DestinationAppwrite; use Utopia\Migration\Exception as MigrationException; @@ -36,8 +37,6 @@ class Migrations extends Action protected Document $project; - protected $logError; - public static function getName(): string { return 'migrations'; @@ -53,14 +52,14 @@ class Migrations extends Action ->inject('message') ->inject('dbForProject') ->inject('dbForConsole') - ->inject('logError') - ->callback(fn (Message $message, Database $dbForProject, Database $dbForConsole, callable $logError) => $this->action($message, $dbForProject, $dbForConsole, $logError)); + ->inject('log') + ->callback(fn (Message $message, Database $dbForProject, Database $dbForConsole, Log $log) => $this->action($message, $dbForProject, $dbForConsole, $log)); } /** * @throws Exception */ - public function action(Message $message, Database $dbForProject, Database $dbForConsole, callable $logError): void + public function action(Message $message, Database $dbForProject, Database $dbForConsole, Log $log): void { $payload = $message->getPayload() ?? []; @@ -79,7 +78,6 @@ class Migrations extends Action $this->dbForProject = $dbForProject; $this->dbForConsole = $dbForConsole; $this->project = $project; - $this->logError = $logError; /** * Handle Event execution. @@ -88,7 +86,10 @@ class Migrations extends Action return; } - $this->processMigration($migration); + $log->addTag('migrationId', $migration->getId()); + $log->addTag('projectId', $project->getId()); + + $this->processMigration($migration, $log); } /** @@ -258,7 +259,7 @@ class Migrations extends Action * @throws \Utopia\Database\Exception * @throws Exception */ - protected function processMigration(Document $migration): void + protected function processMigration(Document $migration, Log $log): void { $project = $this->project; $projectDocument = $this->dbForConsole->getDocument('projects', $project->getId()); @@ -267,6 +268,8 @@ class Migrations extends Action $transfer = $source = $destination = null; try { + $migration = $this->dbForProject->getDocument('migrations', $migration->getId()); + if ( $migration->getAttribute('source') === SourceAppwrite::getName() && empty($migration->getAttribute('credentials', [])) @@ -284,6 +287,8 @@ class Migrations extends Action $migration->setAttribute('status', 'processing'); $this->updateMigrationDocument($migration, $projectDocument); + $log->addTag('type', $migration->getAttribute('source')); + $source = $this->processSource($migration); $destination = $this->processDestination($migration, $tempAPIKey->getAttribute('secret')); @@ -321,6 +326,7 @@ class Migrations extends Action $errorMessages = []; foreach ($sourceErrors as $error) { + /** @var $sourceErrors $error */ $message = "Error occurred while fetching '{$error->getResourceName()}:{$error->getResourceId()}' from source with message: '{$error->getMessage()}'"; if ($error->getPrevious()) { $message .= " Message: ".$error->getPrevious()->getMessage() . " File: ".$error->getPrevious()->getFile() . " Line: ".$error->getPrevious()->getLine(); @@ -340,6 +346,7 @@ class Migrations extends Action } $migration->setAttribute('errors', $errorMessages); + $log->addExtra('migrationErrors', json_encode($errorMessages)); $this->updateMigrationDocument($migration, $projectDocument); return; @@ -354,6 +361,7 @@ class Migrations extends Action if (! $migration->isEmpty()) { $migration->setAttribute('status', 'failed'); $migration->setAttribute('stage', 'finished'); + $migration->setAttribute('errors', [$th->getMessage()]); return; } @@ -373,6 +381,7 @@ class Migrations extends Action } $migration->setAttribute('errors', $errorMessages); + $log->addTag('migrationErrors', json_encode($errorMessages)); } } finally { if (! $tempAPIKey->isEmpty()) { @@ -387,23 +396,7 @@ class Migrations extends Action $destination->error(); $source->error(); - foreach ($source->getErrors() as $error) { - call_user_func($this->logError, $error, 'appwrite-worker', 'appwrite-queue-' . self::getName(), [ - 'migrationId' => $migration->getId() ?? '', - 'source' => $migration->getAttribute('source') ?? '', - 'resourceName' => $error->getResourceName(), - 'resourceGroup' => $error->getResourceGroup() - ]); - } - - foreach ($destination->getErrors() as $error) { - call_user_func($this->logError, $error, 'appwrite-worker', 'appwrite-queue-' . self::getName(), [ - 'migrationId' => $migration->getId() ?? '', - 'source' => $migration->getAttribute('source') ?? '', - 'resourceName' => $error->getResourceName(), - 'resourceGroup' => $error->getResourceGroup() - ]); - } + throw new Exception('Migration failed'); } if ($migration->getAttribute('status', '') === 'completed') { From 9839a4ef36d096e7e3b7e46e28c712a7540ee40a Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 24 Nov 2024 10:31:21 +0200 Subject: [PATCH 134/144] sync with 1.6.x --- src/Appwrite/Platform/Workers/Migrations.php | 43 ++++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index d430d0eb67..fdd885effa 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -16,7 +16,6 @@ use Utopia\Database\Exception\Conflict; use Utopia\Database\Exception\Restricted; use Utopia\Database\Exception\Structure; use Utopia\Database\Helpers\ID; -use Utopia\Logger\Log; use Utopia\Migration\Destination; use Utopia\Migration\Destinations\Appwrite as DestinationAppwrite; use Utopia\Migration\Exception as MigrationException; @@ -37,6 +36,8 @@ class Migrations extends Action protected Document $project; + protected $logError; + public static function getName(): string { return 'migrations'; @@ -52,14 +53,14 @@ class Migrations extends Action ->inject('message') ->inject('dbForProject') ->inject('dbForConsole') - ->inject('log') - ->callback(fn (Message $message, Database $dbForProject, Database $dbForConsole, Log $log) => $this->action($message, $dbForProject, $dbForConsole, $log)); + ->inject('logError') + ->callback(fn (Message $message, Database $dbForProject, Database $dbForConsole, callable $logError) => $this->action($message, $dbForProject, $dbForConsole, $logError)); } /** * @throws Exception */ - public function action(Message $message, Database $dbForProject, Database $dbForConsole, Log $log): void + public function action(Message $message, Database $dbForProject, Database $dbForConsole, callable $logError): void { $payload = $message->getPayload() ?? []; @@ -78,6 +79,7 @@ class Migrations extends Action $this->dbForProject = $dbForProject; $this->dbForConsole = $dbForConsole; $this->project = $project; + $this->logError = $logError; /** * Handle Event execution. @@ -86,10 +88,7 @@ class Migrations extends Action return; } - $log->addTag('migrationId', $migration->getId()); - $log->addTag('projectId', $project->getId()); - - $this->processMigration($migration, $log); + $this->processMigration($migration); } /** @@ -259,7 +258,7 @@ class Migrations extends Action * @throws \Utopia\Database\Exception * @throws Exception */ - protected function processMigration(Document $migration, Log $log): void + protected function processMigration(Document $migration): void { $project = $this->project; $projectDocument = $this->dbForConsole->getDocument('projects', $project->getId()); @@ -268,8 +267,6 @@ class Migrations extends Action $transfer = $source = $destination = null; try { - $migration = $this->dbForProject->getDocument('migrations', $migration->getId()); - if ( $migration->getAttribute('source') === SourceAppwrite::getName() && empty($migration->getAttribute('credentials', [])) @@ -287,8 +284,6 @@ class Migrations extends Action $migration->setAttribute('status', 'processing'); $this->updateMigrationDocument($migration, $projectDocument); - $log->addTag('type', $migration->getAttribute('source')); - $source = $this->processSource($migration); $destination = $this->processDestination($migration, $tempAPIKey->getAttribute('secret')); @@ -326,7 +321,6 @@ class Migrations extends Action $errorMessages = []; foreach ($sourceErrors as $error) { - /** @var $sourceErrors $error */ $message = "Error occurred while fetching '{$error->getResourceName()}:{$error->getResourceId()}' from source with message: '{$error->getMessage()}'"; if ($error->getPrevious()) { $message .= " Message: ".$error->getPrevious()->getMessage() . " File: ".$error->getPrevious()->getFile() . " Line: ".$error->getPrevious()->getLine(); @@ -346,7 +340,6 @@ class Migrations extends Action } $migration->setAttribute('errors', $errorMessages); - $log->addExtra('migrationErrors', json_encode($errorMessages)); $this->updateMigrationDocument($migration, $projectDocument); return; @@ -361,7 +354,6 @@ class Migrations extends Action if (! $migration->isEmpty()) { $migration->setAttribute('status', 'failed'); $migration->setAttribute('stage', 'finished'); - $migration->setAttribute('errors', [$th->getMessage()]); return; } @@ -381,7 +373,6 @@ class Migrations extends Action } $migration->setAttribute('errors', $errorMessages); - $log->addTag('migrationErrors', json_encode($errorMessages)); } } finally { if (! $tempAPIKey->isEmpty()) { @@ -396,7 +387,23 @@ class Migrations extends Action $destination->error(); $source->error(); - throw new Exception('Migration failed'); + foreach ($source->getErrors() as $error) { + call_user_func($this->logError, $error, 'appwrite-worker', 'appwrite-queue-' . self::getName(), [ + 'migrationId' => $migration->getId() ?? '', + 'source' => $migration->getAttribute('source') ?? '', + 'resourceName' => $error->getResourceName(), + 'resourceGroup' => $error->getResourceGroup() + ]); + } + + foreach ($destination->getErrors() as $error) { + call_user_func($this->logError, $error, 'appwrite-worker', 'appwrite-queue-' . self::getName(), [ + 'migrationId' => $migration->getId() ?? '', + 'source' => $migration->getAttribute('source') ?? '', + 'resourceName' => $error->getResourceName(), + 'resourceGroup' => $error->getResourceGroup() + ]); + } } if ($migration->getAttribute('status', '') === 'completed') { From 0f8ad539ad346bc5dff52c2808ad3b82903019b1 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 24 Nov 2024 10:32:27 +0200 Subject: [PATCH 135/144] composer.lock --- composer.lock | 2183 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 1844 insertions(+), 339 deletions(-) diff --git a/composer.lock b/composer.lock index 4b6a24fbfd..bec97d88c3 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": "217b0c1b6c156d51bf5a2674f87a7630", + "content-hash": "ae3b9a491c9870a4897cdf712caba1e3", "packages": [ { "name": "adhocore/jwt", @@ -277,6 +277,66 @@ }, "time": "2024-07-15T13:18:35+00:00" }, + { + "name": "brick/math", + "version": "0.12.1", + "source": { + "type": "git", + "url": "https://github.com/brick/math.git", + "reference": "f510c0a40911935b77b86859eb5223d58d660df1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/brick/math/zipball/f510c0a40911935b77b86859eb5223d58d660df1", + "reference": "f510c0a40911935b77b86859eb5223d58d660df1", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.2", + "phpunit/phpunit": "^10.1", + "vimeo/psalm": "5.16.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Brick\\Math\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Arbitrary-precision arithmetic library", + "keywords": [ + "Arbitrary-precision", + "BigInteger", + "BigRational", + "arithmetic", + "bigdecimal", + "bignum", + "bignumber", + "brick", + "decimal", + "integer", + "math", + "mathematics", + "rational" + ], + "support": { + "issues": "https://github.com/brick/math/issues", + "source": "https://github.com/brick/math/tree/0.12.1" + }, + "funding": [ + { + "url": "https://github.com/BenMorel", + "type": "github" + } + ], + "time": "2023-11-29T23:19:16+00:00" + }, { "name": "chillerlan/php-qrcode", "version": "4.3.4", @@ -422,6 +482,87 @@ ], "time": "2024-07-17T01:04:28+00:00" }, + { + "name": "composer/semver", + "version": "3.4.3", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", + "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "symfony/phpunit-bridge": "^3 || ^7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.3" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-09-19T14:15:21+00:00" + }, { "name": "dragonmantank/cron-expression", "version": "v3.3.2", @@ -567,29 +708,73 @@ "time": "2024-05-03T06:31:11+00:00" }, { - "name": "jean85/pretty-package-versions", - "version": "2.0.6", + "name": "google/protobuf", + "version": "v4.28.3", "source": { "type": "git", - "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4" + "url": "https://github.com/protocolbuffers/protobuf-php.git", + "reference": "c5c311e0f3d89928251ac5a2f0e3db283612c100" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/f9fdd29ad8e6d024f52678b570e5593759b550b4", - "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/c5c311e0f3d89928251ac5a2f0e3db283612c100", + "reference": "c5c311e0f3d89928251ac5a2f0e3db283612c100", "shasum": "" }, "require": { - "composer-runtime-api": "^2.0.0", - "php": "^7.1|^8.0" + "php": ">=7.0.0" + }, + "require-dev": { + "phpunit/phpunit": ">=5.0.0" + }, + "suggest": { + "ext-bcmath": "Need to support JSON deserialization" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\Protobuf\\": "src/Google/Protobuf", + "GPBMetadata\\Google\\Protobuf\\": "src/GPBMetadata/Google/Protobuf" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "proto library for PHP", + "homepage": "https://developers.google.com/protocol-buffers/", + "keywords": [ + "proto" + ], + "support": { + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.28.3" + }, + "time": "2024-10-22T22:27:17+00:00" + }, + { + "name": "jean85/pretty-package-versions", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", + "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2.1.0", + "php": "^7.4|^8.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", "jean85/composer-provided-replaced-stub-package": "^1.0", "phpstan/phpstan": "^1.4", - "phpunit/phpunit": "^7.5|^8.5|^9.4", - "vimeo/psalm": "^4.3" + "phpunit/phpunit": "^7.5|^8.5|^9.6", + "vimeo/psalm": "^4.3 || ^5.0" }, "type": "library", "extra": { @@ -621,9 +806,9 @@ ], "support": { "issues": "https://github.com/Jean85/pretty-package-versions/issues", - "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.6" + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.0" }, - "time": "2024-03-08T09:58:59+00:00" + "time": "2024-11-18T16:19:46+00:00" }, { "name": "league/csv", @@ -906,6 +1091,553 @@ }, "time": "2019-09-10T13:16:29+00:00" }, + { + "name": "nyholm/psr7", + "version": "1.8.2", + "source": { + "type": "git", + "url": "https://github.com/Nyholm/psr7.git", + "reference": "a71f2b11690f4b24d099d6b16690a90ae14fc6f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nyholm/psr7/zipball/a71f2b11690f4b24d099d6b16690a90ae14fc6f3", + "reference": "a71f2b11690f4b24d099d6b16690a90ae14fc6f3", + "shasum": "" + }, + "require": { + "php": ">=7.2", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0", + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "http-interop/http-factory-tests": "^0.9", + "php-http/message-factory": "^1.0", + "php-http/psr7-integration-tests": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.4", + "symfony/error-handler": "^4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Nyholm\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + }, + { + "name": "Martijn van der Ven", + "email": "martijn@vanderven.se" + } + ], + "description": "A fast PHP7 implementation of PSR-7", + "homepage": "https://tnyholm.se", + "keywords": [ + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/Nyholm/psr7/issues", + "source": "https://github.com/Nyholm/psr7/tree/1.8.2" + }, + "funding": [ + { + "url": "https://github.com/Zegnat", + "type": "github" + }, + { + "url": "https://github.com/nyholm", + "type": "github" + } + ], + "time": "2024-09-09T07:06:30+00:00" + }, + { + "name": "nyholm/psr7-server", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/Nyholm/psr7-server.git", + "reference": "4335801d851f554ca43fa6e7d2602141538854dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/4335801d851f554ca43fa6e7d2602141538854dc", + "reference": "4335801d851f554ca43fa6e7d2602141538854dc", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "require-dev": { + "nyholm/nsa": "^1.1", + "nyholm/psr7": "^1.3", + "phpunit/phpunit": "^7.0 || ^8.5 || ^9.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Nyholm\\Psr7Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + }, + { + "name": "Martijn van der Ven", + "email": "martijn@vanderven.se" + } + ], + "description": "Helper classes to handle PSR-7 server requests", + "homepage": "http://tnyholm.se", + "keywords": [ + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/Nyholm/psr7-server/issues", + "source": "https://github.com/Nyholm/psr7-server/tree/1.1.0" + }, + "funding": [ + { + "url": "https://github.com/Zegnat", + "type": "github" + }, + { + "url": "https://github.com/nyholm", + "type": "github" + } + ], + "time": "2023-11-08T09:30:43+00:00" + }, + { + "name": "open-telemetry/api", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/api.git", + "reference": "542064815d38a6df55af7957cd6f1d7d967c99c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/542064815d38a6df55af7957cd6f1d7d967c99c6", + "reference": "542064815d38a6df55af7957cd6f1d7d967c99c6", + "shasum": "" + }, + "require": { + "open-telemetry/context": "^1.0", + "php": "^8.1", + "psr/log": "^1.1|^2.0|^3.0", + "symfony/polyfill-php82": "^1.26" + }, + "conflict": { + "open-telemetry/sdk": "<=1.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.1.x-dev" + }, + "spi": { + "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\HookManagerInterface": [ + "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\ExtensionHookManager" + ] + } + }, + "autoload": { + "files": [ + "Trace/functions.php" + ], + "psr-4": { + "OpenTelemetry\\API\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "API for OpenTelemetry PHP.", + "keywords": [ + "Metrics", + "api", + "apm", + "logging", + "opentelemetry", + "otel", + "tracing" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-10-15T22:42:37+00:00" + }, + { + "name": "open-telemetry/context", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/context.git", + "reference": "0cba875ea1953435f78aec7f1d75afa87bdbf7f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/context/zipball/0cba875ea1953435f78aec7f1d75afa87bdbf7f3", + "reference": "0cba875ea1953435f78aec7f1d75afa87bdbf7f3", + "shasum": "" + }, + "require": { + "php": "^8.1", + "symfony/polyfill-php82": "^1.26" + }, + "suggest": { + "ext-ffi": "To allow context switching in Fibers" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.0.x-dev" + } + }, + "autoload": { + "files": [ + "fiber/initialize_fiber_handler.php" + ], + "psr-4": { + "OpenTelemetry\\Context\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "Context implementation for OpenTelemetry PHP.", + "keywords": [ + "Context", + "opentelemetry", + "otel" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-08-21T00:29:20+00:00" + }, + { + "name": "open-telemetry/exporter-otlp", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/exporter-otlp.git", + "reference": "9b6de12204f25f8ab9540b46d6e7b5151897ce18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/exporter-otlp/zipball/9b6de12204f25f8ab9540b46d6e7b5151897ce18", + "reference": "9b6de12204f25f8ab9540b46d6e7b5151897ce18", + "shasum": "" + }, + "require": { + "open-telemetry/api": "^1.0", + "open-telemetry/gen-otlp-protobuf": "^1.1", + "open-telemetry/sdk": "^1.0", + "php": "^8.1", + "php-http/discovery": "^1.14" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.0.x-dev" + } + }, + "autoload": { + "files": [ + "_register.php" + ], + "psr-4": { + "OpenTelemetry\\Contrib\\Otlp\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "OTLP exporter for OpenTelemetry.", + "keywords": [ + "Metrics", + "exporter", + "gRPC", + "http", + "opentelemetry", + "otel", + "otlp", + "tracing" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-04-30T18:28:30+00:00" + }, + { + "name": "open-telemetry/gen-otlp-protobuf", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/gen-otlp-protobuf.git", + "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/66c3b98e998a726691c92e6405a82e6e7b8b169d", + "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d", + "shasum": "" + }, + "require": { + "google/protobuf": "^3.22 || ^4.0", + "php": "^8.0" + }, + "suggest": { + "ext-protobuf": "For better performance, when dealing with the protobuf format" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Opentelemetry\\Proto\\": "Opentelemetry/Proto/", + "GPBMetadata\\Opentelemetry\\": "GPBMetadata/Opentelemetry/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "PHP protobuf files for communication with OpenTelemetry OTLP collectors/servers.", + "keywords": [ + "Metrics", + "apm", + "gRPC", + "logging", + "opentelemetry", + "otel", + "otlp", + "protobuf", + "tracing" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-10-30T11:49:49+00:00" + }, + { + "name": "open-telemetry/sdk", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/sdk.git", + "reference": "fb0ff8d8279a3776bd604791e2531dd0cc147e8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/fb0ff8d8279a3776bd604791e2531dd0cc147e8b", + "reference": "fb0ff8d8279a3776bd604791e2531dd0cc147e8b", + "shasum": "" + }, + "require": { + "ext-json": "*", + "nyholm/psr7-server": "^1.1", + "open-telemetry/api": "~1.0 || ~1.1", + "open-telemetry/context": "^1.0", + "open-telemetry/sem-conv": "^1.0", + "php": "^8.1", + "php-http/discovery": "^1.14", + "psr/http-client": "^1.0", + "psr/http-client-implementation": "^1.0", + "psr/http-factory-implementation": "^1.0", + "psr/http-message": "^1.0.1|^2.0", + "psr/log": "^1.1|^2.0|^3.0", + "ramsey/uuid": "^3.0 || ^4.0", + "symfony/polyfill-mbstring": "^1.23", + "symfony/polyfill-php82": "^1.26", + "tbachert/spi": "^1.0.1" + }, + "suggest": { + "ext-gmp": "To support unlimited number of synchronous metric readers", + "ext-mbstring": "To increase performance of string operations", + "open-telemetry/sdk-configuration": "File-based OpenTelemetry SDK configuration" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.0.x-dev" + }, + "spi": { + "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\HookManagerInterface": [ + "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\ExtensionHookManager" + ] + } + }, + "autoload": { + "files": [ + "Common/Util/functions.php", + "Logs/Exporter/_register.php", + "Metrics/MetricExporter/_register.php", + "Propagation/_register.php", + "Trace/SpanExporter/_register.php", + "Common/Dev/Compatibility/_load.php", + "_autoload.php" + ], + "psr-4": { + "OpenTelemetry\\SDK\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "SDK for OpenTelemetry PHP.", + "keywords": [ + "Metrics", + "apm", + "logging", + "opentelemetry", + "otel", + "sdk", + "tracing" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-10-18T21:01:35+00:00" + }, + { + "name": "open-telemetry/sem-conv", + "version": "1.27.1", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/sem-conv.git", + "reference": "1dba705fea74bc0718d04be26090e3697e56f4e6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/sem-conv/zipball/1dba705fea74bc0718d04be26090e3697e56f4e6", + "reference": "1dba705fea74bc0718d04be26090e3697e56f4e6", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "OpenTelemetry\\SemConv\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "Semantic conventions for OpenTelemetry PHP.", + "keywords": [ + "Metrics", + "apm", + "logging", + "opentelemetry", + "otel", + "semantic conventions", + "semconv", + "tracing" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-08-28T09:20:31+00:00" + }, { "name": "paragonie/constant_time_encoding", "version": "v2.7.0", @@ -973,6 +1705,85 @@ }, "time": "2024-05-08T12:18:48+00:00" }, + { + "name": "php-http/discovery", + "version": "1.20.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "82fe4c73ef3363caed49ff8dd1539ba06044910d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/82fe4c73ef3363caed49ff8dd1539ba06044910d", + "reference": "82fe4c73ef3363caed49ff8dd1539ba06044910d", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0|^2.0", + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0", + "zendframework/zend-diactoros": "*" + }, + "provide": { + "php-http/async-client-implementation": "*", + "php-http/client-implementation": "*", + "psr/http-client-implementation": "*", + "psr/http-factory-implementation": "*", + "psr/http-message-implementation": "*" + }, + "require-dev": { + "composer/composer": "^1.0.2|^2.0", + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1 || ^7.3", + "sebastian/comparator": "^3.0.5 || ^4.0.8", + "symfony/phpunit-bridge": "^6.4.4 || ^7.0.1" + }, + "type": "composer-plugin", + "extra": { + "class": "Http\\Discovery\\Composer\\Plugin", + "plugin-optional": true + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + }, + "exclude-from-classmap": [ + "src/Composer/Plugin.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr17", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.20.0" + }, + "time": "2024-10-02T11:20:13+00:00" + }, { "name": "phpmailer/phpmailer", "version": "v6.9.1", @@ -1054,6 +1865,450 @@ ], "time": "2023-11-25T22:23:28+00:00" }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "psr/log", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.2" + }, + "time": "2024-09-11T13:17:53+00:00" + }, + { + "name": "ramsey/collection", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/ramsey/collection.git", + "reference": "a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/collection/zipball/a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5", + "reference": "a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "captainhook/plugin-composer": "^5.3", + "ergebnis/composer-normalize": "^2.28.3", + "fakerphp/faker": "^1.21", + "hamcrest/hamcrest-php": "^2.0", + "jangregor/phpstan-prophecy": "^1.0", + "mockery/mockery": "^1.5", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpcsstandards/phpcsutils": "^1.0.0-rc1", + "phpspec/prophecy-phpunit": "^2.0", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan": "^1.9", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5", + "psalm/plugin-mockery": "^1.1", + "psalm/plugin-phpunit": "^0.18.4", + "ramsey/coding-standard": "^2.0.3", + "ramsey/conventional-commits": "^1.3", + "vimeo/psalm": "^5.4" + }, + "type": "library", + "extra": { + "captainhook": { + "force-install": true + }, + "ramsey/conventional-commits": { + "configFile": "conventional-commits.json" + } + }, + "autoload": { + "psr-4": { + "Ramsey\\Collection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "A PHP library for representing and manipulating collections.", + "keywords": [ + "array", + "collection", + "hash", + "map", + "queue", + "set" + ], + "support": { + "issues": "https://github.com/ramsey/collection/issues", + "source": "https://github.com/ramsey/collection/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/ramsey", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ramsey/collection", + "type": "tidelift" + } + ], + "time": "2022-12-31T21:50:55+00:00" + }, + { + "name": "ramsey/uuid", + "version": "4.7.6", + "source": { + "type": "git", + "url": "https://github.com/ramsey/uuid.git", + "reference": "91039bc1faa45ba123c4328958e620d382ec7088" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/91039bc1faa45ba123c4328958e620d382ec7088", + "reference": "91039bc1faa45ba123c4328958e620d382ec7088", + "shasum": "" + }, + "require": { + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12", + "ext-json": "*", + "php": "^8.0", + "ramsey/collection": "^1.2 || ^2.0" + }, + "replace": { + "rhumsaa/uuid": "self.version" + }, + "require-dev": { + "captainhook/captainhook": "^5.10", + "captainhook/plugin-composer": "^5.3", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "doctrine/annotations": "^1.8", + "ergebnis/composer-normalize": "^2.15", + "mockery/mockery": "^1.3", + "paragonie/random-lib": "^2", + "php-mock/php-mock": "^2.2", + "php-mock/php-mock-mockery": "^1.3", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpbench/phpbench": "^1.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^8.5 || ^9", + "ramsey/composer-repl": "^1.4", + "slevomat/coding-standard": "^8.4", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.9" + }, + "suggest": { + "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.", + "ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.", + "ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.", + "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", + "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." + }, + "type": "library", + "extra": { + "captainhook": { + "force-install": true + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A PHP library for generating and working with universally unique identifiers (UUIDs).", + "keywords": [ + "guid", + "identifier", + "uuid" + ], + "support": { + "issues": "https://github.com/ramsey/uuid/issues", + "source": "https://github.com/ramsey/uuid/tree/4.7.6" + }, + "funding": [ + { + "url": "https://github.com/ramsey", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ramsey/uuid", + "type": "tidelift" + } + ], + "time": "2024-04-27T21:32:50+00:00" + }, { "name": "spomky-labs/otphp", "version": "v10.0.3", @@ -1129,6 +2384,245 @@ }, "time": "2022-03-17T08:00:35+00:00" }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "symfony/http-client", + "version": "v7.1.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-client.git", + "reference": "c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-client/zipball/c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a", + "reference": "c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/log": "^1|^2|^3", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/http-client-contracts": "^3.4.1", + "symfony/service-contracts": "^2.5|^3" + }, + "conflict": { + "php-http/discovery": "<1.15", + "symfony/http-foundation": "<6.4" + }, + "provide": { + "php-http/async-client-implementation": "*", + "php-http/client-implementation": "*", + "psr/http-client-implementation": "1.0", + "symfony/http-client-implementation": "3.0" + }, + "require-dev": { + "amphp/amp": "^2.5", + "amphp/http-client": "^4.2.1", + "amphp/http-tunnel": "^1.0", + "amphp/socket": "^1.1", + "guzzlehttp/promises": "^1.4|^2.0", + "nyholm/psr7": "^1.0", + "php-http/httplug": "^1.0|^2.0", + "psr/http-client": "^1.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/messenger": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/rate-limiter": "^6.4|^7.0", + "symfony/stopwatch": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpClient\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides powerful methods to fetch HTTP resources synchronously or asynchronously", + "homepage": "https://symfony.com", + "keywords": [ + "http" + ], + "support": { + "source": "https://github.com/symfony/http-client/tree/v7.1.8" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-11-13T13:40:27+00:00" + }, + { + "name": "symfony/http-client-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-client-contracts.git", + "reference": "20414d96f391677bf80078aa55baece78b82647d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/20414d96f391677bf80078aa55baece78b82647d", + "reference": "20414d96f391677bf80078aa55baece78b82647d", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\HttpClient\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to HTTP clients", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/http-client-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.31.0", @@ -1289,6 +2783,217 @@ ], "time": "2024-09-09T11:45:10+00:00" }, + { + "name": "symfony/polyfill-php82", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php82.git", + "reference": "5d2ed36f7734637dacc025f179698031951b1692" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/5d2ed36f7734637dacc025f179698031951b1692", + "reference": "5d2ed36f7734637dacc025f179698031951b1692", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php82\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php82/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "tbachert/spi", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/Nevay/spi.git", + "reference": "2ddfaf815dafb45791a61b08170de8d583c16062" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nevay/spi/zipball/2ddfaf815dafb45791a61b08170de8d583c16062", + "reference": "2ddfaf815dafb45791a61b08170de8d583c16062", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "composer/semver": "^1.0 || ^2.0 || ^3.0", + "php": "^8.1" + }, + "require-dev": { + "composer/composer": "^2.0", + "infection/infection": "^0.27.9", + "phpunit/phpunit": "^10.5", + "psalm/phar": "^5.18" + }, + "type": "composer-plugin", + "extra": { + "branch-alias": { + "dev-main": "0.2.x-dev" + }, + "class": "Nevay\\SPI\\Composer\\Plugin", + "plugin-optional": true + }, + "autoload": { + "psr-4": { + "Nevay\\SPI\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Service provider loading facility", + "keywords": [ + "service provider" + ], + "support": { + "issues": "https://github.com/Nevay/spi/issues", + "source": "https://github.com/Nevay/spi/tree/v1.0.2" + }, + "time": "2024-10-04T16:36:12+00:00" + }, { "name": "thecodingmachine/safe", "version": "v2.5.0", @@ -1972,21 +3677,22 @@ }, { "name": "utopia-php/framework", - "version": "0.33.11", + "version": "0.33.14", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "354ff0d23bfc6e82bea0fe8e89e115cff1af8466" + "reference": "45a5a2db3602fa054096f378482c7da9936f5850" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/354ff0d23bfc6e82bea0fe8e89e115cff1af8466", - "reference": "354ff0d23bfc6e82bea0fe8e89e115cff1af8466", + "url": "https://api.github.com/repos/utopia-php/http/zipball/45a5a2db3602fa054096f378482c7da9936f5850", + "reference": "45a5a2db3602fa054096f378482c7da9936f5850", "shasum": "" }, "require": { - "php": ">=8.0", - "utopia-php/compression": "0.1.*" + "php": ">=8.1", + "utopia-php/compression": "0.1.*", + "utopia-php/telemetry": "0.1.*" }, "require-dev": { "laravel/pint": "^1.2", @@ -2012,9 +3718,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.11" + "source": "https://github.com/utopia-php/http/tree/0.33.14" }, - "time": "2024-11-08T18:47:43+00:00" + "time": "2024-11-20T12:39:10+00:00" }, { "name": "utopia-php/image", @@ -2542,22 +4248,23 @@ }, { "name": "utopia-php/queue", - "version": "0.7.2", + "version": "0.7.3", "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "40fdd9799d0a11dd33fca06f8223032a47dce2f6" + "reference": "16074a98ee7d6212bc1228de200e13db470c098a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/queue/zipball/40fdd9799d0a11dd33fca06f8223032a47dce2f6", - "reference": "40fdd9799d0a11dd33fca06f8223032a47dce2f6", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/16074a98ee7d6212bc1228de200e13db470c098a", + "reference": "16074a98ee7d6212bc1228de200e13db470c098a", "shasum": "" }, "require": { - "php": ">=8.0", + "php": ">=8.1", "utopia-php/cli": "0.15.*", - "utopia-php/framework": "0.*.*" + "utopia-php/framework": "0.*.*", + "utopia-php/telemetry": "0.1.*" }, "require-dev": { "laravel/pint": "^0.2.3", @@ -2597,9 +4304,9 @@ ], "support": { "issues": "https://github.com/utopia-php/queue/issues", - "source": "https://github.com/utopia-php/queue/tree/0.7.2" + "source": "https://github.com/utopia-php/queue/tree/0.7.3" }, - "time": "2024-11-11T10:04:02+00:00" + "time": "2024-11-13T12:47:48+00:00" }, { "name": "utopia-php/registry", @@ -2815,6 +4522,56 @@ }, "time": "2024-10-09T14:44:01+00:00" }, + { + "name": "utopia-php/telemetry", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/telemetry.git", + "reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/telemetry/zipball/d35f2f0632f4ee0be63fb7ace6a94a6adda71a80", + "reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80", + "shasum": "" + }, + "require": { + "ext-opentelemetry": "*", + "ext-protobuf": "*", + "nyholm/psr7": "^1.8", + "open-telemetry/exporter-otlp": "^1.1", + "open-telemetry/sdk": "^1.1", + "php": ">=8.0", + "symfony/http-client": "^7.1" + }, + "require-dev": { + "laravel/pint": "^1.2", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5.25" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "keywords": [ + "framework", + "php", + "upf" + ], + "support": { + "issues": "https://github.com/utopia-php/telemetry/issues", + "source": "https://github.com/utopia-php/telemetry/tree/0.1.0" + }, + "time": "2024-11-13T10:29:53+00:00" + }, { "name": "utopia-php/vcs", "version": "0.8.5", @@ -3049,16 +4806,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.24", + "version": "0.39.25", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "412451c87f6ef17e24e9a5cf41721043d74c60c8" + "reference": "5b5323636a8d75a1c4faaae9728098dd6a6a47d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/412451c87f6ef17e24e9a5cf41721043d74c60c8", - "reference": "412451c87f6ef17e24e9a5cf41721043d74c60c8", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/5b5323636a8d75a1c4faaae9728098dd6a6a47d1", + "reference": "5b5323636a8d75a1c4faaae9728098dd6a6a47d1", "shasum": "" }, "require": { @@ -3066,7 +4823,7 @@ "ext-json": "*", "ext-mbstring": "*", "matthiasmullie/minify": "1.3.*", - "php": ">=8.0", + "php": ">=8.3", "twig/twig": "3.14.*" }, "require-dev": { @@ -3094,9 +4851,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.39.24" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.25" }, - "time": "2024-10-09T19:13:27+00:00" + "time": "2024-11-08T10:16:34+00:00" }, { "name": "doctrine/annotations", @@ -3370,16 +5127,16 @@ }, { "name": "laravel/pint", - "version": "v1.18.1", + "version": "v1.18.2", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "35c00c05ec43e6b46d295efc0f4386ceb30d50d9" + "reference": "f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/35c00c05ec43e6b46d295efc0f4386ceb30d50d9", - "reference": "35c00c05ec43e6b46d295efc0f4386ceb30d50d9", + "url": "https://api.github.com/repos/laravel/pint/zipball/f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64", + "reference": "f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64", "shasum": "" }, "require": { @@ -3432,7 +5189,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-09-24T17:22:50+00:00" + "time": "2024-11-20T09:33:46+00:00" }, { "name": "matthiasmullie/minify", @@ -4051,16 +5808,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.5.1", + "version": "5.6.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f" + "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0c70d2c566e899666f367ab7b80986beb3581e6f", - "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/f3558a4c23426d12bffeaab463f8a8d8b681193c", + "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c", "shasum": "" }, "require": { @@ -4069,7 +5826,7 @@ "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", "phpdocumentor/type-resolver": "^1.7", - "phpstan/phpdoc-parser": "^1.7", + "phpstan/phpdoc-parser": "^1.7|^2.0", "webmozart/assert": "^1.9.1" }, "require-dev": { @@ -4109,9 +5866,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.5.1" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.0" }, - "time": "2024-11-06T11:58:54+00:00" + "time": "2024-11-12T11:25:25+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -4173,26 +5930,27 @@ }, { "name": "phpspec/prophecy", - "version": "v1.19.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "67a759e7d8746d501c41536ba40cd9c0a07d6a87" + "reference": "a0165c648cab6a80311c74ffc708a07bb53ecc93" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/67a759e7d8746d501c41536ba40cd9c0a07d6a87", - "reference": "67a759e7d8746d501c41536ba40cd9c0a07d6a87", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/a0165c648cab6a80311c74ffc708a07bb53ecc93", + "reference": "a0165c648cab6a80311c74ffc708a07bb53ecc93", "shasum": "" }, "require": { "doctrine/instantiator": "^1.2 || ^2.0", - "php": "^7.2 || 8.0.* || 8.1.* || 8.2.* || 8.3.*", + "php": "^7.2 || 8.0.* || 8.1.* || 8.2.* || 8.3.* || 8.4.*", "phpdocumentor/reflection-docblock": "^5.2", "sebastian/comparator": "^3.0 || ^4.0 || ^5.0 || ^6.0", "sebastian/recursion-context": "^3.0 || ^4.0 || ^5.0 || ^6.0" }, "require-dev": { + "friendsofphp/php-cs-fixer": "^3.40", "phpspec/phpspec": "^6.0 || ^7.0", "phpstan/phpstan": "^1.9", "phpunit/phpunit": "^8.0 || ^9.0 || ^10.0" @@ -4236,36 +5994,36 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.19.0" + "source": "https://github.com/phpspec/prophecy/tree/v1.20.0" }, - "time": "2024-02-29T11:52:51+00:00" + "time": "2024-11-19T13:12:41+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.33.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" + "reference": "c00d78fb6b29658347f9d37ebe104bffadf36299" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", - "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/c00d78fb6b29658347f9d37ebe104bffadf36299", + "reference": "c00d78fb6b29658347f9d37ebe104bffadf36299", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0" + "php": "^7.4 || ^8.0" }, "require-dev": { "doctrine/annotations": "^2.0", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^5.3.0", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.5", - "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^9.5", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6", "symfony/process": "^5.2" }, "type": "library", @@ -4283,9 +6041,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.0.0" }, - "time": "2024-10-13T11:25:22+00:00" + "time": "2024-10-13T11:29:49+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4758,109 +6516,6 @@ }, "time": "2021-02-03T23:26:27+00:00" }, - { - "name": "psr/container", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", - "shasum": "" - }, - "require": { - "php": ">=7.4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/2.0.2" - }, - "time": "2021-11-05T16:47:00+00:00" - }, - { - "name": "psr/log", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", - "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", - "shasum": "" - }, - "require": { - "php": ">=8.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/3.0.2" - }, - "time": "2024-09-11T13:17:53+00:00" - }, { "name": "sebastian/cli-parser", "version": "1.0.2", @@ -5922,16 +7577,16 @@ }, { "name": "symfony/console", - "version": "v7.1.7", + "version": "v7.1.8", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3284aafcac338b6e86fd955ee4d794cbe434151a" + "reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3284aafcac338b6e86fd955ee4d794cbe434151a", - "reference": "3284aafcac338b6e86fd955ee4d794cbe434151a", + "url": "https://api.github.com/repos/symfony/console/zipball/ff04e5b5ba043d2badfb308197b9e6b42883fcd5", + "reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5", "shasum": "" }, "require": { @@ -5995,7 +7650,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.7" + "source": "https://github.com/symfony/console/tree/v7.1.8" }, "funding": [ { @@ -6011,74 +7666,7 @@ "type": "tidelift" } ], - "time": "2024-11-05T15:34:55+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v3.5.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-11-06T14:23:19+00:00" }, { "name": "symfony/filesystem", @@ -6593,16 +8181,16 @@ }, { "name": "symfony/process", - "version": "v7.1.7", + "version": "v7.1.8", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "9b8a40b7289767aa7117e957573c2a535efe6585" + "reference": "42783370fda6e538771f7c7a36e9fa2ee3a84892" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/9b8a40b7289767aa7117e957573c2a535efe6585", - "reference": "9b8a40b7289767aa7117e957573c2a535efe6585", + "url": "https://api.github.com/repos/symfony/process/zipball/42783370fda6e538771f7c7a36e9fa2ee3a84892", + "reference": "42783370fda6e538771f7c7a36e9fa2ee3a84892", "shasum": "" }, "require": { @@ -6634,7 +8222,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.1.7" + "source": "https://github.com/symfony/process/tree/v7.1.8" }, "funding": [ { @@ -6650,103 +8238,20 @@ "type": "tidelift" } ], - "time": "2024-11-06T09:25:12+00:00" - }, - { - "name": "symfony/service-contracts", - "version": "v3.5.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "psr/container": "^1.1|^2.0", - "symfony/deprecation-contracts": "^2.5|^3" - }, - "conflict": { - "ext-psr": "<1.1|>=2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" - }, - "exclude-from-classmap": [ - "/Test/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-11-06T14:23:19+00:00" }, { "name": "symfony/string", - "version": "v7.1.6", + "version": "v7.1.8", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "61b72d66bf96c360a727ae6232df5ac83c71f626" + "reference": "591ebd41565f356fcd8b090fe64dbb5878f50281" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/61b72d66bf96c360a727ae6232df5ac83c71f626", - "reference": "61b72d66bf96c360a727ae6232df5ac83c71f626", + "url": "https://api.github.com/repos/symfony/string/zipball/591ebd41565f356fcd8b090fe64dbb5878f50281", + "reference": "591ebd41565f356fcd8b090fe64dbb5878f50281", "shasum": "" }, "require": { @@ -6804,7 +8309,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.6" + "source": "https://github.com/symfony/string/tree/v7.1.8" }, "funding": [ { @@ -6820,7 +8325,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2024-11-13T13:31:21+00:00" }, { "name": "textalk/websocket", @@ -7052,7 +8557,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From 7d5ae2f1c392f1ca14ed5b67f11e4b5d37e14f8f Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 24 Nov 2024 19:01:24 +0200 Subject: [PATCH 136/144] env var --- .env | 1 + app/controllers/api/projects.php | 11 +++++++++++ docker-compose.yml | 1 + 3 files changed, 13 insertions(+) diff --git a/.env b/.env index 8ff8164a21..80fcde67ca 100644 --- a/.env +++ b/.env @@ -108,3 +108,4 @@ _APP_MESSAGE_EMAIL_TEST_DSN= _APP_MESSAGE_PUSH_TEST_DSN= _APP_WEBHOOK_MAX_FAILED_ATTEMPTS=10 _APP_PROJECT_REGIONS=default +_APP_DATABASE_KEYS= diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 92d3103293..b75ea38591 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -128,6 +128,17 @@ App::post('/v1/projects') $databases = Config::getParam('pools-database', []); + if ($region !== 'default') { + $databases = System::getEnv('_APP_DATABASE_KEYS', ''); + var_dump($databases); + if ($region !== 'default') { + $databases = array_filter($databases, function ($value) use ($region) { + return str_contains($value, $region); + }); + } + } + + $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); $index = \array_search($databaseOverride, $databases); if ($index !== false) { diff --git a/docker-compose.yml b/docker-compose.yml index bae2cc7811..6c9f79520d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -195,6 +195,7 @@ services: - _APP_DATABASE_SHARED_TABLES - _APP_DATABASE_SHARED_TABLES_V1 - _APP_DATABASE_SHARED_NAMESPACE + - _APP_DATABASE_KEYS appwrite-console: <<: *x-logging From 3f0a8fbe215770e1a5a9794efa136c854a8803f6 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 24 Nov 2024 19:03:46 +0200 Subject: [PATCH 137/144] env var --- app/controllers/api/projects.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index b75ea38591..7b1a84b892 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -130,7 +130,6 @@ App::post('/v1/projects') if ($region !== 'default') { $databases = System::getEnv('_APP_DATABASE_KEYS', ''); - var_dump($databases); if ($region !== 'default') { $databases = array_filter($databases, function ($value) use ($region) { return str_contains($value, $region); @@ -138,7 +137,6 @@ App::post('/v1/projects') } } - $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); $index = \array_search($databaseOverride, $databases); if ($index !== false) { From c677374a11a5ea149c97cbafe608b8fdcef71d73 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 24 Nov 2024 19:39:44 +0200 Subject: [PATCH 138/144] env var --- app/controllers/api/projects.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 7b1a84b892..8506abb90e 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -134,6 +134,7 @@ App::post('/v1/projects') $databases = array_filter($databases, function ($value) use ($region) { return str_contains($value, $region); }); + var_dump($databases); } } From 00989fcdde4f531d6b7083d0894e22a30f3498aa Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 24 Nov 2024 20:40:06 +0200 Subject: [PATCH 139/144] env var --- .env | 3 +-- app/controllers/api/projects.php | 13 ++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.env b/.env index 80fcde67ca..28477256ac 100644 --- a/.env +++ b/.env @@ -107,5 +107,4 @@ _APP_MESSAGE_SMS_TEST_DSN= _APP_MESSAGE_EMAIL_TEST_DSN= _APP_MESSAGE_PUSH_TEST_DSN= _APP_WEBHOOK_MAX_FAILED_ATTEMPTS=10 -_APP_PROJECT_REGIONS=default -_APP_DATABASE_KEYS= +_APP_PROJECT_REGIONS=default \ No newline at end of file diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 8506abb90e..1121b19910 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -128,14 +128,13 @@ App::post('/v1/projects') $databases = Config::getParam('pools-database', []); + if ($region !== 'default') { - $databases = System::getEnv('_APP_DATABASE_KEYS', ''); - if ($region !== 'default') { - $databases = array_filter($databases, function ($value) use ($region) { - return str_contains($value, $region); - }); - var_dump($databases); - } + $databaseKeys = System::getEnv('_APP_DATABASE_KEYS', ''); + $keys = explode(',', $databaseKeys); + $databases = array_filter($keys, function ($value) use ($region) { + return str_contains($value, $region); + }); } $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); From f1a3cd13ffaf372c7a5cce8c1d50e3272e1e7fd1 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 24 Nov 2024 22:52:20 +0200 Subject: [PATCH 140/144] env var --- app/controllers/api/projects.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 1121b19910..c840849fec 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -208,7 +208,6 @@ App::post('/v1/projects') $dbForProject = new Database($adapter, $cache); $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); - $projectTables = !\in_array($dsn->getHost(), $sharedTables); $sharedTablesV1 = \in_array($dsn->getHost(), $sharedTablesV1); $sharedTablesV2 = !$projectTables && !$sharedTablesV1; @@ -235,6 +234,11 @@ App::post('/v1/projects') $create = false; } + var_dump($create); + var_dump($projectTables); + var_dump($sharedTablesV2); + var_dump($sharedTablesV2); + if ($create || $projectTables) { $audit = new Audit($dbForProject); $audit->setup(); From aa8af5a2136f080cc9e9e58f8ce85ef34fc5159c Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 24 Nov 2024 23:09:22 +0200 Subject: [PATCH 141/144] env var --- app/controllers/api/projects.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index c840849fec..33ec7760ac 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -213,6 +213,10 @@ App::post('/v1/projects') $sharedTablesV2 = !$projectTables && !$sharedTablesV1; $sharedTables = $sharedTablesV1 || $sharedTablesV2; + var_dump($projectTables); + var_dump($sharedTablesV2); + var_dump($sharedTablesV2); + if (!$sharedTablesV2) { if ($sharedTables) { $dbForProject @@ -234,10 +238,7 @@ App::post('/v1/projects') $create = false; } - var_dump($create); - var_dump($projectTables); - var_dump($sharedTablesV2); - var_dump($sharedTablesV2); + if ($create || $projectTables) { $audit = new Audit($dbForProject); From 6d376df00a964c4d83fe4f08d46e0e988a0e0794 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 25 Nov 2024 09:44:57 +0200 Subject: [PATCH 142/144] updates --- app/controllers/api/projects.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 33ec7760ac..679f2a2684 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -204,8 +204,6 @@ App::post('/v1/projects') $dsn = new DSN('mysql://' . $dsn); } - $adapter = $pools->get($dsn->getHost())->pop()->getResource(); - $dbForProject = new Database($adapter, $cache); $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); $projectTables = !\in_array($dsn->getHost(), $sharedTables); @@ -213,11 +211,10 @@ App::post('/v1/projects') $sharedTablesV2 = !$projectTables && !$sharedTablesV1; $sharedTables = $sharedTablesV1 || $sharedTablesV2; - var_dump($projectTables); - var_dump($sharedTablesV2); - var_dump($sharedTablesV2); - if (!$sharedTablesV2) { + $adapter = $pools->get($dsn->getHost())->pop()->getResource(); + $dbForProject = new Database($adapter, $cache); + if ($sharedTables) { $dbForProject ->setSharedTables(true) From 7ae7ccbe49be88fa187667ea7facf971fa2e5794 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 25 Nov 2024 12:02:00 +0200 Subject: [PATCH 143/144] debug --- app/controllers/api/projects.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 679f2a2684..ccd744a353 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -210,7 +210,10 @@ App::post('/v1/projects') $sharedTablesV1 = \in_array($dsn->getHost(), $sharedTablesV1); $sharedTablesV2 = !$projectTables && !$sharedTablesV1; $sharedTables = $sharedTablesV1 || $sharedTablesV2; - + var_dump($dsn->getHost()); + var_dump($projectTables); + var_dump($sharedTablesV1); + var_dump($sharedTablesV2); if (!$sharedTablesV2) { $adapter = $pools->get($dsn->getHost())->pop()->getResource(); $dbForProject = new Database($adapter, $cache); From 7656ba11ffa2fa9d55516aa6b1a5d785ba19f8f7 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 25 Nov 2024 12:31:06 +0200 Subject: [PATCH 144/144] debug --- app/controllers/api/projects.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index ccd744a353..6399a5e61e 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -211,6 +211,7 @@ App::post('/v1/projects') $sharedTablesV2 = !$projectTables && !$sharedTablesV1; $sharedTables = $sharedTablesV1 || $sharedTablesV2; var_dump($dsn->getHost()); + var_dump($sharedTables); var_dump($projectTables); var_dump($sharedTablesV1); var_dump($sharedTablesV2);