From 03d33601b07b1545841bf466a254fc91b5a7b212 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 14 Jun 2024 13:08:30 +1200 Subject: [PATCH 001/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] _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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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/279] 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 0e038421736013e4edb70ade8a8b5cef609eb7e3 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 25 Nov 2024 17:20:27 +1300 Subject: [PATCH 142/279] Move pool access inside not V2 block --- app/controllers/api/projects.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 92d3103293..5f185c091a 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -195,8 +195,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', '')); @@ -206,6 +204,9 @@ App::post('/v1/projects') $sharedTables = $sharedTablesV1 || $sharedTablesV2; if (!$sharedTablesV2) { + $adapter = $pools->get($dsn->getHost())->pop()->getResource(); + $dbForProject = new Database($adapter, $cache); + if ($sharedTables) { $dbForProject ->setSharedTables(true) From 6d376df00a964c4d83fe4f08d46e0e988a0e0794 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 25 Nov 2024 09:44:57 +0200 Subject: [PATCH 143/279] 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 144/279] 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 145/279] 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); From 928590b1750c099b4ba7293c7c2d3f5cf2a2cdc7 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 26 Nov 2024 16:20:11 +1300 Subject: [PATCH 146/279] Only create databases for current region --- app/http.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/http.php b/app/http.php index c80fccee54..e276dac519 100644 --- a/app/http.php +++ b/app/http.php @@ -264,9 +264,15 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); $sharedTablesV2 = \array_diff($sharedTables, $sharedTablesV1); + $region = System::getEnv('_APP_REGION', 'fra'); $cache = $app->getResource('cache'); - foreach ($sharedTablesV2 as $hostname) { + $regionDatabases = \array_filter( + $sharedTablesV2, + fn ($hostname) => \str_contains($hostname, $region) + ); + + foreach ($regionDatabases as $hostname) { $adapter = $pools ->get($hostname) ->pop() From ddb86127b7bcc44e8f761349a72d4aa9f09985e2 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 26 Nov 2024 18:29:10 +1300 Subject: [PATCH 147/279] Fix lint --- app/controllers/api/projects.php | 2 +- app/init.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 6399a5e61e..45799ce86f 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -133,7 +133,7 @@ App::post('/v1/projects') $databaseKeys = System::getEnv('_APP_DATABASE_KEYS', ''); $keys = explode(',', $databaseKeys); $databases = array_filter($keys, function ($value) use ($region) { - return str_contains($value, $region); + return str_contains($value, $region); }); } diff --git a/app/init.php b/app/init.php index 97efbcf134..de4a411933 100644 --- a/app/init.php +++ b/app/init.php @@ -1334,7 +1334,7 @@ App::setResource('project', function ($dbForConsole, $request, $console) { $project = Authorization::skip(fn () => $dbForConsole->getDocument('projects', $projectId)); - if($project->getAttribute('region') !== System::getEnv('_APP_REGION')){ + 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'); } From 6f8c38dfa00edf02d1465f5c29f088931808e59d Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 26 Nov 2024 09:26:14 +0200 Subject: [PATCH 148/279] debug --- .env | 2 +- app/controllers/api/projects.php | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.env b/.env index 28477256ac..8ff8164a21 100644 --- a/.env +++ b/.env @@ -107,4 +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 \ No newline at end of file +_APP_PROJECT_REGIONS=default diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 6399a5e61e..679f2a2684 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -210,11 +210,7 @@ App::post('/v1/projects') $sharedTablesV1 = \in_array($dsn->getHost(), $sharedTablesV1); $sharedTablesV2 = !$projectTables && !$sharedTablesV1; $sharedTables = $sharedTablesV1 || $sharedTablesV2; - var_dump($dsn->getHost()); - var_dump($sharedTables); - var_dump($projectTables); - var_dump($sharedTablesV1); - var_dump($sharedTablesV2); + if (!$sharedTablesV2) { $adapter = $pools->get($dsn->getHost())->pop()->getResource(); $dbForProject = new Database($adapter, $cache); From d2bf15b20be35dd11677f3eb81ad73ead45b566c Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 26 Nov 2024 11:50:34 +0200 Subject: [PATCH 149/279] debug --- app/init.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/init.php b/app/init.php index de4a411933..d7a05951c7 100644 --- a/app/init.php +++ b/app/init.php @@ -1335,6 +1335,8 @@ App::setResource('project', function ($dbForConsole, $request, $console) { $project = Authorization::skip(fn () => $dbForConsole->getDocument('projects', $projectId)); if ($project->getAttribute('region') !== System::getEnv('_APP_REGION')) { + var_dump(System::getEnv('_APP_REGION')); + var_dump($project->getAttribute('region')); throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, 'Project is not accessible in this region. Please make sure you are using the correct endpoint'); } From 5e3e0b66834021528e48b51455e7dca821bf3e6a Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 26 Nov 2024 12:43:31 +0200 Subject: [PATCH 150/279] debug --- app/console | 1 - 1 file changed, 1 deletion(-) delete mode 160000 app/console diff --git a/app/console b/app/console deleted file mode 160000 index 0959b594b3..0000000000 --- a/app/console +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0959b594b32f176819d4afb3a769afea212db789 From ac27c7742616bd543d18093f4d38efbe37cdf221 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 29 Nov 2024 13:14:20 +0200 Subject: [PATCH 151/279] debug --- 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 d223594cf5..994cb588db 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -658,7 +658,7 @@ App::init() if ($request->getProtocol() === 'https') { $response->addHeader('Strict-Transport-Security', 'max-age=' . (60 * 60 * 24 * 126)); // 126 days } - + var_dump('refDomain='.$refDomain); $response ->addHeader('Server', 'Appwrite') ->addHeader('X-Content-Type-Options', 'nosniff') From 65474df6422755ec11de25f21447fbf3e34bf9c5 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 29 Nov 2024 13:30:04 +0200 Subject: [PATCH 152/279] debug --- app/controllers/general.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index 994cb588db..d98eeac059 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -583,6 +583,7 @@ App::init() $port = \parse_url($request->getOrigin($referrer), PHP_URL_PORT); $refDomainOrigin = 'localhost'; + var_dump($clients); $validator = new Hostname($clients); if ($validator->isValid($origin)) { $refDomainOrigin = $origin; From 61d030b2c6f111aa09a0faeb4cd9505cffd2fda4 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 29 Nov 2024 15:24:52 +0200 Subject: [PATCH 153/279] sync with 1.6.x --- 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 13fef007f3..f514402ca7 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -587,7 +587,6 @@ App::init() $port = \parse_url($request->getOrigin($referrer), PHP_URL_PORT); $refDomainOrigin = 'localhost'; - var_dump($clients); $validator = new Hostname($clients); if ($validator->isValid($origin)) { $refDomainOrigin = $origin; @@ -663,6 +662,7 @@ App::init() if ($request->getProtocol() === 'https') { $response->addHeader('Strict-Transport-Security', 'max-age=' . (60 * 60 * 24 * 126)); // 126 days } + var_dump('origin='.$origin); var_dump('refDomain='.$refDomain); $response ->addHeader('Server', 'Appwrite') From cb93b9e1e7453c8d378c68d2ca9698bf4c6995ed Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 1 Dec 2024 19:25:43 +0200 Subject: [PATCH 154/279] debug --- app/controllers/general.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index f514402ca7..4d8ddc478d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -601,6 +601,15 @@ App::init() $selfDomain = new Domain($request->getHostname()); $endDomain = new Domain((string)$origin); + + var_dump($clients); + var_dump($request->getOrigin()); + var_dump(\parse_url($request->getOrigin(), PHP_URL_HOST)); + var_dump($request->getReferer()); + var_dump(\parse_url($request->getOrigin($referrer), PHP_URL_HOST)); + var_dump('refDomain='.$refDomain); + + Config::setParam( 'domainVerification', ($selfDomain->getRegisterable() === $endDomain->getRegisterable()) && @@ -662,8 +671,7 @@ App::init() if ($request->getProtocol() === 'https') { $response->addHeader('Strict-Transport-Security', 'max-age=' . (60 * 60 * 24 * 126)); // 126 days } - var_dump('origin='.$origin); - var_dump('refDomain='.$refDomain); + $response ->addHeader('Server', 'Appwrite') ->addHeader('X-Content-Type-Options', 'nosniff') From ba510a56415806c1e9234b01476e3c735aafa6e6 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 1 Dec 2024 20:07:40 +0200 Subject: [PATCH 155/279] debug --- app/controllers/api/databases.php | 1 + app/controllers/general.php | 6 +----- app/init.php | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index aad072c50a..9b7dfb0936 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -207,6 +207,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); } + var_dump('pushing to queue '. $db); $queueForDatabase ->setType(DATABASE_TYPE_CREATE_ATTRIBUTE) ->setDatabase($db) diff --git a/app/controllers/general.php b/app/controllers/general.php index 4d8ddc478d..5a578232e9 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -602,11 +602,7 @@ App::init() $endDomain = new Domain((string)$origin); - var_dump($clients); - var_dump($request->getOrigin()); - var_dump(\parse_url($request->getOrigin(), PHP_URL_HOST)); - var_dump($request->getReferer()); - var_dump(\parse_url($request->getOrigin($referrer), PHP_URL_HOST)); + var_dump('origin='.$origin); var_dump('refDomain='.$refDomain); diff --git a/app/init.php b/app/init.php index 058cf82833..82a561ca1e 100644 --- a/app/init.php +++ b/app/init.php @@ -1335,8 +1335,8 @@ App::setResource('project', function ($dbForConsole, $request, $console) { $project = Authorization::skip(fn () => $dbForConsole->getDocument('projects', $projectId)); if ($project->getAttribute('region') !== System::getEnv('_APP_REGION')) { - var_dump(System::getEnv('_APP_REGION')); - var_dump($project->getAttribute('region')); + var_dump('_APP_REGION='. System::getEnv('_APP_REGION')); + var_dump('projectRegion='. $project->getAttribute('region')); throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, 'Project is not accessible in this region. Please make sure you are using the correct endpoint'); } From 1a6f23c3a120e179a3717b305f2c5861c58eee85 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 2 Dec 2024 10:13:10 +0200 Subject: [PATCH 156/279] debug --- app/controllers/api/databases.php | 3 ++- app/controllers/shared/api.php | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 9b7dfb0936..c72d26dc40 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -207,7 +207,8 @@ function createAttribute(string $databaseId, string $collectionId, Document $att $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); } - var_dump('pushing to queue '. $db); + var_dump('pushing to queue'); + var_dump($db); $queueForDatabase ->setType(DATABASE_TYPE_CREATE_ATTRIBUTE) ->setDatabase($db) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 91883b0895..e5a296cedf 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -545,6 +545,10 @@ App::init() $data = $cache->load($key, $timestamp); if (!empty($data) && !$cacheLog->isEmpty()) { + var_dump($request->getURI()); + var_dump($request->getParams()); + var_dump($cacheLog); + var_dump($data); $parts = explode('/', $cacheLog->getAttribute('resourceType')); $type = $parts[0] ?? null; From d06e41f81edb59cd2d5418e282a338e47a71ec89 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 3 Dec 2024 15:00:45 +0200 Subject: [PATCH 157/279] debug --- app/controllers/api/databases.php | 4 ++-- app/controllers/general.php | 8 +++----- app/init.php | 1 + 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index c72d26dc40..94074cc840 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -207,8 +207,8 @@ function createAttribute(string $databaseId, string $collectionId, Document $att $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); } - var_dump('pushing to queue'); - var_dump($db); + var_dump('**pushing to queue**'); + $queueForDatabase ->setType(DATABASE_TYPE_CREATE_ATTRIBUTE) ->setDatabase($db) diff --git a/app/controllers/general.php b/app/controllers/general.php index 5a578232e9..5cbd947f11 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -601,11 +601,6 @@ App::init() $selfDomain = new Domain($request->getHostname()); $endDomain = new Domain((string)$origin); - - var_dump('origin='.$origin); - var_dump('refDomain='.$refDomain); - - Config::setParam( 'domainVerification', ($selfDomain->getRegisterable() === $endDomain->getRegisterable()) && @@ -714,6 +709,9 @@ App::options() */ $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); + var_dump('host='.$host); + var_dump('mainDomain='.$mainDomain); + var_dump('previewHostname='.$previewHostname); // Only run Router when external domain if ($host !== $mainDomain || !empty($previewHostname)) { if (router($utopia, $dbForConsole, $getProjectDB, $swooleRequest, $request, $response, $queueForEvents, $queueForUsage, $queueForFunctions, $geodb, $isResourceBlocked, $previewHostname)) { diff --git a/app/init.php b/app/init.php index 82a561ca1e..4b13e277a7 100644 --- a/app/init.php +++ b/app/init.php @@ -950,6 +950,7 @@ $register->set('pools', function () { }, 'redis' => function () use ($dsnHost, $dsnPort, $dsnPass) { $redis = new Redis(); + var_dump('RedisHost='.$dsnHost); @$redis->pconnect($dsnHost, (int)$dsnPort); if ($dsnPass) { $redis->auth($dsnPass); From 635dbdb5cbaec90bbeb16de5d3f15f3891fd7064 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 3 Dec 2024 16:38:44 +0200 Subject: [PATCH 158/279] debug --- app/controllers/general.php | 3 --- app/controllers/shared/api.php | 6 +----- app/init.php | 5 ++--- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 5cbd947f11..f8d5b161d4 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -709,9 +709,6 @@ App::options() */ $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); - var_dump('host='.$host); - var_dump('mainDomain='.$mainDomain); - var_dump('previewHostname='.$previewHostname); // Only run Router when external domain if ($host !== $mainDomain || !empty($previewHostname)) { if (router($utopia, $dbForConsole, $getProjectDB, $swooleRequest, $request, $response, $queueForEvents, $queueForUsage, $queueForFunctions, $geodb, $isResourceBlocked, $previewHostname)) { diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index e5a296cedf..5118e94350 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -545,11 +545,7 @@ App::init() $data = $cache->load($key, $timestamp); if (!empty($data) && !$cacheLog->isEmpty()) { - var_dump($request->getURI()); - var_dump($request->getParams()); - var_dump($cacheLog); - var_dump($data); - $parts = explode('/', $cacheLog->getAttribute('resourceType')); + $parts = explode('/', $cacheLog->getAttribute('resourceType', '')); $type = $parts[0] ?? null; if ($type === 'bucket') { diff --git a/app/init.php b/app/init.php index 4b13e277a7..058cf82833 100644 --- a/app/init.php +++ b/app/init.php @@ -950,7 +950,6 @@ $register->set('pools', function () { }, 'redis' => function () use ($dsnHost, $dsnPort, $dsnPass) { $redis = new Redis(); - var_dump('RedisHost='.$dsnHost); @$redis->pconnect($dsnHost, (int)$dsnPort); if ($dsnPass) { $redis->auth($dsnPass); @@ -1336,8 +1335,8 @@ App::setResource('project', function ($dbForConsole, $request, $console) { $project = Authorization::skip(fn () => $dbForConsole->getDocument('projects', $projectId)); if ($project->getAttribute('region') !== System::getEnv('_APP_REGION')) { - var_dump('_APP_REGION='. System::getEnv('_APP_REGION')); - var_dump('projectRegion='. $project->getAttribute('region')); + var_dump(System::getEnv('_APP_REGION')); + var_dump($project->getAttribute('region')); throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, 'Project is not accessible in this region. Please make sure you are using the correct endpoint'); } From b04a85491b6a79d74a8a3cfe9bf40ba6b470c8c8 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 3 Dec 2024 17:36:19 +0200 Subject: [PATCH 159/279] debug --- app/controllers/api/databases.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 94074cc840..33b37bb1b6 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -207,8 +207,6 @@ function createAttribute(string $databaseId, string $collectionId, Document $att $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); } - var_dump('**pushing to queue**'); - $queueForDatabase ->setType(DATABASE_TYPE_CREATE_ATTRIBUTE) ->setDatabase($db) @@ -2897,7 +2895,11 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents') } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getInternalId(), $collectionId)); - + var_dump('database_' . $database->getInternalId()); + var_dump($collectionId); + var_dump($collection); + var_dump($isAPIKey); + var_dump($isPrivilegedUser); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::COLLECTION_NOT_FOUND); } From 316b739a274339a941d279bee4a7b13d73a87329 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 3 Dec 2024 19:43:39 +0200 Subject: [PATCH 160/279] composer --- composer.json | 2 +- composer.lock | 121 +++++++++++++++++++++++++------------------------- 2 files changed, 62 insertions(+), 61 deletions(-) diff --git a/composer.json b/composer.json index e3fbcabc83..d6124e8b1c 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.20", + "utopia-php/database": "0.53.25", "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 db479b362e..f671cc3a48 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": "ae3b9a491c9870a4897cdf712caba1e3", + "content-hash": "db3e97b504d4482957dafccb618d5187", "packages": [ { "name": "adhocore/jwt", @@ -2343,9 +2343,9 @@ "type": "library", "extra": { "branch-alias": { - "v10.0": "10.0.x-dev", + "v8.3": "8.3.x-dev", "v9.0": "9.0.x-dev", - "v8.3": "8.3.x-dev" + "v10.0": "10.0.x-dev" } }, "autoload": { @@ -2453,16 +2453,16 @@ }, { "name": "symfony/http-client", - "version": "v7.1.9", + "version": "v7.2.0", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "2ec49720a38a8041673ba4c42512bfd845218c56" + "reference": "955e43336aff03df1e8a8e17daefabb0127a313b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/2ec49720a38a8041673ba4c42512bfd845218c56", - "reference": "2ec49720a38a8041673ba4c42512bfd845218c56", + "url": "https://api.github.com/repos/symfony/http-client/zipball/955e43336aff03df1e8a8e17daefabb0127a313b", + "reference": "955e43336aff03df1e8a8e17daefabb0127a313b", "shasum": "" }, "require": { @@ -2473,6 +2473,7 @@ "symfony/service-contracts": "^2.5|^3" }, "conflict": { + "amphp/amp": "<2.5", "php-http/discovery": "<1.15", "symfony/http-foundation": "<6.4" }, @@ -2483,14 +2484,14 @@ "symfony/http-client-implementation": "3.0" }, "require-dev": { - "amphp/amp": "^2.5", - "amphp/http-client": "^4.2.1", - "amphp/http-tunnel": "^1.0", + "amphp/http-client": "^4.2.1|^5.0", + "amphp/http-tunnel": "^1.0|^2.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/amphp-http-client-meta": "^1.0|^2.0", "symfony/dependency-injection": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0", "symfony/messenger": "^6.4|^7.0", @@ -2527,7 +2528,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.1.9" + "source": "https://github.com/symfony/http-client/tree/v7.2.0" }, "funding": [ { @@ -2543,7 +2544,7 @@ "type": "tidelift" } ], - "time": "2024-11-27T11:52:45+00:00" + "time": "2024-11-29T08:22:02+00:00" }, { "name": "symfony/http-client-contracts", @@ -3475,16 +3476,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.20", + "version": "0.53.25", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "e43f8ee26e06ee8812737e63642dbd7ee7c9dc04" + "reference": "d95bbbd4f7fb74b020b0abae7f9970d71ca52baa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/e43f8ee26e06ee8812737e63642dbd7ee7c9dc04", - "reference": "e43f8ee26e06ee8812737e63642dbd7ee7c9dc04", + "url": "https://api.github.com/repos/utopia-php/database/zipball/d95bbbd4f7fb74b020b0abae7f9970d71ca52baa", + "reference": "d95bbbd4f7fb74b020b0abae7f9970d71ca52baa", "shasum": "" }, "require": { @@ -3525,9 +3526,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.20" + "source": "https://github.com/utopia-php/database/tree/0.53.25" }, - "time": "2024-11-12T00:23:36+00:00" + "time": "2024-12-02T05:09:19+00:00" }, { "name": "utopia-php/domains", @@ -4362,16 +4363,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.6", + "version": "0.18.7", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "893ccf06e183f8ece2aed8dbf14d64d6ba036071" + "reference": "0d9228faa1c202f9e01483e45a8950485f01a288" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/893ccf06e183f8ece2aed8dbf14d64d6ba036071", - "reference": "893ccf06e183f8ece2aed8dbf14d64d6ba036071", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/0d9228faa1c202f9e01483e45a8950485f01a288", + "reference": "0d9228faa1c202f9e01483e45a8950485f01a288", "shasum": "" }, "require": { @@ -4411,9 +4412,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.6" + "source": "https://github.com/utopia-php/storage/tree/0.18.7" }, - "time": "2024-11-06T09:58:50+00:00" + "time": "2024-11-28T11:10:53+00:00" }, { "name": "utopia-php/swoole", @@ -7577,16 +7578,16 @@ }, { "name": "symfony/console", - "version": "v7.1.8", + "version": "v7.2.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5" + "reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/ff04e5b5ba043d2badfb308197b9e6b42883fcd5", - "reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5", + "url": "https://api.github.com/repos/symfony/console/zipball/23c8aae6d764e2bae02d2a99f7532a7f6ed619cf", + "reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf", "shasum": "" }, "require": { @@ -7650,7 +7651,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.8" + "source": "https://github.com/symfony/console/tree/v7.2.0" }, "funding": [ { @@ -7666,20 +7667,20 @@ "type": "tidelift" } ], - "time": "2024-11-06T14:23:19+00:00" + "time": "2024-11-06T14:24:19+00:00" }, { "name": "symfony/filesystem", - "version": "v7.1.6", + "version": "v7.2.0", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "c835867b3c62bb05c7fe3d637c871c7ae52024d4" + "reference": "b8dce482de9d7c9fe2891155035a7248ab5c7fdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/c835867b3c62bb05c7fe3d637c871c7ae52024d4", - "reference": "c835867b3c62bb05c7fe3d637c871c7ae52024d4", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/b8dce482de9d7c9fe2891155035a7248ab5c7fdb", + "reference": "b8dce482de9d7c9fe2891155035a7248ab5c7fdb", "shasum": "" }, "require": { @@ -7716,7 +7717,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.1.6" + "source": "https://github.com/symfony/filesystem/tree/v7.2.0" }, "funding": [ { @@ -7732,20 +7733,20 @@ "type": "tidelift" } ], - "time": "2024-10-25T15:11:02+00:00" + "time": "2024-10-25T15:15:23+00:00" }, { "name": "symfony/finder", - "version": "v7.1.6", + "version": "v7.2.0", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "2cb89664897be33f78c65d3d2845954c8d7a43b8" + "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/2cb89664897be33f78c65d3d2845954c8d7a43b8", - "reference": "2cb89664897be33f78c65d3d2845954c8d7a43b8", + "url": "https://api.github.com/repos/symfony/finder/zipball/6de263e5868b9a137602dd1e33e4d48bfae99c49", + "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49", "shasum": "" }, "require": { @@ -7780,7 +7781,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.6" + "source": "https://github.com/symfony/finder/tree/v7.2.0" }, "funding": [ { @@ -7796,20 +7797,20 @@ "type": "tidelift" } ], - "time": "2024-10-01T08:31:23+00:00" + "time": "2024-10-23T06:56:12+00:00" }, { "name": "symfony/options-resolver", - "version": "v7.1.9", + "version": "v7.2.0", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "0f4099f5306a92487d13b2a4589068c36a93c447" + "reference": "7da8fbac9dcfef75ffc212235d76b2754ce0cf50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/0f4099f5306a92487d13b2a4589068c36a93c447", - "reference": "0f4099f5306a92487d13b2a4589068c36a93c447", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/7da8fbac9dcfef75ffc212235d76b2754ce0cf50", + "reference": "7da8fbac9dcfef75ffc212235d76b2754ce0cf50", "shasum": "" }, "require": { @@ -7847,7 +7848,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v7.1.9" + "source": "https://github.com/symfony/options-resolver/tree/v7.2.0" }, "funding": [ { @@ -7863,7 +7864,7 @@ "type": "tidelift" } ], - "time": "2024-11-20T11:08:58+00:00" + "time": "2024-11-20T11:17:29+00:00" }, { "name": "symfony/polyfill-ctype", @@ -8181,16 +8182,16 @@ }, { "name": "symfony/process", - "version": "v7.1.8", + "version": "v7.2.0", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "42783370fda6e538771f7c7a36e9fa2ee3a84892" + "reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/42783370fda6e538771f7c7a36e9fa2ee3a84892", - "reference": "42783370fda6e538771f7c7a36e9fa2ee3a84892", + "url": "https://api.github.com/repos/symfony/process/zipball/d34b22ba9390ec19d2dd966c40aa9e8462f27a7e", + "reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e", "shasum": "" }, "require": { @@ -8222,7 +8223,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.1.8" + "source": "https://github.com/symfony/process/tree/v7.2.0" }, "funding": [ { @@ -8238,20 +8239,20 @@ "type": "tidelift" } ], - "time": "2024-11-06T14:23:19+00:00" + "time": "2024-11-06T14:24:19+00:00" }, { "name": "symfony/string", - "version": "v7.1.8", + "version": "v7.2.0", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "591ebd41565f356fcd8b090fe64dbb5878f50281" + "reference": "446e0d146f991dde3e73f45f2c97a9faad773c82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/591ebd41565f356fcd8b090fe64dbb5878f50281", - "reference": "591ebd41565f356fcd8b090fe64dbb5878f50281", + "url": "https://api.github.com/repos/symfony/string/zipball/446e0d146f991dde3e73f45f2c97a9faad773c82", + "reference": "446e0d146f991dde3e73f45f2c97a9faad773c82", "shasum": "" }, "require": { @@ -8309,7 +8310,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.8" + "source": "https://github.com/symfony/string/tree/v7.2.0" }, "funding": [ { @@ -8325,7 +8326,7 @@ "type": "tidelift" } ], - "time": "2024-11-13T13:31:21+00:00" + "time": "2024-11-13T13:31:26+00:00" }, { "name": "textalk/websocket", From 714c2f30d7a313326e1b4cd7a90970992da8ad35 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 5 Dec 2024 17:50:24 +1300 Subject: [PATCH 161/279] Update database --- composer.json | 2 +- composer.lock | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index d6124e8b1c..afd870b3d6 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.25", + "utopia-php/database": "0.53.27", "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 f671cc3a48..3debf3d5cc 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": "db3e97b504d4482957dafccb618d5187", + "content-hash": "cfa976b029b0e8f53ef617056d04face", "packages": [ { "name": "adhocore/jwt", @@ -709,16 +709,16 @@ }, { "name": "google/protobuf", - "version": "v4.29.0", + "version": "v4.29.1", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "0ef6b2eb74b782f3f9023276c324d22e440f7587" + "reference": "6042b5483f8029e42473faeb8ef75ba266278381" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/0ef6b2eb74b782f3f9023276c324d22e440f7587", - "reference": "0ef6b2eb74b782f3f9023276c324d22e440f7587", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/6042b5483f8029e42473faeb8ef75ba266278381", + "reference": "6042b5483f8029e42473faeb8ef75ba266278381", "shasum": "" }, "require": { @@ -747,9 +747,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.0" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.1" }, - "time": "2024-11-27T18:37:40+00:00" + "time": "2024-12-03T22:07:45+00:00" }, { "name": "jean85/pretty-package-versions", @@ -2970,10 +2970,10 @@ }, "type": "composer-plugin", "extra": { + "class": "Nevay\\SPI\\Composer\\Plugin", "branch-alias": { "dev-main": "0.2.x-dev" }, - "class": "Nevay\\SPI\\Composer\\Plugin", "plugin-optional": true }, "autoload": { @@ -3476,16 +3476,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.25", + "version": "0.53.27", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "d95bbbd4f7fb74b020b0abae7f9970d71ca52baa" + "reference": "d3a8cae6e743a6a1a5719b860762a03aabce678a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/d95bbbd4f7fb74b020b0abae7f9970d71ca52baa", - "reference": "d95bbbd4f7fb74b020b0abae7f9970d71ca52baa", + "url": "https://api.github.com/repos/utopia-php/database/zipball/d3a8cae6e743a6a1a5719b860762a03aabce678a", + "reference": "d3a8cae6e743a6a1a5719b860762a03aabce678a", "shasum": "" }, "require": { @@ -3526,9 +3526,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.25" + "source": "https://github.com/utopia-php/database/tree/0.53.27" }, - "time": "2024-12-02T05:09:19+00:00" + "time": "2024-12-02T08:53:55+00:00" }, { "name": "utopia-php/domains", @@ -8558,7 +8558,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8582,5 +8582,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } From dd6cde6ae5beb2c9037a66240b6d37e92d9eacf3 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 5 Dec 2024 21:30:26 +1300 Subject: [PATCH 162/279] Log trace --- app/controllers/general.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index f8d5b161d4..03be06ac1e 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -759,6 +759,7 @@ App::error() Console::error('[Error] Message: ' . $message); Console::error('[Error] File: ' . $file); Console::error('[Error] Line: ' . $line); + Console::error('[Error] Trace: ' . $error->getTraceAsString()); } switch ($class) { From 8e0bd8d18d90a2ce48363e4aa316125b88f737c2 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 8 Dec 2024 15:47:29 +0200 Subject: [PATCH 163/279] composer --- composer.lock | 74 +++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/composer.lock b/composer.lock index 3debf3d5cc..db5dac1b33 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": "cfa976b029b0e8f53ef617056d04face", + "content-hash": "fae350df93342992edd8f639948e1570", "packages": [ { "name": "adhocore/jwt", @@ -2565,12 +2565,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -3476,16 +3476,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.27", + "version": "0.53.200", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "d3a8cae6e743a6a1a5719b860762a03aabce678a" + "reference": "570c63a3760d0e1404679ddfacd9484af40bd9fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/d3a8cae6e743a6a1a5719b860762a03aabce678a", - "reference": "d3a8cae6e743a6a1a5719b860762a03aabce678a", + "url": "https://api.github.com/repos/utopia-php/database/zipball/570c63a3760d0e1404679ddfacd9484af40bd9fc", + "reference": "570c63a3760d0e1404679ddfacd9484af40bd9fc", "shasum": "" }, "require": { @@ -3526,9 +3526,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.27" + "source": "https://github.com/utopia-php/database/tree/0.53.200" }, - "time": "2024-12-02T08:53:55+00:00" + "time": "2024-12-01T07:59:15+00:00" }, { "name": "utopia-php/domains", @@ -4363,16 +4363,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.7", + "version": "0.18.8", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "0d9228faa1c202f9e01483e45a8950485f01a288" + "reference": "84737afa634e6a833fc4f8b0c967553234d3f215" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/0d9228faa1c202f9e01483e45a8950485f01a288", - "reference": "0d9228faa1c202f9e01483e45a8950485f01a288", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/84737afa634e6a833fc4f8b0c967553234d3f215", + "reference": "84737afa634e6a833fc4f8b0c967553234d3f215", "shasum": "" }, "require": { @@ -4412,9 +4412,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.7" + "source": "https://github.com/utopia-php/storage/tree/0.18.8" }, - "time": "2024-11-28T11:10:53+00:00" + "time": "2024-12-04T08:30:35+00:00" }, { "name": "utopia-php/swoole", @@ -4934,29 +4934,27 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", - "phpstan/phpstan": "1.4.10 || 1.10.15", - "phpstan/phpstan-phpunit": "^1.0", + "doctrine/coding-standard": "^9 || ^12", + "phpstan/phpstan": "1.4.10 || 2.0.3", + "phpstan/phpstan-phpunit": "^1.0 || ^2", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psalm/plugin-phpunit": "0.18.4", - "psr/log": "^1 || ^2 || ^3", - "vimeo/psalm": "4.30.0 || 5.12.0" + "psr/log": "^1 || ^2 || ^3" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" @@ -4964,7 +4962,7 @@ "type": "library", "autoload": { "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + "Doctrine\\Deprecations\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -4975,9 +4973,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.3" + "source": "https://github.com/doctrine/deprecations/tree/1.1.4" }, - "time": "2024-01-30T19:34:25+00:00" + "time": "2024-12-07T21:18:45+00:00" }, { "name": "doctrine/instantiator", @@ -5809,16 +5807,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.6.0", + "version": "5.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c" + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/f3558a4c23426d12bffeaab463f8a8d8b681193c", - "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", "shasum": "" }, "require": { @@ -5867,9 +5865,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.6.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1" }, - "time": "2024-11-12T11:25:25+00:00" + "time": "2024-12-07T09:39:29+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -8558,7 +8556,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8582,5 +8580,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } From c9e6bfbdb38d17f0895158fbc9b507914980a89e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 9 Dec 2024 16:48:41 +1300 Subject: [PATCH 164/279] Update database --- composer.json | 2 +- composer.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 512e203a5e..afd870b3d6 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.200", + "utopia-php/database": "0.53.27", "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 db5dac1b33..4c761dfd91 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": "fae350df93342992edd8f639948e1570", + "content-hash": "cfa976b029b0e8f53ef617056d04face", "packages": [ { "name": "adhocore/jwt", @@ -3476,16 +3476,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.200", + "version": "0.53.27", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "570c63a3760d0e1404679ddfacd9484af40bd9fc" + "reference": "d3a8cae6e743a6a1a5719b860762a03aabce678a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/570c63a3760d0e1404679ddfacd9484af40bd9fc", - "reference": "570c63a3760d0e1404679ddfacd9484af40bd9fc", + "url": "https://api.github.com/repos/utopia-php/database/zipball/d3a8cae6e743a6a1a5719b860762a03aabce678a", + "reference": "d3a8cae6e743a6a1a5719b860762a03aabce678a", "shasum": "" }, "require": { @@ -3526,9 +3526,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.200" + "source": "https://github.com/utopia-php/database/tree/0.53.27" }, - "time": "2024-12-01T07:59:15+00:00" + "time": "2024-12-02T08:53:55+00:00" }, { "name": "utopia-php/domains", @@ -8556,7 +8556,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8580,5 +8580,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } From 8f390a70c73853d7ad583211dbed29f574506d49 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Dec 2024 18:54:58 +1300 Subject: [PATCH 165/279] Fix self-hosted region check default --- app/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/init.php b/app/init.php index 058cf82833..47186bfc86 100644 --- a/app/init.php +++ b/app/init.php @@ -1334,7 +1334,7 @@ App::setResource('project', function ($dbForConsole, $request, $console) { $project = Authorization::skip(fn () => $dbForConsole->getDocument('projects', $projectId)); - if ($project->getAttribute('region') !== System::getEnv('_APP_REGION')) { + if ($project->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { var_dump(System::getEnv('_APP_REGION')); var_dump($project->getAttribute('region')); throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, 'Project is not accessible in this region. Please make sure you are using the correct endpoint'); From f4637e1b7dc12a80cdf5599e21ea9108c6d5b78c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Dec 2024 18:55:25 +1300 Subject: [PATCH 166/279] Create audit/abuse for V2 --- app/controllers/api/projects.php | 3 --- app/http.php | 10 ++++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 9a6bd0d799..66a6fb812f 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -128,7 +128,6 @@ App::post('/v1/projects') $databases = Config::getParam('pools-database', []); - if ($region !== 'default') { $databaseKeys = System::getEnv('_APP_DATABASE_KEYS', ''); $keys = explode(',', $databaseKeys); @@ -235,8 +234,6 @@ App::post('/v1/projects') $create = false; } - - if ($create || $projectTables) { $audit = new Audit($dbForProject); $audit->setup(); diff --git a/app/http.php b/app/http.php index aaa8dfca0e..b99a6cfad3 100644 --- a/app/http.php +++ b/app/http.php @@ -292,6 +292,16 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg Console::success('[Setup] - Skip: metadata table already exists'); } + if ($dbForProject->getCollection(Audit::COLLECTION)->isEmpty()) { + $audit = new Audit($dbForProject); + $audit->setup(); + } + + if ($dbForProject->getCollection(TimeLimit::COLLECTION)->isEmpty()) { + $adapter = new TimeLimit("", 0, 1, $dbForProject); + $adapter->setup(); + } + foreach ($projectCollections as $key => $collection) { if (($collection['$collection'] ?? '') !== Database::METADATA) { continue; From 9a89cc1332d9e329a9ad1f812b836a20cb921da5 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Dec 2024 19:06:35 +1300 Subject: [PATCH 167/279] Remove logs --- app/controllers/api/databases.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 33b37bb1b6..aad072c50a 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -2895,11 +2895,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents') } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getInternalId(), $collectionId)); - var_dump('database_' . $database->getInternalId()); - var_dump($collectionId); - var_dump($collection); - var_dump($isAPIKey); - var_dump($isPrivilegedUser); + if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::COLLECTION_NOT_FOUND); } From 39e4a046256acd7f077e110150a29f7d66624480 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Dec 2024 20:31:50 +1300 Subject: [PATCH 168/279] Fix default region --- app/http.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/http.php b/app/http.php index b99a6cfad3..839272bd31 100644 --- a/app/http.php +++ b/app/http.php @@ -265,7 +265,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); $sharedTablesV2 = \array_diff($sharedTables, $sharedTablesV1); - $region = System::getEnv('_APP_REGION', 'fra'); + $region = System::getEnv('_APP_REGION', 'default'); $cache = $app->getResource('cache'); $regionDatabases = \array_filter( @@ -292,12 +292,16 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg Console::success('[Setup] - Skip: metadata table already exists'); } + Console::info('Checking audit collection'); if ($dbForProject->getCollection(Audit::COLLECTION)->isEmpty()) { + Console::info('Creating audit collection'); $audit = new Audit($dbForProject); $audit->setup(); } + Console::info('Checking abuse collection'); if ($dbForProject->getCollection(TimeLimit::COLLECTION)->isEmpty()) { + Console::info('Creating abuse collection'); $adapter = new TimeLimit("", 0, 1, $dbForProject); $adapter->setup(); } From 54d1ef257d1b931c7160883aa10c08df2161baf2 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Dec 2024 21:01:26 +1300 Subject: [PATCH 169/279] Remove logs --- app/http.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/http.php b/app/http.php index 839272bd31..b14e653c44 100644 --- a/app/http.php +++ b/app/http.php @@ -292,16 +292,12 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg Console::success('[Setup] - Skip: metadata table already exists'); } - Console::info('Checking audit collection'); if ($dbForProject->getCollection(Audit::COLLECTION)->isEmpty()) { - Console::info('Creating audit collection'); $audit = new Audit($dbForProject); $audit->setup(); } - Console::info('Checking abuse collection'); if ($dbForProject->getCollection(TimeLimit::COLLECTION)->isEmpty()) { - Console::info('Creating abuse collection'); $adapter = new TimeLimit("", 0, 1, $dbForProject); $adapter->setup(); } From 06b69360f47f4ab3bf0805c6d9038cf9ffb8c93a Mon Sep 17 00:00:00 2001 From: shimon Date: Sat, 14 Dec 2024 20:23:07 +0200 Subject: [PATCH 170/279] sync with 1.6.x --- app/controllers/api/messaging.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 92c0f47edc..83b17e86ec 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2742,7 +2742,7 @@ App::post('/v1/messaging/messages/email') ->setMessageId($message->getId()); break; case MessageStatus::SCHEDULED: - $schedule = $dbForConsole->createDocument('schedules', new Document([ + $schedule = $dbForPlatform->createDocument('schedules', new Document([ 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), @@ -2859,8 +2859,8 @@ App::post('/v1/messaging/messages/sms') ->setMessageId($message->getId()); break; case MessageStatus::SCHEDULED: - $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => $project->getAttribute('region'),, + $schedule = $dbForPlatform->createDocument('schedules', new Document([ + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), From 3159e5de0c1dbca79eeb1ffeb1861a33a6ae55a4 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 24 Dec 2024 18:22:17 +0200 Subject: [PATCH 171/279] project usage updates --- app/controllers/api/project.php | 7 ++++++- app/init.php | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/project.php b/app/controllers/api/project.php index 45c8f2c32b..0e549e951c 100644 --- a/app/controllers/api/project.php +++ b/app/controllers/api/project.php @@ -49,7 +49,10 @@ App::get('/v1/project/usage') METRIC_FILES_STORAGE, METRIC_DATABASES_STORAGE, METRIC_DEPLOYMENTS_STORAGE, - METRIC_BUILDS_STORAGE + METRIC_BUILDS_STORAGE, + METRIC_BACKUPS_STORAGE, + METRIC_NETWORK_INBOUND, + METRIC_NETWORK_OUTBOUND, ], 'period' => [ METRIC_NETWORK_REQUESTS, @@ -289,12 +292,14 @@ App::get('/v1/project/usage') 'documentsTotal' => $total[METRIC_DOCUMENTS], 'databasesTotal' => $total[METRIC_DATABASES], 'databasesStorageTotal' => $total[METRIC_DATABASES_STORAGE], + 'backupsStorageTotal' => $total[METRIC_BACKUPS_STORAGE], 'usersTotal' => $total[METRIC_USERS], 'bucketsTotal' => $total[METRIC_BUCKETS], 'filesStorageTotal' => $total[METRIC_FILES_STORAGE], 'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE], 'buildsStorageTotal' => $total[METRIC_BUILDS_STORAGE], 'deploymentsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE], + 'networkTotal' => $total[METRIC_NETWORK_INBOUND]+$total[METRIC_NETWORK_OUTBOUND], 'executionsBreakdown' => $executionsBreakdown, 'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown, 'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown, diff --git a/app/init.php b/app/init.php index ace69303e3..1065014d1e 100644 --- a/app/init.php +++ b/app/init.php @@ -259,6 +259,7 @@ const METRIC_DOCUMENTS = 'documents'; const METRIC_DATABASE_ID_DOCUMENTS = '{databaseInternalId}.documents'; const METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS = '{databaseInternalId}.{collectionInternalId}.documents'; const METRIC_DATABASE_ID_COLLECTION_ID_STORAGE = '{databaseInternalId}.{collectionInternalId}.databases.storage'; +const METRIC_BACKUPS_STORAGE = 'backups.storage'; const METRIC_BUCKETS = 'buckets'; const METRIC_FILES = 'files'; const METRIC_FILES_STORAGE = 'files.storage'; From 0e0009dd2716e4a0c2f9646e618233e41cea601a Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 24 Dec 2024 18:52:33 +0200 Subject: [PATCH 172/279] composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 87c9cf808d..2879993d3f 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.27", + "utopia-php/database": "0.53.200", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", From a7d09118e4dac0563011d2b9bcf6567ed939cfb2 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 24 Dec 2024 18:53:28 +0200 Subject: [PATCH 173/279] composer --- composer.lock | 118 +++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/composer.lock b/composer.lock index 6cab92d581..63a7559b37 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": "cfa976b029b0e8f53ef617056d04face", + "content-hash": "db3b63ba1be2561ee4a112e5b9c6bd53", "packages": [ { "name": "adhocore/jwt", @@ -709,16 +709,16 @@ }, { "name": "google/protobuf", - "version": "v4.29.1", + "version": "v4.29.2", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "6042b5483f8029e42473faeb8ef75ba266278381" + "reference": "79aa5014efeeec3d137df5cdb0ae2fc163953945" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/6042b5483f8029e42473faeb8ef75ba266278381", - "reference": "6042b5483f8029e42473faeb8ef75ba266278381", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/79aa5014efeeec3d137df5cdb0ae2fc163953945", + "reference": "79aa5014efeeec3d137df5cdb0ae2fc163953945", "shasum": "" }, "require": { @@ -747,9 +747,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.1" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.2" }, - "time": "2024-12-03T22:07:45+00:00" + "time": "2024-12-18T14:11:12+00:00" }, { "name": "jean85/pretty-package-versions", @@ -1237,16 +1237,16 @@ }, { "name": "open-telemetry/api", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/api.git", - "reference": "542064815d38a6df55af7957cd6f1d7d967c99c6" + "reference": "04c85a1e41a3d59fa9bdc801a5de1df6624b95ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/542064815d38a6df55af7957cd6f1d7d967c99c6", - "reference": "542064815d38a6df55af7957cd6f1d7d967c99c6", + "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/04c85a1e41a3d59fa9bdc801a5de1df6624b95ed", + "reference": "04c85a1e41a3d59fa9bdc801a5de1df6624b95ed", "shasum": "" }, "require": { @@ -1260,13 +1260,13 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.1.x-dev" - }, "spi": { "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\HookManagerInterface": [ "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\ExtensionHookManager" ] + }, + "branch-alias": { + "dev-main": "1.1.x-dev" } }, "autoload": { @@ -1303,7 +1303,7 @@ "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" + "time": "2024-11-16T04:32:30+00:00" }, { "name": "open-telemetry/context", @@ -1530,13 +1530,13 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.0.x-dev" - }, "spi": { "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\HookManagerInterface": [ "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\ExtensionHookManager" ] + }, + "branch-alias": { + "dev-main": "1.0.x-dev" } }, "autoload": { @@ -2453,23 +2453,23 @@ }, { "name": "symfony/http-client", - "version": "v7.2.0", + "version": "v7.2.1", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "955e43336aff03df1e8a8e17daefabb0127a313b" + "reference": "ff4df2b68d1c67abb9fef146e6540ea16b58d99e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/955e43336aff03df1e8a8e17daefabb0127a313b", - "reference": "955e43336aff03df1e8a8e17daefabb0127a313b", + "url": "https://api.github.com/repos/symfony/http-client/zipball/ff4df2b68d1c67abb9fef146e6540ea16b58d99e", + "reference": "ff4df2b68d1c67abb9fef146e6540ea16b58d99e", "shasum": "" }, "require": { "php": ">=8.2", "psr/log": "^1|^2|^3", "symfony/deprecation-contracts": "^2.5|^3", - "symfony/http-client-contracts": "~3.4.3|^3.5.1", + "symfony/http-client-contracts": "~3.4.4|^3.5.2", "symfony/service-contracts": "^2.5|^3" }, "conflict": { @@ -2528,7 +2528,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.2.0" + "source": "https://github.com/symfony/http-client/tree/v7.2.1" }, "funding": [ { @@ -2544,20 +2544,20 @@ "type": "tidelift" } ], - "time": "2024-11-29T08:22:02+00:00" + "time": "2024-12-07T08:50:44+00:00" }, { "name": "symfony/http-client-contracts", - "version": "v3.5.1", + "version": "v3.5.2", "source": { "type": "git", "url": "https://github.com/symfony/http-client-contracts.git", - "reference": "c2f3ad828596624ca39ea40f83617ef51ca8bbf9" + "reference": "ee8d807ab20fcb51267fdace50fbe3494c31e645" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/c2f3ad828596624ca39ea40f83617ef51ca8bbf9", - "reference": "c2f3ad828596624ca39ea40f83617ef51ca8bbf9", + "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/ee8d807ab20fcb51267fdace50fbe3494c31e645", + "reference": "ee8d807ab20fcb51267fdace50fbe3494c31e645", "shasum": "" }, "require": { @@ -2606,7 +2606,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/http-client-contracts/tree/v3.5.1" + "source": "https://github.com/symfony/http-client-contracts/tree/v3.5.2" }, "funding": [ { @@ -2622,7 +2622,7 @@ "type": "tidelift" } ], - "time": "2024-11-25T12:02:18+00:00" + "time": "2024-12-07T08:49:48+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2650,8 +2650,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -3136,16 +3136,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.43.2", + "version": "0.45.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "374536b86d8d39066960a7da161d444a099bbc56" + "reference": "54a58355df1eb26c9be7834738debe6754e5581d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/374536b86d8d39066960a7da161d444a099bbc56", - "reference": "374536b86d8d39066960a7da161d444a099bbc56", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/54a58355df1eb26c9be7834738debe6754e5581d", + "reference": "54a58355df1eb26c9be7834738debe6754e5581d", "shasum": "" }, "require": { @@ -3181,9 +3181,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.43.2" + "source": "https://github.com/utopia-php/abuse/tree/0.45.0" }, - "time": "2024-12-12T19:43:24+00:00" + "time": "2024-12-20T16:18:52+00:00" }, { "name": "utopia-php/analytics", @@ -3476,16 +3476,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.27", + "version": "0.53.200", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "d3a8cae6e743a6a1a5719b860762a03aabce678a" + "reference": "570c63a3760d0e1404679ddfacd9484af40bd9fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/d3a8cae6e743a6a1a5719b860762a03aabce678a", - "reference": "d3a8cae6e743a6a1a5719b860762a03aabce678a", + "url": "https://api.github.com/repos/utopia-php/database/zipball/570c63a3760d0e1404679ddfacd9484af40bd9fc", + "reference": "570c63a3760d0e1404679ddfacd9484af40bd9fc", "shasum": "" }, "require": { @@ -3526,9 +3526,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.27" + "source": "https://github.com/utopia-php/database/tree/0.53.200" }, - "time": "2024-12-02T08:53:55+00:00" + "time": "2024-12-01T07:59:15+00:00" }, { "name": "utopia-php/domains", @@ -4807,16 +4807,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.25", + "version": "0.39.27", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "5b5323636a8d75a1c4faaae9728098dd6a6a47d1" + "reference": "27d8ecde30e40cbfe1124cc0430c406d3e144849" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/5b5323636a8d75a1c4faaae9728098dd6a6a47d1", - "reference": "5b5323636a8d75a1c4faaae9728098dd6a6a47d1", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/27d8ecde30e40cbfe1124cc0430c406d3e144849", + "reference": "27d8ecde30e40cbfe1124cc0430c406d3e144849", "shasum": "" }, "require": { @@ -4852,9 +4852,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.25" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.27" }, - "time": "2024-11-08T10:16:34+00:00" + "time": "2024-12-16T11:32:02+00:00" }, { "name": "doctrine/annotations", @@ -7576,16 +7576,16 @@ }, { "name": "symfony/console", - "version": "v7.2.0", + "version": "v7.2.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf" + "reference": "fefcc18c0f5d0efe3ab3152f15857298868dc2c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/23c8aae6d764e2bae02d2a99f7532a7f6ed619cf", - "reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf", + "url": "https://api.github.com/repos/symfony/console/zipball/fefcc18c0f5d0efe3ab3152f15857298868dc2c3", + "reference": "fefcc18c0f5d0efe3ab3152f15857298868dc2c3", "shasum": "" }, "require": { @@ -7649,7 +7649,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.2.0" + "source": "https://github.com/symfony/console/tree/v7.2.1" }, "funding": [ { @@ -7665,7 +7665,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T14:24:19+00:00" + "time": "2024-12-11T03:49:26+00:00" }, { "name": "symfony/filesystem", @@ -8556,7 +8556,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8580,5 +8580,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } From 33a8da45bd3fd57cd95752b219859e1a705e2b17 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 25 Dec 2024 12:34:02 +0200 Subject: [PATCH 174/279] rollback project usage changes --- app/controllers/api/project.php | 7 +------ app/init.php | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/controllers/api/project.php b/app/controllers/api/project.php index 0e549e951c..45c8f2c32b 100644 --- a/app/controllers/api/project.php +++ b/app/controllers/api/project.php @@ -49,10 +49,7 @@ App::get('/v1/project/usage') METRIC_FILES_STORAGE, METRIC_DATABASES_STORAGE, METRIC_DEPLOYMENTS_STORAGE, - METRIC_BUILDS_STORAGE, - METRIC_BACKUPS_STORAGE, - METRIC_NETWORK_INBOUND, - METRIC_NETWORK_OUTBOUND, + METRIC_BUILDS_STORAGE ], 'period' => [ METRIC_NETWORK_REQUESTS, @@ -292,14 +289,12 @@ App::get('/v1/project/usage') 'documentsTotal' => $total[METRIC_DOCUMENTS], 'databasesTotal' => $total[METRIC_DATABASES], 'databasesStorageTotal' => $total[METRIC_DATABASES_STORAGE], - 'backupsStorageTotal' => $total[METRIC_BACKUPS_STORAGE], 'usersTotal' => $total[METRIC_USERS], 'bucketsTotal' => $total[METRIC_BUCKETS], 'filesStorageTotal' => $total[METRIC_FILES_STORAGE], 'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE], 'buildsStorageTotal' => $total[METRIC_BUILDS_STORAGE], 'deploymentsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE], - 'networkTotal' => $total[METRIC_NETWORK_INBOUND]+$total[METRIC_NETWORK_OUTBOUND], 'executionsBreakdown' => $executionsBreakdown, 'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown, 'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown, diff --git a/app/init.php b/app/init.php index 1065014d1e..ace69303e3 100644 --- a/app/init.php +++ b/app/init.php @@ -259,7 +259,6 @@ const METRIC_DOCUMENTS = 'documents'; const METRIC_DATABASE_ID_DOCUMENTS = '{databaseInternalId}.documents'; const METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS = '{databaseInternalId}.{collectionInternalId}.documents'; const METRIC_DATABASE_ID_COLLECTION_ID_STORAGE = '{databaseInternalId}.{collectionInternalId}.databases.storage'; -const METRIC_BACKUPS_STORAGE = 'backups.storage'; const METRIC_BUCKETS = 'buckets'; const METRIC_FILES = 'files'; const METRIC_FILES_STORAGE = 'files.storage'; From 18f17ff9fb4b11d87ce770cc630d20107329a5bb Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 8 Jan 2025 15:54:31 +0200 Subject: [PATCH 175/279] remove abuse from deletes worker --- src/Appwrite/Platform/Workers/Deletes.php | 31 +++-------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index f29b79e5db..9aaf19f412 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -7,7 +7,6 @@ use Appwrite\Certificates\Adapter as CertificatesAdapter; use Appwrite\Extend\Exception; use Executor\Executor; use Throwable; -use Utopia\Abuse\Abuse; use Utopia\Audit\Audit; use Utopia\Cache\Adapter\Filesystem; use Utopia\Cache\Cache; @@ -52,13 +51,12 @@ class Deletes extends Action ->inject('deviceForBuilds') ->inject('deviceForCache') ->inject('certificates') - ->inject('abuseRetention') ->inject('executionRetention') ->inject('auditRetention') ->inject('log') ->callback( - fn ($message, $dbForPlatform, callable $getProjectDB, callable $timelimit, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, int $abuseRetention, string $executionRetention, string $auditRetention, Log $log) => - $this->action($message, $dbForPlatform, $getProjectDB, $timelimit, $deviceForFiles, $deviceForFunctions, $deviceForBuilds, $deviceForCache, $certificates, $abuseRetention, $executionRetention, $auditRetention, $log) + fn ($message, $dbForPlatform, callable $getProjectDB, callable $timelimit, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log) => + $this->action($message, $dbForPlatform, $getProjectDB, $timelimit, $deviceForFiles, $deviceForFunctions, $deviceForBuilds, $deviceForCache, $certificates, $executionRetention, $auditRetention, $log) ); } @@ -66,7 +64,7 @@ class Deletes extends Action * @throws Exception * @throws Throwable */ - public function action(Message $message, Database $dbForPlatform, callable $getProjectDB, callable $timelimit, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, int $abuseRetention, string $executionRetention, string $auditRetention, Log $log): void + public function action(Message $message, Database $dbForPlatform, callable $getProjectDB, callable $timelimit, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log): void { $payload = $message->getPayload() ?? []; @@ -125,9 +123,6 @@ class Deletes extends Action $this->deleteAuditLogs($project, $getProjectDB, $auditRetention); } break; - case DELETE_TYPE_ABUSE: - $this->deleteAbuseLogs($project, $timelimit, $abuseRetention); - break; case DELETE_TYPE_REALTIME: $this->deleteRealtimeUsage($dbForPlatform, $datetime); break; @@ -700,26 +695,6 @@ class Deletes extends Action ], $dbForPlatform); } - /** - * @param Database $dbForPlatform - * @param callable $getProjectDB - * @param int $abuseRetention - * @return void - * @throws Exception - */ - private function deleteAbuseLogs(Document $project, callable $timelimit, int $abuseRetention): void - { - $projectId = $project->getId(); - $timeLimit = $timelimit("", 0, 1); - $abuse = new Abuse($timeLimit); - - try { - $abuse->cleanup($abuseRetention); - } catch (DatabaseException $e) { - Console::error('Failed to delete abuse logs for project ' . $projectId . ': ' . $e->getMessage()); - } - } - /** * @param Database $dbForPlatform * @param callable $getProjectDB From 246c334127d3edcf5dad458e0e13892749b8e154 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 13 Jan 2025 21:05:19 +0200 Subject: [PATCH 176/279] debug region validation --- app/init.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/init.php b/app/init.php index efe797175a..22c96ec4fc 100644 --- a/app/init.php +++ b/app/init.php @@ -1348,8 +1348,12 @@ App::setResource('project', function ($dbForPlatform, $request, $console) { $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); if ($project->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { - var_dump(System::getEnv('_APP_REGION')); - var_dump($project->getAttribute('region')); + var_dump([ + 'projectId' => $project->getId(), + 'projectRegion' => $project->getAttribute('region'), + '_APP_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'); } From 348199712a8ba4933fe6e0d91bd0aad639ba372e Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 16 Jan 2025 15:10:07 +0200 Subject: [PATCH 177/279] composer.lock --- composer.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/composer.lock b/composer.lock index 3c8f4d3de0..233761419e 100644 --- a/composer.lock +++ b/composer.lock @@ -1430,16 +1430,16 @@ }, { "name": "open-telemetry/gen-otlp-protobuf", - "version": "1.2.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/gen-otlp-protobuf.git", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d" + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/66c3b98e998a726691c92e6405a82e6e7b8b169d", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d", + "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/585bafddd4ae6565de154610b10a787a455c9ba0", + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0", "shasum": "" }, "require": { @@ -1489,7 +1489,7 @@ "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" + "time": "2025-01-15T23:07:07+00:00" }, { "name": "open-telemetry/sdk", @@ -3379,16 +3379,16 @@ }, { "name": "utopia-php/compression", - "version": "0.1.2", + "version": "0.1.3", "source": { "type": "git", "url": "https://github.com/utopia-php/compression.git", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98" + "reference": "66f093557ba66d98245e562036182016c7dcfe8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/compression/zipball/6062f70596415f8d5de40a589367b0eb2a435f98", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98", + "url": "https://api.github.com/repos/utopia-php/compression/zipball/66f093557ba66d98245e562036182016c7dcfe8a", + "reference": "66f093557ba66d98245e562036182016c7dcfe8a", "shasum": "" }, "require": { @@ -3419,9 +3419,9 @@ ], "support": { "issues": "https://github.com/utopia-php/compression/issues", - "source": "https://github.com/utopia-php/compression/tree/0.1.2" + "source": "https://github.com/utopia-php/compression/tree/0.1.3" }, - "time": "2024-11-08T14:59:54+00:00" + "time": "2025-01-15T15:15:51+00:00" }, { "name": "utopia-php/config", From 286f7e6b86830f66f3d1bab255333faea30d7c31 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 19 Jan 2025 11:22:22 +0200 Subject: [PATCH 178/279] added attr installations collection --- app/config/collections/platform.php | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/app/config/collections/platform.php b/app/config/collections/platform.php index a5fedb6461..8a46bfd3ec 100644 --- a/app/config/collections/platform.php +++ b/app/config/collections/platform.php @@ -1185,6 +1185,39 @@ return [ 'default' => false, 'array' => false, ], + [ + '$id' => ID::custom('personalAccessToken'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['encrypt'], + ], + [ + '$id' => ID::custom('personalAccessTokenExpiry'), + 'type' => Database::VAR_DATETIME, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['datetime'], + ], + [ + '$id' => ID::custom('personalRefreshToken'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['encrypt'], + ], ], 'indexes' => [ From 561af1d386b34be97cb237399109456c3d7fc7e3 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 19 Jan 2025 21:03:48 +0200 Subject: [PATCH 179/279] debug --- app/init.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/init.php b/app/init.php index 2c827779d5..08a5ea3582 100644 --- a/app/init.php +++ b/app/init.php @@ -1262,6 +1262,12 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons ) ); + var_dump([ + 'no' => '1', + 'cookie_name' => Auth::setCookieName, + 'session' => $session + ]); + // Get session from header for SSR clients if (empty($session['id']) && empty($session['secret'])) { $sessionHeader = $request->getHeader('x-appwrite-session', ''); @@ -1275,6 +1281,12 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons if ($response) { $response->addHeader('X-Debug-Fallback', 'false'); } + var_dump([ + 'no' => '2', + 'mode' => $mode, + 'secret' => $session['secret'], + 'id' => $session['id'] + ]); if (empty($session['id']) && empty($session['secret'])) { if ($response) { From 6e1675c574b2e826b25f7f69828d569b537148bd Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 19 Jan 2025 22:10:52 +0200 Subject: [PATCH 180/279] debug --- app/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/init.php b/app/init.php index 08a5ea3582..22f17e6c43 100644 --- a/app/init.php +++ b/app/init.php @@ -1264,7 +1264,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons var_dump([ 'no' => '1', - 'cookie_name' => Auth::setCookieName, + 'cookie_name' => Auth::$setCookieName, 'session' => $session ]); From 419d18bb1c676f1f27b8894c1f49a3bf766fca9a Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 19 Jan 2025 22:25:03 +0200 Subject: [PATCH 181/279] debug --- app/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/init.php b/app/init.php index 22f17e6c43..63b4658305 100644 --- a/app/init.php +++ b/app/init.php @@ -1264,7 +1264,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons var_dump([ 'no' => '1', - 'cookie_name' => Auth::$setCookieName, + 'cookie_name' => Auth::$cookieName, 'session' => $session ]); From bad427071e6890345e2d4a66b7002a675b678e4c Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 19 Jan 2025 22:41:00 +0200 Subject: [PATCH 182/279] debug --- app/init.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/init.php b/app/init.php index 63b4658305..216926ab8e 100644 --- a/app/init.php +++ b/app/init.php @@ -1312,6 +1312,10 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons } } else { $user = $dbForPlatform->getDocument('users', Auth::$unique); + var_dump([ + 'no' => '3', + 'secret' => $user, + ]); } if ( From 3c152b8349579e589d2c60f020eddf570afa5874 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 09:25:15 +0200 Subject: [PATCH 183/279] debug --- app/controllers/shared/api.php | 5 +++++ app/init.php | 21 ++++----------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 09cb311ecb..b1a4bc5f39 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -334,6 +334,11 @@ App::init() $scopes = \array_unique($scopes); Authorization::setRole($role); + var_dump([ + 'file' => 'api.php', + '$user' => $user, + 'roles' => Auth::getRoles($user), + ]); foreach (Auth::getRoles($user) as $authRole) { Authorization::setRole($authRole); } diff --git a/app/init.php b/app/init.php index 216926ab8e..f682dacec5 100644 --- a/app/init.php +++ b/app/init.php @@ -1262,12 +1262,6 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons ) ); - var_dump([ - 'no' => '1', - 'cookie_name' => Auth::$cookieName, - 'session' => $session - ]); - // Get session from header for SSR clients if (empty($session['id']) && empty($session['secret'])) { $sessionHeader = $request->getHeader('x-appwrite-session', ''); @@ -1281,12 +1275,6 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons if ($response) { $response->addHeader('X-Debug-Fallback', 'false'); } - var_dump([ - 'no' => '2', - 'mode' => $mode, - 'secret' => $session['secret'], - 'id' => $session['id'] - ]); if (empty($session['id']) && empty($session['secret'])) { if ($response) { @@ -1312,10 +1300,6 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons } } else { $user = $dbForPlatform->getDocument('users', Auth::$unique); - var_dump([ - 'no' => '3', - 'secret' => $user, - ]); } if ( @@ -1359,7 +1343,10 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons $dbForProject->setMetadata('user', $user->getId()); $dbForPlatform->setMetadata('user', $user->getId()); - + var_dump([ + 'file' => 'init.php', + '$user' => $user, + ]); return $user; }, ['mode', 'project', 'console', 'request', 'response', 'dbForProject', 'dbForPlatform']); From b2f920d983a1ba706ef9afb6e41a10992fdde4b9 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 10:03:54 +0200 Subject: [PATCH 184/279] debug --- app/controllers/shared/api.php | 5 ----- app/init.php | 9 ++++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index b1a4bc5f39..09cb311ecb 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -334,11 +334,6 @@ App::init() $scopes = \array_unique($scopes); Authorization::setRole($role); - var_dump([ - 'file' => 'api.php', - '$user' => $user, - 'roles' => Auth::getRoles($user), - ]); foreach (Auth::getRoles($user) as $authRole) { Authorization::setRole($authRole); } diff --git a/app/init.php b/app/init.php index f682dacec5..ee64262d73 100644 --- a/app/init.php +++ b/app/init.php @@ -1308,7 +1308,11 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons ) { // Validate user has valid login token $user = new Document([]); } - + var_dump([ + 'number' => 1, + 'file' => 'init.php', + '$user' => $user, + ]); // if (APP_MODE_ADMIN === $mode) { // if ($user->find('teamInternalId', $project->getAttribute('teamInternalId'), 'memberships')) { // Authorization::setDefaultStatus(false); // Cancel security segmentation for admin users. @@ -1343,10 +1347,13 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons $dbForProject->setMetadata('user', $user->getId()); $dbForPlatform->setMetadata('user', $user->getId()); + var_dump([ + 'number' => 2, 'file' => 'init.php', '$user' => $user, ]); + return $user; }, ['mode', 'project', 'console', 'request', 'response', 'dbForProject', 'dbForPlatform']); From 645fbd4f1ce71df68ec314a32aa464ee8b09ffea Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 10:33:06 +0200 Subject: [PATCH 185/279] debug --- app/init.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/init.php b/app/init.php index ee64262d73..52a4ec2fb6 100644 --- a/app/init.php +++ b/app/init.php @@ -1301,6 +1301,14 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons } else { $user = $dbForPlatform->getDocument('users', Auth::$unique); } + var_dump([ + 'number' => 1, + 'file' => 'init.php', + '$user' => $user, + 'Auth::$secret' => Auth::$secret, + 'sessions' => $user->getAttribute('sessions', []), + 'Auth::sessionVerify' => Auth::sessionVerify($user->getAttribute('sessions', []), Auth::$secret) + ]); if ( $user->isEmpty() // Check a document has been found in the DB @@ -1308,8 +1316,9 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons ) { // Validate user has valid login token $user = new Document([]); } + var_dump([ - 'number' => 1, + 'number' => 2, 'file' => 'init.php', '$user' => $user, ]); @@ -1349,7 +1358,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons $dbForPlatform->setMetadata('user', $user->getId()); var_dump([ - 'number' => 2, + 'number' => 3, 'file' => 'init.php', '$user' => $user, ]); From 5fa4a1232fa7b5db28398f71399081da9e2b4c7d Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 11:32:54 +0200 Subject: [PATCH 186/279] debug --- app/init.php | 6 ------ src/Appwrite/Auth/Auth.php | 10 ++++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/init.php b/app/init.php index 52a4ec2fb6..c9ff034ec6 100644 --- a/app/init.php +++ b/app/init.php @@ -1357,12 +1357,6 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons $dbForProject->setMetadata('user', $user->getId()); $dbForPlatform->setMetadata('user', $user->getId()); - var_dump([ - 'number' => 3, - 'file' => 'init.php', - '$user' => $user, - ]); - return $user; }, ['mode', 'project', 'console', 'request', 'response', 'dbForProject', 'dbForPlatform']); diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index 1e8109622e..d5f90f3245 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -385,6 +385,16 @@ class Auth */ public static function sessionVerify(array $sessions, string $secret) { + + var_dump([ + 'secret' => $session->getAttribute('secret'), + 'provider' => $session->getAttribute('provider'), + 'expire' => $session->getAttribute('expire'), + 'hashed' => self::hash($secret), + 'secret_validation' => $session->getAttribute('secret') === self::hash($secret), + 'expiration_validation' => DateTime::formatTz(DateTime::format(new \DateTime($session->getAttribute('expire')))) >= DateTime::formatTz(DateTime::now()), + ]); + foreach ($sessions as $session) { if ( $session->isSet('secret') && From 0c3753097422651cfbaab00a69ab9a877ae0e550 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 11:34:25 +0200 Subject: [PATCH 187/279] debug --- app/init.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/init.php b/app/init.php index c9ff034ec6..018140814c 100644 --- a/app/init.php +++ b/app/init.php @@ -1317,6 +1317,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons $user = new Document([]); } + var_dump([ 'number' => 2, 'file' => 'init.php', From dbec8c01a967c60edbcbfe4bfc8db95cb99d1b57 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 11:47:47 +0200 Subject: [PATCH 188/279] debug --- src/Appwrite/Auth/Auth.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index d5f90f3245..72659dd6c5 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -386,16 +386,20 @@ class Auth public static function sessionVerify(array $sessions, string $secret) { - var_dump([ - 'secret' => $session->getAttribute('secret'), - 'provider' => $session->getAttribute('provider'), - 'expire' => $session->getAttribute('expire'), - 'hashed' => self::hash($secret), - 'secret_validation' => $session->getAttribute('secret') === self::hash($secret), - 'expiration_validation' => DateTime::formatTz(DateTime::format(new \DateTime($session->getAttribute('expire')))) >= DateTime::formatTz(DateTime::now()), - ]); + foreach ($sessions as $session) { + + var_dump([ + 'secret' => $session->getAttribute('secret'), + 'provider' => $session->getAttribute('provider'), + 'expire' => $session->getAttribute('expire'), + 'hashed' => self::hash($secret), + 'secret_validation' => $session->getAttribute('secret') === self::hash($secret), + 'expiration_validation' => DateTime::formatTz(DateTime::format(new \DateTime($session->getAttribute('expire')))) >= DateTime::formatTz(DateTime::now()), + ]); + + if ( $session->isSet('secret') && $session->isSet('provider') && From 430c883a889b6ac1a029c3ad418a4fcae25f8945 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 15:29:33 +0200 Subject: [PATCH 189/279] debug --- app/init.php | 14 +------------- src/Appwrite/Auth/Auth.php | 8 +++----- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/app/init.php b/app/init.php index 018140814c..ab4529406b 100644 --- a/app/init.php +++ b/app/init.php @@ -1301,14 +1301,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons } else { $user = $dbForPlatform->getDocument('users', Auth::$unique); } - var_dump([ - 'number' => 1, - 'file' => 'init.php', - '$user' => $user, - 'Auth::$secret' => Auth::$secret, - 'sessions' => $user->getAttribute('sessions', []), - 'Auth::sessionVerify' => Auth::sessionVerify($user->getAttribute('sessions', []), Auth::$secret) - ]); + if ( $user->isEmpty() // Check a document has been found in the DB @@ -1318,11 +1311,6 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons } - var_dump([ - 'number' => 2, - 'file' => 'init.php', - '$user' => $user, - ]); // if (APP_MODE_ADMIN === $mode) { // if ($user->find('teamInternalId', $project->getAttribute('teamInternalId'), 'memberships')) { // Authorization::setDefaultStatus(false); // Cancel security segmentation for admin users. diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index 72659dd6c5..4b1cb5f07a 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -391,12 +391,10 @@ class Auth foreach ($sessions as $session) { var_dump([ - 'secret' => $session->getAttribute('secret'), - 'provider' => $session->getAttribute('provider'), - 'expire' => $session->getAttribute('expire'), - 'hashed' => self::hash($secret), + 'secret from cookie' => $secret, + 'hashed secret' => self::hash($secret), + 'secret from db' => $session->getAttribute('secret'), 'secret_validation' => $session->getAttribute('secret') === self::hash($secret), - 'expiration_validation' => DateTime::formatTz(DateTime::format(new \DateTime($session->getAttribute('expire')))) >= DateTime::formatTz(DateTime::now()), ]); From 01dc8fa3960a0f20ccc16464d4e7bd9d2c92db8b Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 16:16:38 +0200 Subject: [PATCH 190/279] debug --- app/init.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/init.php b/app/init.php index ab4529406b..3efdda4118 100644 --- a/app/init.php +++ b/app/init.php @@ -607,7 +607,11 @@ Database::addFilter( } $value = json_decode($value, true); $key = System::getEnv('_APP_OPENSSL_KEY_V' . $value['version']); - + var_dump([ + 'key' => $key, + 'method' => $value['method'], + 'data' => $value['data'], + ]); return OpenSSL::decrypt($value['data'], $value['method'], $key, 0, hex2bin($value['iv']), hex2bin($value['tag'])); } ); From f94f6642eae8fc0ea679183bebd6b63ce517bc3d Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 17:45:42 +0200 Subject: [PATCH 191/279] debug --- app/init.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/init.php b/app/init.php index 3efdda4118..b211a71710 100644 --- a/app/init.php +++ b/app/init.php @@ -607,6 +607,7 @@ Database::addFilter( } $value = json_decode($value, true); $key = System::getEnv('_APP_OPENSSL_KEY_V' . $value['version']); + var_dump([ 'key' => $key, 'method' => $value['method'], From d0452e5d3bcecf9d9f96309402d4d5129717861e Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 20 Jan 2025 19:26:14 +0200 Subject: [PATCH 192/279] debug --- app/init.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/init.php b/app/init.php index b211a71710..14e614bf1e 100644 --- a/app/init.php +++ b/app/init.php @@ -609,9 +609,13 @@ Database::addFilter( $key = System::getEnv('_APP_OPENSSL_KEY_V' . $value['version']); var_dump([ + 'region' => System::getEnv('_APP_REGION', 'default'), 'key' => $key, + 'value' => $value, 'method' => $value['method'], 'data' => $value['data'], + 'iv' => hex2bin($value['iv']), + 'tag' => hex2bin($value['tag']) ]); return OpenSSL::decrypt($value['data'], $value['method'], $key, 0, hex2bin($value['iv']), hex2bin($value['tag'])); } From b9acae5a255f6f276c43ea9dc4037cde46317662 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 21 Jan 2025 09:43:34 +0200 Subject: [PATCH 193/279] debug --- app/init.php | 11 ----------- src/Appwrite/Auth/Auth.php | 12 ------------ 2 files changed, 23 deletions(-) diff --git a/app/init.php b/app/init.php index 14e614bf1e..2c827779d5 100644 --- a/app/init.php +++ b/app/init.php @@ -608,15 +608,6 @@ Database::addFilter( $value = json_decode($value, true); $key = System::getEnv('_APP_OPENSSL_KEY_V' . $value['version']); - var_dump([ - 'region' => System::getEnv('_APP_REGION', 'default'), - 'key' => $key, - 'value' => $value, - 'method' => $value['method'], - 'data' => $value['data'], - 'iv' => hex2bin($value['iv']), - 'tag' => hex2bin($value['tag']) - ]); return OpenSSL::decrypt($value['data'], $value['method'], $key, 0, hex2bin($value['iv']), hex2bin($value['tag'])); } ); @@ -1311,7 +1302,6 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons $user = $dbForPlatform->getDocument('users', Auth::$unique); } - if ( $user->isEmpty() // Check a document has been found in the DB || !Auth::sessionVerify($user->getAttribute('sessions', []), Auth::$secret) @@ -1319,7 +1309,6 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons $user = new Document([]); } - // if (APP_MODE_ADMIN === $mode) { // if ($user->find('teamInternalId', $project->getAttribute('teamInternalId'), 'memberships')) { // Authorization::setDefaultStatus(false); // Cancel security segmentation for admin users. diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index 4b1cb5f07a..1e8109622e 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -385,19 +385,7 @@ class Auth */ public static function sessionVerify(array $sessions, string $secret) { - - - foreach ($sessions as $session) { - - var_dump([ - 'secret from cookie' => $secret, - 'hashed secret' => self::hash($secret), - 'secret from db' => $session->getAttribute('secret'), - 'secret_validation' => $session->getAttribute('secret') === self::hash($secret), - ]); - - if ( $session->isSet('secret') && $session->isSet('provider') && From 066008293d5d2309c0dd1302c9fdf73bcbc41013 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 22 Jan 2025 18:49:57 +0200 Subject: [PATCH 194/279] debug --- composer.json | 6 +++--- composer.lock | 56 +++++++++++++++++++++++++-------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/composer.json b/composer.json index 4e1b5a98a2..dfbc834ed2 100644 --- a/composer.json +++ b/composer.json @@ -45,13 +45,13 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.16.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "0.46.*", + "utopia-php/abuse": "0.47.*", "utopia-php/analytics": "0.10.*", - "utopia-php/audit": "0.46.*", + "utopia-php/audit": "0.47.*", "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.32", + "utopia-php/database": "0.56.5", "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 48758aaba0..67ab9706d6 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": "3853435a659889e86c16764046950bed", + "content-hash": "1ca8e90732c949ace1f05ef3ceaf819b", "packages": [ { "name": "adhocore/jwt", @@ -3136,16 +3136,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.46.2", + "version": "0.47.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "59749df988430b28953fb5cabfad88b0ff5b539b" + "reference": "2b52bb362234d4072b647ed57db1b3be030f57c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/59749df988430b28953fb5cabfad88b0ff5b539b", - "reference": "59749df988430b28953fb5cabfad88b0ff5b539b", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/2b52bb362234d4072b647ed57db1b3be030f57c2", + "reference": "2b52bb362234d4072b647ed57db1b3be030f57c2", "shasum": "" }, "require": { @@ -3153,7 +3153,7 @@ "ext-pdo": "*", "ext-redis": "*", "php": ">=8.0", - "utopia-php/database": "0.53.32" + "utopia-php/database": "0.56.*" }, "require-dev": { "laravel/pint": "1.5.*", @@ -3181,9 +3181,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.46.2" + "source": "https://github.com/utopia-php/abuse/tree/0.47.0" }, - "time": "2025-01-13T02:09:43+00:00" + "time": "2025-01-15T02:41:02+00:00" }, { "name": "utopia-php/analytics", @@ -3233,21 +3233,21 @@ }, { "name": "utopia-php/audit", - "version": "0.46.1", + "version": "0.47.0", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "21255fa1ce66433140a43d380b2859c7f0a0bb37" + "reference": "1ebd5784ba68645073426f2f04a67726a1bde4d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/21255fa1ce66433140a43d380b2859c7f0a0bb37", - "reference": "21255fa1ce66433140a43d380b2859c7f0a0bb37", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/1ebd5784ba68645073426f2f04a67726a1bde4d7", + "reference": "1ebd5784ba68645073426f2f04a67726a1bde4d7", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "0.53.32" + "utopia-php/database": "0.56.*" }, "require-dev": { "laravel/pint": "1.5.*", @@ -3274,9 +3274,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.46.1" + "source": "https://github.com/utopia-php/audit/tree/0.47.0" }, - "time": "2025-01-13T02:19:56+00:00" + "time": "2025-01-15T02:40:53+00:00" }, { "name": "utopia-php/cache", @@ -3476,16 +3476,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.32", + "version": "0.56.5", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "981a1241139b42dccd531511130b79137740b205" + "reference": "e3a0eadf775f9fea9006d1f4d20ee1cb7f0c796d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/981a1241139b42dccd531511130b79137740b205", - "reference": "981a1241139b42dccd531511130b79137740b205", + "url": "https://api.github.com/repos/utopia-php/database/zipball/e3a0eadf775f9fea9006d1f4d20ee1cb7f0c796d", + "reference": "e3a0eadf775f9fea9006d1f4d20ee1cb7f0c796d", "shasum": "" }, "require": { @@ -3526,9 +3526,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.32" + "source": "https://github.com/utopia-php/database/tree/0.56.5" }, - "time": "2025-01-10T08:53:47+00:00" + "time": "2025-01-22T10:34:34+00:00" }, { "name": "utopia-php/domains", @@ -3929,16 +3929,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.14", + "version": "0.6.15", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "59a19f09ded0ccab4c8cca35b1242c01e2b9cfd2" + "reference": "e849ec3e7ad38f5f5273ebb0132b112639cdf01c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/59a19f09ded0ccab4c8cca35b1242c01e2b9cfd2", - "reference": "59a19f09ded0ccab4c8cca35b1242c01e2b9cfd2", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/e849ec3e7ad38f5f5273ebb0132b112639cdf01c", + "reference": "e849ec3e7ad38f5f5273ebb0132b112639cdf01c", "shasum": "" }, "require": { @@ -3946,7 +3946,7 @@ "ext-curl": "*", "ext-openssl": "*", "php": "8.3.*", - "utopia-php/database": "0.53.*", + "utopia-php/database": "0.56.*", "utopia-php/dsn": "0.2.*", "utopia-php/framework": "0.33.*", "utopia-php/storage": "0.18.*" @@ -3979,9 +3979,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.14" + "source": "https://github.com/utopia-php/migration/tree/0.6.15" }, - "time": "2025-01-08T01:07:25+00:00" + "time": "2025-01-15T04:55:08+00:00" }, { "name": "utopia-php/mongo", From 37087c37ca93dac898c01e1c317e682f2f507f9e Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 22 Jan 2025 20:44:18 +0200 Subject: [PATCH 195/279] debug platforms --- app/realtime.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/realtime.php b/app/realtime.php index 86f9c85fdd..6bf437f8d0 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -533,6 +533,10 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, * Skip this check for non-web platforms which are not required to send an origin header. */ $origin = $request->getOrigin(); + var_dump([ + 'platforms '=> $console->getAttribute('platforms', []) + ]); + $originValidator = new Origin(array_merge($project->getAttribute('platforms', []), $console->getAttribute('platforms', []))); if (!$originValidator->isValid($origin) && $project->getId() !== 'console') { From 59c41478caa71971fd0df04f781d91b4f02995d9 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 22 Jan 2025 21:14:41 +0200 Subject: [PATCH 196/279] debug platforms --- app/realtime.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/realtime.php b/app/realtime.php index 6bf437f8d0..5978bc31fc 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -534,6 +534,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, */ $origin = $request->getOrigin(); var_dump([ + '_APP_CONSOLE_HOSTNAMES' => System::getEnv('_APP_CONSOLE_HOSTNAMES'), 'platforms '=> $console->getAttribute('platforms', []) ]); From 9b58ae7ff554186bbda6aa8f065e587fc8e854db Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 23 Jan 2025 07:23:35 +0200 Subject: [PATCH 197/279] debug platforms --- app/realtime.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/realtime.php b/app/realtime.php index 5978bc31fc..384d300e6d 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -30,6 +30,7 @@ use Utopia\DSN\DSN; use Utopia\Logger\Log; use Utopia\System\System; use Utopia\Telemetry\Adapter\None as NoTelemetry; +use Utopia\Validator\Hostname; use Utopia\WebSocket\Adapter; use Utopia\WebSocket\Server; @@ -533,6 +534,21 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, * Skip this check for non-web platforms which are not required to send an origin header. */ $origin = $request->getOrigin(); + $hostnames = explode(',', System::getEnv('_APP_CONSOLE_HOSTNAMES', '')); + $validator = new Hostname(); + foreach ($hostnames as $hostname) { + $hostname = trim($hostname); + if (!$validator->isValid($hostname)) { + continue; + } + $console->setAttribute('platforms', [ + '$collection' => ID::custom('platforms'), + 'type' => Origin::CLIENT_TYPE_WEB, + 'name' => $hostname, + 'hostname' => $hostname, + ], Document::SET_TYPE_APPEND); + } + var_dump([ '_APP_CONSOLE_HOSTNAMES' => System::getEnv('_APP_CONSOLE_HOSTNAMES'), 'platforms '=> $console->getAttribute('platforms', []) From 9841f6ae87b8bf35db595940a4c7df87aeec7d64 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 23 Jan 2025 07:40:44 +0200 Subject: [PATCH 198/279] debug platforms --- app/realtime.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/realtime.php b/app/realtime.php index 384d300e6d..2f040d6214 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -541,6 +541,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, if (!$validator->isValid($hostname)) { continue; } + $console->setAttribute('platforms', [ '$collection' => ID::custom('platforms'), 'type' => Origin::CLIENT_TYPE_WEB, From 0052487d4962975a8b04a0b63da9f9e3ac742c25 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 23 Jan 2025 07:47:23 +0200 Subject: [PATCH 199/279] debug platforms --- app/init.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/init.php b/app/init.php index 2c827779d5..55a72c9558 100644 --- a/app/init.php +++ b/app/init.php @@ -1362,6 +1362,7 @@ App::setResource('project', function ($dbForPlatform, $request, $console) { if ($project->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { var_dump([ + 'x-projectId' => $projectId, 'projectId' => $project->getId(), 'projectRegion' => $project->getAttribute('region'), '_APP_REGION' => System::getEnv('_APP_REGION'), From 5113c9e50a06c96103562052bd49309c813d4aab Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 23 Jan 2025 07:53:03 +0200 Subject: [PATCH 200/279] debug platforms --- app/realtime.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/realtime.php b/app/realtime.php index 2f040d6214..d13198b853 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -534,21 +534,6 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, * Skip this check for non-web platforms which are not required to send an origin header. */ $origin = $request->getOrigin(); - $hostnames = explode(',', System::getEnv('_APP_CONSOLE_HOSTNAMES', '')); - $validator = new Hostname(); - foreach ($hostnames as $hostname) { - $hostname = trim($hostname); - if (!$validator->isValid($hostname)) { - continue; - } - - $console->setAttribute('platforms', [ - '$collection' => ID::custom('platforms'), - 'type' => Origin::CLIENT_TYPE_WEB, - 'name' => $hostname, - 'hostname' => $hostname, - ], Document::SET_TYPE_APPEND); - } var_dump([ '_APP_CONSOLE_HOSTNAMES' => System::getEnv('_APP_CONSOLE_HOSTNAMES'), From 74b06cdd962acc08d4d779c3c824352c9e9d9440 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 23 Jan 2025 08:51:13 +0200 Subject: [PATCH 201/279] debug platforms --- src/Appwrite/Platform/Workers/Builds.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 4f5d6eb694..bb466ef848 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -377,6 +377,10 @@ class Builds extends Action payload: $build, project: $project ); + + var_dump($target); + + Realtime::send( projectId: 'console', payload: $build->getArrayCopy(), From 54c8a890d355643e3c3d841ef1da0cb718c676c6 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 23 Jan 2025 09:23:19 +0200 Subject: [PATCH 202/279] removed comments --- app/realtime.php | 7 ------- src/Appwrite/Platform/Workers/Builds.php | 4 ---- 2 files changed, 11 deletions(-) diff --git a/app/realtime.php b/app/realtime.php index d13198b853..86f9c85fdd 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -30,7 +30,6 @@ use Utopia\DSN\DSN; use Utopia\Logger\Log; use Utopia\System\System; use Utopia\Telemetry\Adapter\None as NoTelemetry; -use Utopia\Validator\Hostname; use Utopia\WebSocket\Adapter; use Utopia\WebSocket\Server; @@ -534,12 +533,6 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, * Skip this check for non-web platforms which are not required to send an origin header. */ $origin = $request->getOrigin(); - - var_dump([ - '_APP_CONSOLE_HOSTNAMES' => System::getEnv('_APP_CONSOLE_HOSTNAMES'), - 'platforms '=> $console->getAttribute('platforms', []) - ]); - $originValidator = new Origin(array_merge($project->getAttribute('platforms', []), $console->getAttribute('platforms', []))); if (!$originValidator->isValid($origin) && $project->getId() !== 'console') { diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index bb466ef848..4f5d6eb694 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -377,10 +377,6 @@ class Builds extends Action payload: $build, project: $project ); - - var_dump($target); - - Realtime::send( projectId: 'console', payload: $build->getArrayCopy(), From ff1bfb61f11bfbaa7cacfcd589c9555c3f924d4a Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 09:06:10 +0200 Subject: [PATCH 203/279] payload debug --- app/controllers/api/vcs.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index f24a0d97fe..8d5216d091 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -884,6 +884,7 @@ App::post('/v1/vcs/github/events') ->action( function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { $payload = $request->getRawPayload(); + var_dump(['payload' => $payload]); $signatureRemote = $request->getHeader('x-hub-signature-256', ''); $signatureLocal = System::getEnv('_APP_VCS_GITHUB_WEBHOOK_SECRET', ''); From a70e323a15341633c61b63b1641d273314824db2 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 09:41:53 +0200 Subject: [PATCH 204/279] payload debug --- app/controllers/api/vcs.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 8d5216d091..826dec176b 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -881,10 +881,16 @@ App::post('/v1/vcs/github/events') ->inject('dbForPlatform') ->inject('getProjectDB') ->inject('queueForBuilds') + ->inject('project') ->action( - function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { + function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds, Document $project) use ($createGitDeployments) { $payload = $request->getRawPayload(); - var_dump(['payload' => $payload]); + + var_dump([ + 'project'=> $project, + $request->getHeaders() + ]); + $signatureRemote = $request->getHeader('x-hub-signature-256', ''); $signatureLocal = System::getEnv('_APP_VCS_GITHUB_WEBHOOK_SECRET', ''); From de298797938afa1ce1f71a6e333a956f148ac980 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 16:22:11 +0200 Subject: [PATCH 205/279] payload debug --- app/controllers/api/vcs.php | 53 ++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 826dec176b..8971d4549d 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -1,5 +1,6 @@ inject('dbForPlatform') ->inject('getProjectDB') ->inject('queueForBuilds') - ->inject('project') ->action( - function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds, Document $project) use ($createGitDeployments) { - $payload = $request->getRawPayload(); + function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { - var_dump([ - 'project'=> $project, - $request->getHeaders() - ]); + $payload = $request->getRawPayload(); + $parsedPayload = $github->getEvent($event, $payload); + $providerInstallationId = $parsedPayload["installationId"] ?? ''; + + $repository = Authorization::skip(fn () => $dbForPlatform->findOne('repositories', [ + Query::equal('installationId', [$providerInstallationId]), + ])); + + $projectId = $repository->getAttribute('projectId'); + var_dump($projectId); +// if (empty($projectId)) { +// throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, "Project was not found"); +// } +// +// $project = $dbForPlatform->getDocument('projects', $projectId); +// +// if($project->getAttribute('region') !== System::getEnv('_APP_REGION')){ +// $networkDomains = []; +// $tmp = explode(',', System::getEnv('_APP_NETWORK_DOMAINS')); +// foreach ($tmp as $domain) { +// $parts = explode('=', $domain); +// $networkDomains[$parts[0]] = $parts[1]; +// } +// +// $targetUrl = 'https://'.$networkDomains[$project->getAttribute('region')].'/v1/vcs/github/events'; +// $client = new Client(); +// foreach ($request->getHeaders() as $name => $value) { +// $client->addHeader($name, $value); +// } +// +// try { +// $client->fetch( +// url: $targetUrl, +// method: Client::METHOD_POST, +// body: $payload +// ); +// } catch (Throwable $th) { +// throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, "Error while redirecting to $targetUrl"); +// } +// } $signatureRemote = $request->getHeader('x-hub-signature-256', ''); $signatureLocal = System::getEnv('_APP_VCS_GITHUB_WEBHOOK_SECRET', ''); @@ -903,7 +939,7 @@ App::post('/v1/vcs/github/events') $event = $request->getHeader('x-github-event', ''); $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); - $parsedPayload = $github->getEvent($event, $payload); + if ($event == $github::EVENT_PUSH) { $providerBranchCreated = $parsedPayload["branchCreated"] ?? false; @@ -911,7 +947,6 @@ App::post('/v1/vcs/github/events') $providerBranchUrl = $parsedPayload["branchUrl"] ?? ''; $providerRepositoryId = $parsedPayload["repositoryId"] ?? ''; $providerRepositoryName = $parsedPayload["repositoryName"] ?? ''; - $providerInstallationId = $parsedPayload["installationId"] ?? ''; $providerRepositoryUrl = $parsedPayload["repositoryUrl"] ?? ''; $providerCommitHash = $parsedPayload["commitHash"] ?? ''; $providerRepositoryOwner = $parsedPayload["owner"] ?? ''; From 270dfd685da8ae2852fa6f451b588f21888aaf90 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 16:39:16 +0200 Subject: [PATCH 206/279] payload debug --- app/controllers/api/vcs.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 8971d4549d..bf6bc19ec4 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -887,6 +887,7 @@ App::post('/v1/vcs/github/events') function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { $payload = $request->getRawPayload(); + $event = $request->getHeader('x-github-event', ''); $parsedPayload = $github->getEvent($event, $payload); $providerInstallationId = $parsedPayload["installationId"] ?? ''; @@ -936,7 +937,7 @@ App::post('/v1/vcs/github/events') throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, "Invalid webhook payload signature. Please make sure the webhook secret has same value in your GitHub app and in the _APP_VCS_GITHUB_WEBHOOK_SECRET environment variable"); } - $event = $request->getHeader('x-github-event', ''); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); From 39585d04388ddc50f01861467ce924ea933a0899 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 16:46:02 +0200 Subject: [PATCH 207/279] payload debug --- app/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/init.php b/app/init.php index 55a72c9558..c869515ab1 100644 --- a/app/init.php +++ b/app/init.php @@ -1360,7 +1360,7 @@ App::setResource('project', function ($dbForPlatform, $request, $console) { $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); - if ($project->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { + if (!empty($project->getAttribute('region')) && $project->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { var_dump([ 'x-projectId' => $projectId, 'projectId' => $project->getId(), From 87de071f53e99e89bf9e716eb7e4e573927aab93 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 16:53:26 +0200 Subject: [PATCH 208/279] payload debug --- app/controllers/api/vcs.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index bf6bc19ec4..e97450950d 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -891,12 +891,18 @@ App::post('/v1/vcs/github/events') $parsedPayload = $github->getEvent($event, $payload); $providerInstallationId = $parsedPayload["installationId"] ?? ''; + $repository = Authorization::skip(fn () => $dbForPlatform->findOne('repositories', [ Query::equal('installationId', [$providerInstallationId]), ])); $projectId = $repository->getAttribute('projectId'); - var_dump($projectId); + + var_dump([ + 'providerInstallationId' => $providerInstallationId, + 'repository' => $repository, + 'projectId' => $projectId, + ]); // if (empty($projectId)) { // throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, "Project was not found"); // } From 78dcfd27709c1eb3909c5a38bc51d58824d6861f Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 17:25:57 +0200 Subject: [PATCH 209/279] payload debug --- app/controllers/api/vcs.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index e97450950d..6e4d7e213d 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -889,18 +889,18 @@ App::post('/v1/vcs/github/events') $payload = $request->getRawPayload(); $event = $request->getHeader('x-github-event', ''); $parsedPayload = $github->getEvent($event, $payload); - $providerInstallationId = $parsedPayload["installationId"] ?? ''; + $providerRepositoryId = $parsedPayload["repositoryId"] ?? ''; $repository = Authorization::skip(fn () => $dbForPlatform->findOne('repositories', [ - Query::equal('installationId', [$providerInstallationId]), + Query::equal('providerRepositoryId', [$providerRepositoryId]), ])); - $projectId = $repository->getAttribute('projectId'); + $projectId = $installation->getAttribute('projectId'); var_dump([ - 'providerInstallationId' => $providerInstallationId, - 'repository' => $repository, + 'providerRepositoryId' => $providerRepositoryId, + '$repository' => $repository, 'projectId' => $projectId, ]); // if (empty($projectId)) { @@ -955,6 +955,7 @@ App::post('/v1/vcs/github/events') $providerRepositoryId = $parsedPayload["repositoryId"] ?? ''; $providerRepositoryName = $parsedPayload["repositoryName"] ?? ''; $providerRepositoryUrl = $parsedPayload["repositoryUrl"] ?? ''; + $providerInstallationId = $parsedPayload["installationId"] ?? ''; $providerCommitHash = $parsedPayload["commitHash"] ?? ''; $providerRepositoryOwner = $parsedPayload["owner"] ?? ''; $providerCommitAuthor = $parsedPayload["headCommitAuthor"] ?? ''; From 1675683e76a58b22afd56fb32b2f2bb203d233c2 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 17:38:29 +0200 Subject: [PATCH 210/279] payload debug --- app/controllers/api/vcs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 6e4d7e213d..b02f3252ef 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -896,11 +896,11 @@ App::post('/v1/vcs/github/events') Query::equal('providerRepositoryId', [$providerRepositoryId]), ])); - $projectId = $installation->getAttribute('projectId'); + $projectId = $repository->getAttribute('projectId'); var_dump([ 'providerRepositoryId' => $providerRepositoryId, - '$repository' => $repository, + 'repository' => $repository, 'projectId' => $projectId, ]); // if (empty($projectId)) { From 2c4f5d3daa1e666bd17ccbc3b2055546bf9057f7 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 17:52:07 +0200 Subject: [PATCH 211/279] payload debug --- app/controllers/api/vcs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index b02f3252ef..2e6389220b 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -900,7 +900,7 @@ App::post('/v1/vcs/github/events') var_dump([ 'providerRepositoryId' => $providerRepositoryId, - 'repository' => $repository, + 'parsedPayload' => $parsedPayload, 'projectId' => $projectId, ]); // if (empty($projectId)) { From 0cc5088e8e1cb980a287b8ccdff3dcf362dcde23 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 18:03:24 +0200 Subject: [PATCH 212/279] payload debug --- app/controllers/api/vcs.php | 274 +++++++++++++++++++----------------- 1 file changed, 145 insertions(+), 129 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 2e6389220b..7f571f066e 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -1,10 +1,14 @@ desc('Install GitHub app') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk.namespace', 'vcs') ->label('error', __DIR__ . '/../../views/general/error.phtml') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'createGitHubInstallation') - ->label('sdk.description', '') - ->label('sdk.response.code', Response::STATUS_CODE_MOVED_PERMANENTLY) - ->label('sdk.response.type', Response::CONTENT_TYPE_HTML) - ->label('sdk.methodType', 'webAuth') - ->label('sdk.hide', true) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'createGitHubInstallation', + description: '/docs/references/vcs/create-github-installation.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_MOVED_PERMANENTLY, + model: Response::MODEL_NONE, + ) + ], + contentType: ContentType::HTML, + type: MethodType::WEBAUTH, + hide: true, + )) ->param('success', '', fn ($clients) => new Host($clients), 'URL to redirect back to console after a successful installation attempt.', true, ['clients']) ->param('failure', '', fn ($clients) => new Host($clients), 'URL to redirect back to console after a failed installation attempt.', true, ['clients']) ->inject('request') @@ -444,13 +454,18 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro ->desc('Get files and directories of a VCS repository') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'getRepositoryContents') - ->label('sdk.description', '') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_VCS_CONTENT_LIST) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'getRepositoryContents', + description: '/docs/references/vcs/get-repository-contents.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_VCS_CONTENT_LIST, + ) + ] + )) ->param('installationId', '', new Text(256), 'Installation Id') ->param('providerRepositoryId', '', new Text(256), 'Repository Id') ->param('providerRootDirectory', '', new Text(256, 0), 'Path to get contents of nested directory', true) @@ -505,13 +520,18 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories/:pr ->desc('Detect runtime settings from source code') ->groups(['api', 'vcs']) ->label('scope', 'vcs.write') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'createRepositoryDetection') - ->label('sdk.description', '') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_DETECTION) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'createRepositoryDetection', + description: '/docs/references/vcs/create-repository-detection.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_DETECTION, + ) + ] + )) ->param('installationId', '', new Text(256), 'Installation Id') ->param('providerRepositoryId', '', new Text(256), 'Repository Id') ->param('providerRootDirectory', '', new Text(256, 0), 'Path to Root Directory', true) @@ -577,13 +597,18 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories') ->desc('List repositories') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'listRepositories') - ->label('sdk.description', '') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_PROVIDER_REPOSITORY_LIST) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'listRepositories', + description: '/docs/references/vcs/list-repositories.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_PROVIDER_REPOSITORY_LIST, + ) + ] + )) ->param('installationId', '', new Text(256), 'Installation Id') ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->inject('gitHub') @@ -672,13 +697,18 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories') ->desc('Create repository') ->groups(['api', 'vcs']) ->label('scope', 'vcs.write') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'createRepository') - ->label('sdk.description', '') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_PROVIDER_REPOSITORY) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'createRepository', + description: '/docs/references/vcs/create-repository.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_PROVIDER_REPOSITORY, + ) + ] + )) ->param('installationId', '', new Text(256), 'Installation Id') ->param('name', '', new Text(256), 'Repository name (slug)') ->param('private', '', new Boolean(false), 'Mark repository public or private') @@ -779,13 +809,18 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro ->desc('Get repository') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'getRepository') - ->label('sdk.description', '') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_PROVIDER_REPOSITORY) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'getRepository', + description: '/docs/references/vcs/get-repository.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_PROVIDER_REPOSITORY, + ) + ] + )) ->param('installationId', '', new Text(256), 'Installation Id') ->param('providerRepositoryId', '', new Text(256), 'Repository Id') ->inject('gitHub') @@ -828,13 +863,18 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro ->desc('List repository branches') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'listRepositoryBranches') - ->label('sdk.description', '') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_BRANCH_LIST) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'listRepositoryBranches', + description: '/docs/references/vcs/list-repository-branches.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_BRANCH_LIST, + ) + ] + )) ->param('installationId', '', new Text(256), 'Installation Id') ->param('providerRepositoryId', '', new Text(256), 'Repository Id') ->inject('gitHub') @@ -885,55 +925,8 @@ App::post('/v1/vcs/github/events') ->inject('queueForBuilds') ->action( function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { - $payload = $request->getRawPayload(); - $event = $request->getHeader('x-github-event', ''); - $parsedPayload = $github->getEvent($event, $payload); - $providerRepositoryId = $parsedPayload["repositoryId"] ?? ''; - - - $repository = Authorization::skip(fn () => $dbForPlatform->findOne('repositories', [ - Query::equal('providerRepositoryId', [$providerRepositoryId]), - ])); - - $projectId = $repository->getAttribute('projectId'); - - var_dump([ - 'providerRepositoryId' => $providerRepositoryId, - 'parsedPayload' => $parsedPayload, - 'projectId' => $projectId, - ]); -// if (empty($projectId)) { -// throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, "Project was not found"); -// } -// -// $project = $dbForPlatform->getDocument('projects', $projectId); -// -// if($project->getAttribute('region') !== System::getEnv('_APP_REGION')){ -// $networkDomains = []; -// $tmp = explode(',', System::getEnv('_APP_NETWORK_DOMAINS')); -// foreach ($tmp as $domain) { -// $parts = explode('=', $domain); -// $networkDomains[$parts[0]] = $parts[1]; -// } -// -// $targetUrl = 'https://'.$networkDomains[$project->getAttribute('region')].'/v1/vcs/github/events'; -// $client = new Client(); -// foreach ($request->getHeaders() as $name => $value) { -// $client->addHeader($name, $value); -// } -// -// try { -// $client->fetch( -// url: $targetUrl, -// method: Client::METHOD_POST, -// body: $payload -// ); -// } catch (Throwable $th) { -// throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, "Error while redirecting to $targetUrl"); -// } -// } - + var_dump(['payload' => $payload]); $signatureRemote = $request->getHeader('x-hub-signature-256', ''); $signatureLocal = System::getEnv('_APP_VCS_GITHUB_WEBHOOK_SECRET', ''); @@ -943,10 +936,10 @@ App::post('/v1/vcs/github/events') throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, "Invalid webhook payload signature. Please make sure the webhook secret has same value in your GitHub app and in the _APP_VCS_GITHUB_WEBHOOK_SECRET environment variable"); } - + $event = $request->getHeader('x-github-event', ''); $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); - + $parsedPayload = $github->getEvent($event, $payload); if ($event == $github::EVENT_PUSH) { $providerBranchCreated = $parsedPayload["branchCreated"] ?? false; @@ -954,8 +947,8 @@ App::post('/v1/vcs/github/events') $providerBranchUrl = $parsedPayload["branchUrl"] ?? ''; $providerRepositoryId = $parsedPayload["repositoryId"] ?? ''; $providerRepositoryName = $parsedPayload["repositoryName"] ?? ''; - $providerRepositoryUrl = $parsedPayload["repositoryUrl"] ?? ''; $providerInstallationId = $parsedPayload["installationId"] ?? ''; + $providerRepositoryUrl = $parsedPayload["repositoryUrl"] ?? ''; $providerCommitHash = $parsedPayload["commitHash"] ?? ''; $providerRepositoryOwner = $parsedPayload["owner"] ?? ''; $providerCommitAuthor = $parsedPayload["headCommitAuthor"] ?? ''; @@ -1064,13 +1057,18 @@ App::get('/v1/vcs/installations') ->desc('List installations') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'listInstallations') - ->label('sdk.description', '/docs/references/vcs/list-installations.md') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_INSTALLATION_LIST) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'listInstallations', + description: '/docs/references/vcs/list-installations.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_INSTALLATION_LIST, + ) + ] + )) ->param('queries', [], new Installations(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long. You may filter on the following attributes: ' . implode(', ', Installations::ALLOWED_ATTRIBUTES), true) ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->inject('response') @@ -1130,13 +1128,18 @@ App::get('/v1/vcs/installations/:installationId') ->desc('Get installation') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'getInstallation') - ->label('sdk.description', '/docs/references/vcs/get-installation.md') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_INSTALLATION) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'getInstallation', + description: '/docs/references/vcs/get-installation.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_INSTALLATION, + ) + ] + )) ->param('installationId', '', new Text(256), 'Installation Id') ->inject('response') ->inject('project') @@ -1159,12 +1162,19 @@ App::delete('/v1/vcs/installations/:installationId') ->desc('Delete installation') ->groups(['api', 'vcs']) ->label('scope', 'vcs.write') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'deleteInstallation') - ->label('sdk.description', '/docs/references/vcs/delete-installation.md') - ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) - ->label('sdk.response.model', Response::MODEL_NONE) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'deleteInstallation', + description: '/docs/references/vcs/delete-installation.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_NOCONTENT, + model: Response::MODEL_NONE, + ) + ], + contentType: ContentType::NONE + )) ->param('installationId', '', new Text(256), 'Installation Id') ->inject('response') ->inject('project') @@ -1192,12 +1202,18 @@ App::patch('/v1/vcs/github/installations/:installationId/repositories/:repositor ->desc('Authorize external deployment') ->groups(['api', 'vcs']) ->label('scope', 'vcs.write') - ->label('sdk.namespace', 'vcs') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.method', 'updateExternalDeployments') - ->label('sdk.description', '') - ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) - ->label('sdk.response.model', Response::MODEL_NONE) + ->label('sdk', new Method( + namespace: 'vcs', + name: 'updateExternalDeployments', + description: '/docs/references/vcs/update-external-deployments.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_NOCONTENT, + model: Response::MODEL_NONE, + ) + ] + )) ->param('installationId', '', new Text(256), 'Installation Id') ->param('repositoryId', '', new Text(256), 'VCS Repository Id') ->param('providerPullRequestId', '', new Text(256), 'GitHub Pull Request Id') From b18d3bc67889a4da5e5ad0908b31ca745220e135 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 24 Jan 2025 18:36:32 +0200 Subject: [PATCH 213/279] payload debug --- app/controllers/api/vcs.php | 219 +++++++++++++----------------------- composer.json | 2 +- composer.lock | 14 +-- 3 files changed, 85 insertions(+), 150 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 7f571f066e..a91b457d9f 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -1,14 +1,10 @@ desc('Install GitHub app') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') + ->label('sdk.namespace', 'vcs') ->label('error', __DIR__ . '/../../views/general/error.phtml') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'createGitHubInstallation', - description: '/docs/references/vcs/create-github-installation.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_MOVED_PERMANENTLY, - model: Response::MODEL_NONE, - ) - ], - contentType: ContentType::HTML, - type: MethodType::WEBAUTH, - hide: true, - )) + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'createGitHubInstallation') + ->label('sdk.description', '') + ->label('sdk.response.code', Response::STATUS_CODE_MOVED_PERMANENTLY) + ->label('sdk.response.type', Response::CONTENT_TYPE_HTML) + ->label('sdk.methodType', 'webAuth') + ->label('sdk.hide', true) ->param('success', '', fn ($clients) => new Host($clients), 'URL to redirect back to console after a successful installation attempt.', true, ['clients']) ->param('failure', '', fn ($clients) => new Host($clients), 'URL to redirect back to console after a failed installation attempt.', true, ['clients']) ->inject('request') @@ -454,18 +443,13 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro ->desc('Get files and directories of a VCS repository') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'getRepositoryContents', - description: '/docs/references/vcs/get-repository-contents.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_OK, - model: Response::MODEL_VCS_CONTENT_LIST, - ) - ] - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'getRepositoryContents') + ->label('sdk.description', '') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_VCS_CONTENT_LIST) ->param('installationId', '', new Text(256), 'Installation Id') ->param('providerRepositoryId', '', new Text(256), 'Repository Id') ->param('providerRootDirectory', '', new Text(256, 0), 'Path to get contents of nested directory', true) @@ -520,18 +504,13 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories/:pr ->desc('Detect runtime settings from source code') ->groups(['api', 'vcs']) ->label('scope', 'vcs.write') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'createRepositoryDetection', - description: '/docs/references/vcs/create-repository-detection.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_OK, - model: Response::MODEL_DETECTION, - ) - ] - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'createRepositoryDetection') + ->label('sdk.description', '') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_DETECTION) ->param('installationId', '', new Text(256), 'Installation Id') ->param('providerRepositoryId', '', new Text(256), 'Repository Id') ->param('providerRootDirectory', '', new Text(256, 0), 'Path to Root Directory', true) @@ -597,18 +576,13 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories') ->desc('List repositories') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'listRepositories', - description: '/docs/references/vcs/list-repositories.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_OK, - model: Response::MODEL_PROVIDER_REPOSITORY_LIST, - ) - ] - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'listRepositories') + ->label('sdk.description', '') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_PROVIDER_REPOSITORY_LIST) ->param('installationId', '', new Text(256), 'Installation Id') ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->inject('gitHub') @@ -697,18 +671,13 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories') ->desc('Create repository') ->groups(['api', 'vcs']) ->label('scope', 'vcs.write') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'createRepository', - description: '/docs/references/vcs/create-repository.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_OK, - model: Response::MODEL_PROVIDER_REPOSITORY, - ) - ] - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'createRepository') + ->label('sdk.description', '') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_PROVIDER_REPOSITORY) ->param('installationId', '', new Text(256), 'Installation Id') ->param('name', '', new Text(256), 'Repository name (slug)') ->param('private', '', new Boolean(false), 'Mark repository public or private') @@ -809,18 +778,13 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro ->desc('Get repository') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'getRepository', - description: '/docs/references/vcs/get-repository.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_OK, - model: Response::MODEL_PROVIDER_REPOSITORY, - ) - ] - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'getRepository') + ->label('sdk.description', '') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_PROVIDER_REPOSITORY) ->param('installationId', '', new Text(256), 'Installation Id') ->param('providerRepositoryId', '', new Text(256), 'Repository Id') ->inject('gitHub') @@ -863,18 +827,13 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro ->desc('List repository branches') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'listRepositoryBranches', - description: '/docs/references/vcs/list-repository-branches.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_OK, - model: Response::MODEL_BRANCH_LIST, - ) - ] - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'listRepositoryBranches') + ->label('sdk.description', '') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_BRANCH_LIST) ->param('installationId', '', new Text(256), 'Installation Id') ->param('providerRepositoryId', '', new Text(256), 'Repository Id') ->inject('gitHub') @@ -926,7 +885,6 @@ App::post('/v1/vcs/github/events') ->action( function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { $payload = $request->getRawPayload(); - var_dump(['payload' => $payload]); $signatureRemote = $request->getHeader('x-hub-signature-256', ''); $signatureLocal = System::getEnv('_APP_VCS_GITHUB_WEBHOOK_SECRET', ''); @@ -1057,18 +1015,13 @@ App::get('/v1/vcs/installations') ->desc('List installations') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'listInstallations', - description: '/docs/references/vcs/list-installations.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_OK, - model: Response::MODEL_INSTALLATION_LIST, - ) - ] - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'listInstallations') + ->label('sdk.description', '/docs/references/vcs/list-installations.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_INSTALLATION_LIST) ->param('queries', [], new Installations(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long. You may filter on the following attributes: ' . implode(', ', Installations::ALLOWED_ATTRIBUTES), true) ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->inject('response') @@ -1128,18 +1081,13 @@ App::get('/v1/vcs/installations/:installationId') ->desc('Get installation') ->groups(['api', 'vcs']) ->label('scope', 'vcs.read') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'getInstallation', - description: '/docs/references/vcs/get-installation.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_OK, - model: Response::MODEL_INSTALLATION, - ) - ] - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'getInstallation') + ->label('sdk.description', '/docs/references/vcs/get-installation.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_INSTALLATION) ->param('installationId', '', new Text(256), 'Installation Id') ->inject('response') ->inject('project') @@ -1162,19 +1110,12 @@ App::delete('/v1/vcs/installations/:installationId') ->desc('Delete installation') ->groups(['api', 'vcs']) ->label('scope', 'vcs.write') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'deleteInstallation', - description: '/docs/references/vcs/delete-installation.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_NOCONTENT, - model: Response::MODEL_NONE, - ) - ], - contentType: ContentType::NONE - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'deleteInstallation') + ->label('sdk.description', '/docs/references/vcs/delete-installation.md') + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->label('sdk.response.model', Response::MODEL_NONE) ->param('installationId', '', new Text(256), 'Installation Id') ->inject('response') ->inject('project') @@ -1202,18 +1143,12 @@ App::patch('/v1/vcs/github/installations/:installationId/repositories/:repositor ->desc('Authorize external deployment') ->groups(['api', 'vcs']) ->label('scope', 'vcs.write') - ->label('sdk', new Method( - namespace: 'vcs', - name: 'updateExternalDeployments', - description: '/docs/references/vcs/update-external-deployments.md', - auth: [AuthType::ADMIN], - responses: [ - new SDKResponse( - code: Response::STATUS_CODE_NOCONTENT, - model: Response::MODEL_NONE, - ) - ] - )) + ->label('sdk.namespace', 'vcs') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.method', 'updateExternalDeployments') + ->label('sdk.description', '') + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->label('sdk.response.model', Response::MODEL_NONE) ->param('installationId', '', new Text(256), 'Installation Id') ->param('repositoryId', '', new Text(256), 'VCS Repository Id') ->param('providerPullRequestId', '', new Text(256), 'GitHub Pull Request Id') diff --git a/composer.json b/composer.json index dfbc834ed2..cce79cc928 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", - "utopia-php/fetch": "0.2.*", + "utopia-php/fetch": "0.3.*", "utopia-php/image": "0.7.*", "utopia-php/locale": "0.4.*", "utopia-php/logger": "0.6.*", diff --git a/composer.lock b/composer.lock index 67ab9706d6..04fda4af4f 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": "1ca8e90732c949ace1f05ef3ceaf819b", + "content-hash": "437347e8b0264137ab3a4427b5334ed4", "packages": [ { "name": "adhocore/jwt", @@ -3639,16 +3639,16 @@ }, { "name": "utopia-php/fetch", - "version": "0.2.1", + "version": "0.3.0", "source": { "type": "git", "url": "https://github.com/utopia-php/fetch.git", - "reference": "1423c0ee3eef944d816ca6e31706895b585aea82" + "reference": "02b12c05aec13399dcc2da8d51f908e328ab63f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/fetch/zipball/1423c0ee3eef944d816ca6e31706895b585aea82", - "reference": "1423c0ee3eef944d816ca6e31706895b585aea82", + "url": "https://api.github.com/repos/utopia-php/fetch/zipball/02b12c05aec13399dcc2da8d51f908e328ab63f4", + "reference": "02b12c05aec13399dcc2da8d51f908e328ab63f4", "shasum": "" }, "require": { @@ -3672,9 +3672,9 @@ "description": "A simple library that provides an interface for making HTTP Requests.", "support": { "issues": "https://github.com/utopia-php/fetch/issues", - "source": "https://github.com/utopia-php/fetch/tree/0.2.1" + "source": "https://github.com/utopia-php/fetch/tree/0.3.0" }, - "time": "2024-03-18T11:50:59+00:00" + "time": "2025-01-17T06:11:10+00:00" }, { "name": "utopia-php/framework", From b73b450a2e90d3cfdbb96533ad670e81d77bc578 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 4 Feb 2025 21:36:06 +0200 Subject: [PATCH 214/279] updated against 1.6.x --- composer.lock | 127 +++++++++++++++----------------------------------- 1 file changed, 37 insertions(+), 90 deletions(-) diff --git a/composer.lock b/composer.lock index 04fda4af4f..a35ae8268e 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": "437347e8b0264137ab3a4427b5334ed4", + "content-hash": "d020ecb017b7fcd201bd8e2e65d8561c", "packages": [ { "name": "adhocore/jwt", @@ -1237,16 +1237,16 @@ }, { "name": "open-telemetry/api", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/api.git", - "reference": "351a30baa79699de3de3a814c8ccc7b52ccdfb1d" + "reference": "74b1a03263be8c5acb578f41da054b4bac3af4a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/351a30baa79699de3de3a814c8ccc7b52ccdfb1d", - "reference": "351a30baa79699de3de3a814c8ccc7b52ccdfb1d", + "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/74b1a03263be8c5acb578f41da054b4bac3af4a0", + "reference": "74b1a03263be8c5acb578f41da054b4bac3af4a0", "shasum": "" }, "require": { @@ -1303,7 +1303,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2025-01-08T23:50:34+00:00" + "time": "2025-01-20T23:35:16+00:00" }, { "name": "open-telemetry/context", @@ -1493,16 +1493,16 @@ }, { "name": "open-telemetry/sdk", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/sdk.git", - "reference": "9a1c3b866239dbff291e5cc555bb7793eab08127" + "reference": "96aeaee5b7cb8c0bc4af7ff4717b429f2d9f67e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/9a1c3b866239dbff291e5cc555bb7793eab08127", - "reference": "9a1c3b866239dbff291e5cc555bb7793eab08127", + "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/96aeaee5b7cb8c0bc4af7ff4717b429f2d9f67e1", + "reference": "96aeaee5b7cb8c0bc4af7ff4717b429f2d9f67e1", "shasum": "" }, "require": { @@ -1579,7 +1579,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2025-01-08T23:50:34+00:00" + "time": "2025-01-09T23:17:14+00:00" }, { "name": "open-telemetry/sem-conv", @@ -2453,16 +2453,16 @@ }, { "name": "symfony/http-client", - "version": "v7.2.2", + "version": "v7.2.3", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "339ba21476eb184290361542f732ad12c97591ec" + "reference": "7ce6078c79a4a7afff931c413d2959d3bffbfb8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/339ba21476eb184290361542f732ad12c97591ec", - "reference": "339ba21476eb184290361542f732ad12c97591ec", + "url": "https://api.github.com/repos/symfony/http-client/zipball/7ce6078c79a4a7afff931c413d2959d3bffbfb8d", + "reference": "7ce6078c79a4a7afff931c413d2959d3bffbfb8d", "shasum": "" }, "require": { @@ -2528,7 +2528,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.2.2" + "source": "https://github.com/symfony/http-client/tree/v7.2.3" }, "funding": [ { @@ -2544,7 +2544,7 @@ "type": "tidelift" } ], - "time": "2024-12-30T18:35:15+00:00" + "time": "2025-01-28T15:51:35+00:00" }, { "name": "symfony/http-client-contracts", @@ -3878,16 +3878,16 @@ }, { "name": "utopia-php/messaging", - "version": "0.13.0", + "version": "0.14.1", "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "0e3e57351fe4fe875ef3ab9a01a7fff5f022de90" + "reference": "4ba356a3aa382802727f7e13e0f0152bcc1fc535" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/0e3e57351fe4fe875ef3ab9a01a7fff5f022de90", - "reference": "0e3e57351fe4fe875ef3ab9a01a7fff5f022de90", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/4ba356a3aa382802727f7e13e0f0152bcc1fc535", + "reference": "4ba356a3aa382802727f7e13e0f0152bcc1fc535", "shasum": "" }, "require": { @@ -3923,9 +3923,9 @@ ], "support": { "issues": "https://github.com/utopia-php/messaging/issues", - "source": "https://github.com/utopia-php/messaging/tree/0.13.0" + "source": "https://github.com/utopia-php/messaging/tree/0.14.1" }, - "time": "2024-12-05T08:36:07+00:00" + "time": "2025-01-28T06:14:28+00:00" }, { "name": "utopia-php/migration", @@ -4807,16 +4807,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.28", + "version": "0.39.32", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "6ff467858fe418e364460da905139216570a5d5e" + "reference": "2d02e1305ea5004fb0aec6b2618d6c597659b75c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/6ff467858fe418e364460da905139216570a5d5e", - "reference": "6ff467858fe418e364460da905139216570a5d5e", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/2d02e1305ea5004fb0aec6b2618d6c597659b75c", + "reference": "2d02e1305ea5004fb0aec6b2618d6c597659b75c", "shasum": "" }, "require": { @@ -4852,9 +4852,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.28" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.32" }, - "time": "2024-12-30T11:17:25+00:00" + "time": "2025-01-29T04:04:19+00:00" }, { "name": "doctrine/annotations", @@ -5601,70 +5601,18 @@ }, "time": "2023-10-30T13:38:26+00:00" }, - { - "name": "phpbench/dom", - "version": "0.3.3", - "source": { - "type": "git", - "url": "https://github.com/phpbench/dom.git", - "reference": "786a96db538d0def931f5b19225233ec42ec7a72" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpbench/dom/zipball/786a96db538d0def931f5b19225233ec42ec7a72", - "reference": "786a96db538d0def931f5b19225233ec42ec7a72", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "php": "^7.3||^8.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.14", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^8.0||^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "PhpBench\\Dom\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Daniel Leech", - "email": "daniel@dantleech.com" - } - ], - "description": "DOM wrapper to simplify working with the PHP DOM implementation", - "support": { - "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" - }, { "name": "phpbench/phpbench", - "version": "1.3.1", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/phpbench/phpbench.git", - "reference": "a3e1ef08d9d7736d43a7fbd444893d6a073c0ca0" + "reference": "4248817222514421cba466bfa7adc7d8932345d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpbench/phpbench/zipball/a3e1ef08d9d7736d43a7fbd444893d6a073c0ca0", - "reference": "a3e1ef08d9d7736d43a7fbd444893d6a073c0ca0", + "url": "https://api.github.com/repos/phpbench/phpbench/zipball/4248817222514421cba466bfa7adc7d8932345d4", + "reference": "4248817222514421cba466bfa7adc7d8932345d4", "shasum": "" }, "require": { @@ -5677,7 +5625,6 @@ "ext-tokenizer": "*", "php": "^8.1", "phpbench/container": "^2.2", - "phpbench/dom": "~0.3.3", "psr/log": "^1.1 || ^2.0 || ^3.0", "seld/jsonlint": "^1.1", "symfony/console": "^6.1 || ^7.0", @@ -5696,8 +5643,8 @@ "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.0", "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^10.4", - "rector/rector": "^0.18.11 || ^1.0.0", + "phpunit/phpunit": "^10.4 || ^11.0", + "rector/rector": "^1.2", "symfony/error-handler": "^6.1 || ^7.0", "symfony/var-dumper": "^6.1 || ^7.0" }, @@ -5742,7 +5689,7 @@ ], "support": { "issues": "https://github.com/phpbench/phpbench/issues", - "source": "https://github.com/phpbench/phpbench/tree/1.3.1" + "source": "https://github.com/phpbench/phpbench/tree/1.4.0" }, "funding": [ { @@ -5750,7 +5697,7 @@ "type": "github" } ], - "time": "2024-06-30T11:04:37+00:00" + "time": "2025-01-26T19:54:45+00:00" }, { "name": "phpdocumentor/reflection-common", From be27912a6e149d8e54804dbe4044954c431c14b4 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 5 Feb 2025 11:35:19 +0200 Subject: [PATCH 215/279] _APP_DOMAIN_FUNCTIONS_FALLBACK --- app/controllers/general.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 9088e6bfe9..da326f471d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -72,11 +72,26 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw } if ($route->isEmpty()) { - if ($host === System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) { + + $appDomainFunctionsFallback = System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''); + $appDomainFunctions = System::getEnv('_APP_DOMAIN_FUNCTIONS' ,''); + + if (!empty($appDomainFunctionsFallback) && \str_ends_with($host, $appDomainFunctionsFallback)) { + $appDomainFunctions = $appDomainFunctionsFallback; + } + + var_dump([ + 'location' => 'router', + '_APP_DOMAIN_FUNCTIONS_FALLBACK' => System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''), + '_APP_DOMAIN_FUNCTIONS' => System::getEnv('_APP_DOMAIN_FUNCTIONS' ,''), + 'appDomainFunctions' => $appDomainFunctions, + ]); + + if ($host === $appDomainFunctions) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain cannot be used for security reasons. Please use any subdomain instead.'); } - if (\str_ends_with($host, System::getEnv('_APP_DOMAIN_FUNCTIONS', ''))) { + if (\str_ends_with($host, $appDomainFunctions)) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain is not connected to any Appwrite resource yet. Please configure custom domain or function domain to allow this request.'); } From 3cfb013f1ef32589b94ebb205bed78ea0185caef Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 5 Feb 2025 12:49:04 +0200 Subject: [PATCH 216/279] _APP_DOMAIN_FUNCTIONS_FALLBACK --- app/controllers/general.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index da326f471d..182dcbcc1b 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -85,6 +85,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw '_APP_DOMAIN_FUNCTIONS_FALLBACK' => System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''), '_APP_DOMAIN_FUNCTIONS' => System::getEnv('_APP_DOMAIN_FUNCTIONS' ,''), 'appDomainFunctions' => $appDomainFunctions, + 'host' => $host, ]); if ($host === $appDomainFunctions) { From 50400c4b43e448dbeb97173a0306f4c7aff2cfa6 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 5 Feb 2025 13:14:03 +0200 Subject: [PATCH 217/279] _APP_DOMAIN_FUNCTIONS_FALLBACK --- app/controllers/general.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 182dcbcc1b..374080ff52 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -80,14 +80,6 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw $appDomainFunctions = $appDomainFunctionsFallback; } - var_dump([ - 'location' => 'router', - '_APP_DOMAIN_FUNCTIONS_FALLBACK' => System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''), - '_APP_DOMAIN_FUNCTIONS' => System::getEnv('_APP_DOMAIN_FUNCTIONS' ,''), - 'appDomainFunctions' => $appDomainFunctions, - 'host' => $host, - ]); - if ($host === $appDomainFunctions) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain cannot be used for security reasons. Please use any subdomain instead.'); } From e992ed11c10fae33cc8be9ee9bd8b9afd2d87686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 6 Feb 2025 11:08:28 +0100 Subject: [PATCH 218/279] Fix unwanted redirects in functions --- 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 374080ff52..121483321b 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -494,7 +494,7 @@ App::init() }); App::init() - ->groups(['api']) + ->groups(['api', 'web']) ->inject('utopia') ->inject('swooleRequest') ->inject('request') From 00478e8533cdf4437b564b012789a307da22fa87 Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 14 Feb 2025 11:08:43 +0200 Subject: [PATCH 219/279] _APP_DOMAIN_FUNCTIONS_FALLBACK --- app/controllers/general.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index 121483321b..6a29cde5d3 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -71,6 +71,16 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw )[0] ?? new Document(); } + var_dump([ + 'location' => 'router function', + '_APP_RULES_FORMAT' => System::getEnv('_APP_RULES_FORMAT'), + 'host' => $host, + 'md5' => md5($host), + 'route' => $route, + + ]); + + if ($route->isEmpty()) { $appDomainFunctionsFallback = System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''); From 463bc4aac3b6a3b013377f66e23f3fb106f501df Mon Sep 17 00:00:00 2001 From: shimon Date: Sat, 15 Feb 2025 06:28:19 +0200 Subject: [PATCH 220/279] sync against 1.6.x --- app/controllers/api/vcs.php | 1 - app/controllers/general.php | 4 ++-- composer.lock | 16 ++++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 49a4191257..2c145febcc 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -1,6 +1,5 @@ isEmpty()) { $appDomainFunctionsFallback = System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''); - $appDomainFunctions = System::getEnv('_APP_DOMAIN_FUNCTIONS' ,''); + $appDomainFunctions = System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); if (!empty($appDomainFunctionsFallback) && \str_ends_with($host, $appDomainFunctionsFallback)) { - $appDomainFunctions = $appDomainFunctionsFallback; + $appDomainFunctions = $appDomainFunctionsFallback; } if ($host === $appDomainFunctions) { diff --git a/composer.lock b/composer.lock index 152a7bd0d1..ea7382e3da 100644 --- a/composer.lock +++ b/composer.lock @@ -6190,16 +6190,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "c00d78fb6b29658347f9d37ebe104bffadf36299" + "reference": "72e51f7c32c5aef7c8b462195b8c599b11199893" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/c00d78fb6b29658347f9d37ebe104bffadf36299", - "reference": "c00d78fb6b29658347f9d37ebe104bffadf36299", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/72e51f7c32c5aef7c8b462195b8c599b11199893", + "reference": "72e51f7c32c5aef7c8b462195b8c599b11199893", "shasum": "" }, "require": { @@ -6231,9 +6231,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/2.0.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.0.1" }, - "time": "2024-10-13T11:29:49+00:00" + "time": "2025-02-13T12:25:43+00:00" }, { "name": "phpunit/php-code-coverage", @@ -8747,7 +8747,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8771,5 +8771,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } From a8a8df602f1385da0269c5be4b952924f532386f Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 17 Feb 2025 10:30:53 +0200 Subject: [PATCH 221/279] sync against 1.6.x --- app/controllers/api/projects.php | 6 +++--- app/controllers/general.php | 10 ---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index b29bd227aa..04d14815be 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -213,17 +213,17 @@ 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); $sharedTablesV1 = \in_array($dsn->getHost(), $sharedTablesV1); $sharedTablesV2 = !$projectTables && !$sharedTablesV1; $sharedTables = $sharedTablesV1 || $sharedTablesV2; if (!$sharedTablesV2) { - $adapter = $pools->get($dsn->getHost())->pop()->getResource(); - $dbForProject = new Database($adapter, $cache); - if ($sharedTables) { $dbForProject ->setSharedTables(true) diff --git a/app/controllers/general.php b/app/controllers/general.php index 37a3d24f24..f40aabe51e 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -71,16 +71,6 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw )[0] ?? new Document(); } - var_dump([ - 'location' => 'router function', - '_APP_RULES_FORMAT' => System::getEnv('_APP_RULES_FORMAT'), - 'host' => $host, - 'md5' => md5($host), - 'route' => $route, - - ]); - - if ($route->isEmpty()) { $appDomainFunctionsFallback = System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''); From 39e5c5e734d0f2e1de8af726491025617c9dcfe8 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Feb 2025 10:11:47 +0200 Subject: [PATCH 222/279] debug --- app/controllers/general.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index f40aabe51e..50915c2cd8 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -88,12 +88,20 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain is not connected to any Appwrite resource yet. Please configure custom domain or function domain to allow this request.'); } + var_dump([ + 'before' => $host + ]); + if (System::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { 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.'); } } + var_dump([ + 'after' => $host + ]); + // Act as API - no Proxy logic $utopia->getRoute()?->label('error', ''); return false; From 197e32f1284137638d4fbccc8415a6571d99195d Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Feb 2025 13:52:14 +0200 Subject: [PATCH 223/279] debug --- app/controllers/general.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index 50915c2cd8..9ab45c7328 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -527,6 +527,9 @@ App::init() */ $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); + + var_dump('Called'); + // Only run Router when external domain if ($host !== $mainDomain || !empty($previewHostname)) { if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $geodb, $isResourceBlocked, $previewHostname)) { From baa40e4007f9e63b45138f2c9fc2062d648b3ead Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Feb 2025 18:15:26 +0200 Subject: [PATCH 224/279] debug --- 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 9ab45c7328..b7ca785baf 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -528,7 +528,7 @@ App::init() $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); - var_dump('Called'); + var_dump('Init Called'); // Only run Router when external domain if ($host !== $mainDomain || !empty($previewHostname)) { From c151d2aaca5b745e86693b0fa7773015c78a40c6 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Feb 2025 18:18:39 +0200 Subject: [PATCH 225/279] debug --- app/controllers/api/projects.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 04d14815be..48d20cd17f 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -138,14 +138,6 @@ App::post('/v1/projects') $databases = Config::getParam('pools-database', []); - if ($region !== 'default') { - $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'); $index = \array_search($databaseOverride, $databases); if ($index !== false) { From 4157e89ab724f64c6eec942c853f76493b38e398 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Feb 2025 22:33:13 +0200 Subject: [PATCH 226/279] debug --- 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 b7ca785baf..abf4898938 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -91,12 +91,12 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw var_dump([ 'before' => $host ]); - - if (System::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { - 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.'); - } - } +// +// if (System::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { +// 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.'); +// } +// } var_dump([ 'after' => $host From be1c12147fa4d906bff4b09d0e875bf7f8e01fde Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Feb 2025 22:59:04 +0200 Subject: [PATCH 227/279] debug --- app/controllers/general.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index abf4898938..2230c99e2c 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -88,19 +88,11 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain is not connected to any Appwrite resource yet. Please configure custom domain or function domain to allow this request.'); } - var_dump([ - 'before' => $host - ]); -// -// if (System::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { -// 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.'); -// } -// } - - var_dump([ - 'after' => $host - ]); + if (System::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { + 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.'); + } + } // Act as API - no Proxy logic $utopia->getRoute()?->label('error', ''); @@ -528,7 +520,6 @@ App::init() $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); - var_dump('Init Called'); // Only run Router when external domain if ($host !== $mainDomain || !empty($previewHostname)) { From 45b2d58aa5b9e3b2e5d5b50546aceabcb525e1f2 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Feb 2025 23:28:09 +0200 Subject: [PATCH 228/279] debug --- app/controllers/api/projects.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 48d20cd17f..ddc9656b12 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -137,7 +137,14 @@ App::post('/v1/projects') } $databases = Config::getParam('pools-database', []); + var_dump( + [ + 'location' => 'projects.php', + '_APP_REGION' => System::getEnv('_APP_REGION'), + 'databases' => $databases + ] + ); $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); $index = \array_search($databaseOverride, $databases); if ($index !== false) { From e4369e5e85e889efc871885db99488df9705b69c Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 20 Feb 2025 09:48:17 +0200 Subject: [PATCH 229/279] debug --- app/controllers/api/projects.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index ddc9656b12..b6f1877ea8 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -137,14 +137,22 @@ App::post('/v1/projects') } $databases = Config::getParam('pools-database', []); - var_dump( - [ - 'location' => 'projects.php', - '_APP_REGION' => System::getEnv('_APP_REGION'), - 'databases' => $databases - ] + if ($region !== 'default') { + $databaseKeys = System::getEnv('_APP_DATABASE_KEYS', ''); + $keys = explode(',', $databaseKeys); + $databases = array_filter($keys, function ($value) use ($region) { + return str_contains($value, $region); + }); + } + + var_dump([ + 'location' => 'projects.php', + '_APP_REGION' => System::getEnv('_APP_REGION'), + 'databases' => $databases + ] ); + $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); $index = \array_search($databaseOverride, $databases); if ($index !== false) { From e972ccedd63ee349ff55e42eddb6713ad11b3b68 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 20 Feb 2025 10:26:39 +0200 Subject: [PATCH 230/279] debug --- app/controllers/api/projects.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index b6f1877ea8..b29bd227aa 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -146,13 +146,6 @@ App::post('/v1/projects') }); } - var_dump([ - 'location' => 'projects.php', - '_APP_REGION' => System::getEnv('_APP_REGION'), - 'databases' => $databases - ] - ); - $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE'); $index = \array_search($databaseOverride, $databases); if ($index !== false) { @@ -220,17 +213,17 @@ 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); $sharedTablesV1 = \in_array($dsn->getHost(), $sharedTablesV1); $sharedTablesV2 = !$projectTables && !$sharedTablesV1; $sharedTables = $sharedTablesV1 || $sharedTablesV2; if (!$sharedTablesV2) { + $adapter = $pools->get($dsn->getHost())->pop()->getResource(); + $dbForProject = new Database($adapter, $cache); + if ($sharedTables) { $dbForProject ->setSharedTables(true) From 1f606a591d36f9004f7ca5945be3dd5990539b5e Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 24 Feb 2025 14:13:18 +0200 Subject: [PATCH 231/279] debug cert --- src/Appwrite/Certificates/LetsEncrypt.php | 12 +++++++++++- src/Appwrite/Platform/Workers/Certificates.php | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Certificates/LetsEncrypt.php b/src/Appwrite/Certificates/LetsEncrypt.php index 3896eab022..5192b2a3f9 100644 --- a/src/Appwrite/Certificates/LetsEncrypt.php +++ b/src/Appwrite/Certificates/LetsEncrypt.php @@ -34,7 +34,11 @@ class LetsEncrypt implements Adapter $stdout, $stderr ); - + var_dump([ + 'location' => 'issueCertificate.1', + 'certificate' => "certbot certonly -v --webroot --noninteractive --agree-tos$staging --email {$this->email} --cert-name $certName -w ".APP_STORAGE_CERTIFICATES." -d $domain", + 'result' => $exit, + ]); // Unexpected error, usually 5XX, API limits, ... if ($exit !== 0) { throw new Exception('Failed to issue a certificate with message: ' . $stderr); @@ -71,7 +75,13 @@ class LetsEncrypt implements Adapter " - certFile: /storage/certificates/{$domain}/fullchain.pem", " keyFile: /storage/certificates/{$domain}/privkey.pem" ]); + var_dump([ + 'location' => 'issueCertificate.2', + 'config' => $config, + 'path' => APP_STORAGE_CONFIG . '/' . $domain . '.yml', + 'file_put_contents' => file_put_contents(APP_STORAGE_CONFIG . '/' . $domain . '.yml', $config), + ]); // Save configuration into Traefik using our new cert files if (!\file_put_contents(APP_STORAGE_CONFIG . '/' . $domain . '.yml', $config)) { throw new Exception('Failed to save Traefik configuration.'); diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 7e220b2734..c92113dda0 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -136,6 +136,11 @@ class Certificates extends Action $certificate->setAttribute('domain', $domain->get()); } + var_dump([ + 'location' => 'execute.1', + 'certificate' => $certificate + ]); + $success = false; try { @@ -184,6 +189,10 @@ class Certificates extends Action } finally { // All actions result in new updatedAt date $certificate->setAttribute('updated', DateTime::now()); + var_dump([ + 'location' => 'execute.2', + 'certificate' => $certificate + ]); // Save all changes we made to certificate document into database $this->saveCertificateDocument($domain->get(), $certificate, $success, $dbForPlatform, $queueForEvents, $queueForFunctions); From 69e9a1bd8cb6b6310bd2efd0289253978bf7754e Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 25 Feb 2025 17:42:36 +0200 Subject: [PATCH 232/279] debug cert --- src/Appwrite/Event/Event.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 0edffdf4dc..47c876f72f 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -360,6 +360,10 @@ class Event // Merge the base payload with any trimmed values $payload = array_merge($this->preparePayload(), $this->trimPayload()); + var_dump([ + 'queue' => $this->getQueue(), + 'payload' => $payload, + ]); return $this->publisher->enqueue($queue, $payload); } From e2b9c64f9150bf5b9f6d45abe27f7b58b4358dfc Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 25 Feb 2025 18:01:30 +0200 Subject: [PATCH 233/279] debug cert --- src/Appwrite/Event/Event.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 47c876f72f..5d0c360f41 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -351,6 +351,7 @@ class Event */ public function trigger(): string|bool { + var_dump('in trigger'); if ($this->paused) { return false; } From f48791fba6a032138fa9e87653e1c42b61e27412 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 26 Feb 2025 15:53:04 +0200 Subject: [PATCH 234/279] debug cert --- src/Appwrite/Certificates/LetsEncrypt.php | 12 +----------- src/Appwrite/Event/Event.php | 7 ++----- src/Appwrite/Platform/Workers/Certificates.php | 9 --------- src/Appwrite/Platform/Workers/StatsResources.php | 1 - src/Appwrite/Platform/Workers/Usage.php | 1 - 5 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/Appwrite/Certificates/LetsEncrypt.php b/src/Appwrite/Certificates/LetsEncrypt.php index 5192b2a3f9..3896eab022 100644 --- a/src/Appwrite/Certificates/LetsEncrypt.php +++ b/src/Appwrite/Certificates/LetsEncrypt.php @@ -34,11 +34,7 @@ class LetsEncrypt implements Adapter $stdout, $stderr ); - var_dump([ - 'location' => 'issueCertificate.1', - 'certificate' => "certbot certonly -v --webroot --noninteractive --agree-tos$staging --email {$this->email} --cert-name $certName -w ".APP_STORAGE_CERTIFICATES." -d $domain", - 'result' => $exit, - ]); + // Unexpected error, usually 5XX, API limits, ... if ($exit !== 0) { throw new Exception('Failed to issue a certificate with message: ' . $stderr); @@ -75,13 +71,7 @@ class LetsEncrypt implements Adapter " - certFile: /storage/certificates/{$domain}/fullchain.pem", " keyFile: /storage/certificates/{$domain}/privkey.pem" ]); - var_dump([ - 'location' => 'issueCertificate.2', - 'config' => $config, - 'path' => APP_STORAGE_CONFIG . '/' . $domain . '.yml', - 'file_put_contents' => file_put_contents(APP_STORAGE_CONFIG . '/' . $domain . '.yml', $config), - ]); // Save configuration into Traefik using our new cert files if (!\file_put_contents(APP_STORAGE_CONFIG . '/' . $domain . '.yml', $config)) { throw new Exception('Failed to save Traefik configuration.'); diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 5d0c360f41..a00cc45159 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -351,7 +351,7 @@ class Event */ public function trigger(): string|bool { - var_dump('in trigger'); + if ($this->paused) { return false; } @@ -361,10 +361,7 @@ class Event // Merge the base payload with any trimmed values $payload = array_merge($this->preparePayload(), $this->trimPayload()); - var_dump([ - 'queue' => $this->getQueue(), - 'payload' => $payload, - ]); + return $this->publisher->enqueue($queue, $payload); } diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index c92113dda0..7e220b2734 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -136,11 +136,6 @@ class Certificates extends Action $certificate->setAttribute('domain', $domain->get()); } - var_dump([ - 'location' => 'execute.1', - 'certificate' => $certificate - ]); - $success = false; try { @@ -189,10 +184,6 @@ class Certificates extends Action } finally { // All actions result in new updatedAt date $certificate->setAttribute('updated', DateTime::now()); - var_dump([ - 'location' => 'execute.2', - 'certificate' => $certificate - ]); // Save all changes we made to certificate document into database $this->saveCertificateDocument($domain->get(), $certificate, $success, $dbForPlatform, $queueForEvents, $queueForFunctions); diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index a6101522fb..f3c9cbddee 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -70,7 +70,6 @@ class StatsResources extends Action } if (empty($project->getAttribute('database'))) { - var_dump($payload); return; } diff --git a/src/Appwrite/Platform/Workers/Usage.php b/src/Appwrite/Platform/Workers/Usage.php index 3687eeab67..af2a98fab4 100644 --- a/src/Appwrite/Platform/Workers/Usage.php +++ b/src/Appwrite/Platform/Workers/Usage.php @@ -63,7 +63,6 @@ class Usage extends Action if (empty($project->getAttribute('database'))) { - var_dump($payload); return; } From 369caae87dd275902b5359e7ff61e5c9aa2c1f95 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 26 Feb 2025 17:40:06 +0200 Subject: [PATCH 235/279] debug cert --- app/controllers/general.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 2230c99e2c..12a8bbb1b0 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -591,7 +591,10 @@ App::init() Query::equal('domain', [$domain->get()]) ]); } - + var_dump([ + 'location' => 'general.php.1', + 'domainDocument' => $domainDocument + ]); if ($domainDocument->isEmpty()) { $domainDocument = new Document([ // TODO: @christyjacob remove once we migrate the rules in 1.7.x @@ -602,7 +605,10 @@ App::init() 'projectId' => 'console', 'projectInternalId' => 'console' ]); - + var_dump([ + 'location' => 'general.php.2', + 'domainDocument' => $domainDocument + ]); $domainDocument = $dbForPlatform->createDocument('rules', $domainDocument); Console::info('Issuing a TLS certificate for the main domain (' . $domain->get() . ') in a few seconds...'); From 458df237979e97be2473eaeefa9cbb6515a8c92a Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 26 Feb 2025 17:41:44 +0200 Subject: [PATCH 236/279] debug cert --- app/controllers/general.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index 12a8bbb1b0..afc5ac7bba 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -595,6 +595,7 @@ App::init() 'location' => 'general.php.1', 'domainDocument' => $domainDocument ]); + if ($domainDocument->isEmpty()) { $domainDocument = new Document([ // TODO: @christyjacob remove once we migrate the rules in 1.7.x @@ -605,6 +606,7 @@ App::init() 'projectId' => 'console', 'projectInternalId' => 'console' ]); + var_dump([ 'location' => 'general.php.2', 'domainDocument' => $domainDocument From 12f274223f73ccabc2d9c09c5cb9a4981eeae795 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 27 Feb 2025 10:31:47 +0200 Subject: [PATCH 237/279] sync against 1.6.x --- composer.lock | 618 ++++++++++++-------------------------------------- 1 file changed, 141 insertions(+), 477 deletions(-) diff --git a/composer.lock b/composer.lock index ea7382e3da..550a82489b 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": "ed36bf1392e79d1b1bb07fb2a81f03bf", + "content-hash": "d7e31cf9078e9fb785aa196e5575cf74", "packages": [ { "name": "adhocore/jwt", @@ -279,16 +279,16 @@ }, { "name": "brick/math", - "version": "0.12.1", + "version": "0.12.2", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "f510c0a40911935b77b86859eb5223d58d660df1" + "reference": "901eddb1e45a8e0f689302e40af871c181ecbe40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/f510c0a40911935b77b86859eb5223d58d660df1", - "reference": "f510c0a40911935b77b86859eb5223d58d660df1", + "url": "https://api.github.com/repos/brick/math/zipball/901eddb1e45a8e0f689302e40af871c181ecbe40", + "reference": "901eddb1e45a8e0f689302e40af871c181ecbe40", "shasum": "" }, "require": { @@ -297,7 +297,7 @@ "require-dev": { "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^10.1", - "vimeo/psalm": "5.16.0" + "vimeo/psalm": "6.8.8" }, "type": "library", "autoload": { @@ -327,7 +327,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.12.1" + "source": "https://github.com/brick/math/tree/0.12.2" }, "funding": [ { @@ -335,7 +335,7 @@ "type": "github" } ], - "time": "2023-11-29T23:19:16+00:00" + "time": "2025-02-26T10:21:45+00:00" }, { "name": "chillerlan/php-qrcode", @@ -1757,16 +1757,16 @@ }, { "name": "php-amqplib/php-amqplib", - "version": "v3.7.2", + "version": "v3.7.3", "source": { "type": "git", "url": "https://github.com/php-amqplib/php-amqplib.git", - "reference": "738a73eb0019b6c99d9bc25d7a0c0dd8f56a5199" + "reference": "9f50fe69a9f1a19e2cb25596a354d705de36fe59" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/738a73eb0019b6c99d9bc25d7a0c0dd8f56a5199", - "reference": "738a73eb0019b6c99d9bc25d7a0c0dd8f56a5199", + "url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/9f50fe69a9f1a19e2cb25596a354d705de36fe59", + "reference": "9f50fe69a9f1a19e2cb25596a354d705de36fe59", "shasum": "" }, "require": { @@ -1832,9 +1832,9 @@ ], "support": { "issues": "https://github.com/php-amqplib/php-amqplib/issues", - "source": "https://github.com/php-amqplib/php-amqplib/tree/v3.7.2" + "source": "https://github.com/php-amqplib/php-amqplib/tree/v3.7.3" }, - "time": "2024-11-21T09:21:41+00:00" + "time": "2025-02-18T20:11:13+00:00" }, { "name": "php-http/discovery", @@ -2694,16 +2694,16 @@ }, { "name": "symfony/http-client", - "version": "v7.2.3", + "version": "v7.2.4", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "7ce6078c79a4a7afff931c413d2959d3bffbfb8d" + "reference": "78981a2ffef6437ed92d4d7e2a86a82f256c6dc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/7ce6078c79a4a7afff931c413d2959d3bffbfb8d", - "reference": "7ce6078c79a4a7afff931c413d2959d3bffbfb8d", + "url": "https://api.github.com/repos/symfony/http-client/zipball/78981a2ffef6437ed92d4d7e2a86a82f256c6dc6", + "reference": "78981a2ffef6437ed92d4d7e2a86a82f256c6dc6", "shasum": "" }, "require": { @@ -2769,7 +2769,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.2.3" + "source": "https://github.com/symfony/http-client/tree/v7.2.4" }, "funding": [ { @@ -2785,7 +2785,7 @@ "type": "tidelift" } ], - "time": "2025-01-28T15:51:35+00:00" + "time": "2025-02-13T10:27:23+00:00" }, { "name": "symfony/http-client-contracts", @@ -3377,16 +3377,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.50.0", + "version": "0.51.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "3ff67819e9de61506c5ca070a70552f7ebe99f80" + "reference": "661687b03277f1d202a0e8cf9da6e58c97da2b5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/3ff67819e9de61506c5ca070a70552f7ebe99f80", - "reference": "3ff67819e9de61506c5ca070a70552f7ebe99f80", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/661687b03277f1d202a0e8cf9da6e58c97da2b5e", + "reference": "661687b03277f1d202a0e8cf9da6e58c97da2b5e", "shasum": "" }, "require": { @@ -3394,7 +3394,7 @@ "ext-pdo": "*", "ext-redis": "*", "php": ">=8.0", - "utopia-php/database": "0.59.*" + "utopia-php/database": "0.60.*" }, "require-dev": { "laravel/pint": "1.*", @@ -3422,9 +3422,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.50.0" + "source": "https://github.com/utopia-php/abuse/tree/0.51.0" }, - "time": "2025-02-12T09:13:59+00:00" + "time": "2025-02-17T11:10:18+00:00" }, { "name": "utopia-php/analytics", @@ -3474,21 +3474,21 @@ }, { "name": "utopia-php/audit", - "version": "0.51.0", + "version": "0.54.0", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "a5a4b73a57e27a0fac8025b1d6038e145a1ca04e" + "reference": "1b0cb8ac6bfbd7703e3f9a753c6ba59ff1c39975" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/a5a4b73a57e27a0fac8025b1d6038e145a1ca04e", - "reference": "a5a4b73a57e27a0fac8025b1d6038e145a1ca04e", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/1b0cb8ac6bfbd7703e3f9a753c6ba59ff1c39975", + "reference": "1b0cb8ac6bfbd7703e3f9a753c6ba59ff1c39975", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "0.59.*" + "utopia-php/database": "0.60.*" }, "require-dev": { "laravel/pint": "1.*", @@ -3515,9 +3515,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.51.0" + "source": "https://github.com/utopia-php/audit/tree/0.54.0" }, - "time": "2025-02-12T09:12:44+00:00" + "time": "2025-02-25T07:21:07+00:00" }, { "name": "utopia-php/cache", @@ -3717,16 +3717,16 @@ }, { "name": "utopia-php/database", - "version": "0.59.0", + "version": "0.60.3", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "0eed7f1ad3eb66ff4a7d73b68dd9d3e05089eb18" + "reference": "c4bc4af3f09a91aea76aac75b4b78fa06598c61d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/0eed7f1ad3eb66ff4a7d73b68dd9d3e05089eb18", - "reference": "0eed7f1ad3eb66ff4a7d73b68dd9d3e05089eb18", + "url": "https://api.github.com/repos/utopia-php/database/zipball/c4bc4af3f09a91aea76aac75b4b78fa06598c61d", + "reference": "c4bc4af3f09a91aea76aac75b4b78fa06598c61d", "shasum": "" }, "require": { @@ -3767,9 +3767,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.59.0" + "source": "https://github.com/utopia-php/database/tree/0.60.3" }, - "time": "2025-02-12T08:08:29+00:00" + "time": "2025-02-17T12:46:59+00:00" }, { "name": "utopia-php/domains", @@ -3919,16 +3919,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.16", + "version": "0.33.17", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "e91d4c560d1b809e25faa63d564fef034363b50f" + "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/e91d4c560d1b809e25faa63d564fef034363b50f", - "reference": "e91d4c560d1b809e25faa63d564fef034363b50f", + "url": "https://api.github.com/repos/utopia-php/http/zipball/73fac6fbce9f56282dba4e52a58cf836ec434644", + "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644", "shasum": "" }, "require": { @@ -3960,31 +3960,32 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.16" + "source": "https://github.com/utopia-php/http/tree/0.33.17" }, - "time": "2025-01-16T15:58:50+00:00" + "time": "2025-02-24T17:35:48+00:00" }, { "name": "utopia-php/image", - "version": "0.7.0", + "version": "0.8.0", "source": { "type": "git", "url": "https://github.com/utopia-php/image.git", - "reference": "fcea143edbad524bf871ddbebe801d981f91f181" + "reference": "dcae5b1c6deb3ff6865f4e68f012b3709c289bca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/image/zipball/fcea143edbad524bf871ddbebe801d981f91f181", - "reference": "fcea143edbad524bf871ddbebe801d981f91f181", + "url": "https://api.github.com/repos/utopia-php/image/zipball/dcae5b1c6deb3ff6865f4e68f012b3709c289bca", + "reference": "dcae5b1c6deb3ff6865f4e68f012b3709c289bca", "shasum": "" }, "require": { + "ext-gd": "*", "ext-imagick": "*", "php": ">=8.1" }, "require-dev": { "laravel/pint": "1.2.*", - "phpstan/phpstan": "1.9.x-dev", + "phpstan/phpstan": "^1.10.0", "phpunit/phpunit": "^9.3", "vimeo/psalm": "4.13.1" }, @@ -4008,9 +4009,9 @@ ], "support": { "issues": "https://github.com/utopia-php/image/issues", - "source": "https://github.com/utopia-php/image/tree/0.7.0" + "source": "https://github.com/utopia-php/image/tree/0.8.0" }, - "time": "2024-10-02T05:45:38+00:00" + "time": "2025-02-20T11:49:03+00:00" }, { "name": "utopia-php/locale", @@ -4119,16 +4120,16 @@ }, { "name": "utopia-php/messaging", - "version": "0.14.1", + "version": "0.16.0", "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "4ba356a3aa382802727f7e13e0f0152bcc1fc535" + "reference": "5f3083697102b1821d6624938186761b1e09c54e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/4ba356a3aa382802727f7e13e0f0152bcc1fc535", - "reference": "4ba356a3aa382802727f7e13e0f0152bcc1fc535", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/5f3083697102b1821d6624938186761b1e09c54e", + "reference": "5f3083697102b1821d6624938186761b1e09c54e", "shasum": "" }, "require": { @@ -4164,22 +4165,22 @@ ], "support": { "issues": "https://github.com/utopia-php/messaging/issues", - "source": "https://github.com/utopia-php/messaging/tree/0.14.1" + "source": "https://github.com/utopia-php/messaging/tree/0.16.0" }, - "time": "2025-01-28T06:14:28+00:00" + "time": "2025-02-18T08:27:00+00:00" }, { "name": "utopia-php/migration", - "version": "0.6.19", + "version": "0.6.20", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "3c9497f7a54ef88b1077c48d8326893133ad78eb" + "reference": "8c9ba52196f50aaef4aa1903f0d8fe0c8d9997ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/3c9497f7a54ef88b1077c48d8326893133ad78eb", - "reference": "3c9497f7a54ef88b1077c48d8326893133ad78eb", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/8c9ba52196f50aaef4aa1903f0d8fe0c8d9997ba", + "reference": "8c9ba52196f50aaef4aa1903f0d8fe0c8d9997ba", "shasum": "" }, "require": { @@ -4187,7 +4188,7 @@ "ext-curl": "*", "ext-openssl": "*", "php": ">=8.1", - "utopia-php/database": "0.59.*", + "utopia-php/database": "0.60.*", "utopia-php/dsn": "0.2.*", "utopia-php/framework": "0.33.*", "utopia-php/storage": "0.18.*" @@ -4220,9 +4221,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.19" + "source": "https://github.com/utopia-php/migration/tree/0.6.20" }, - "time": "2025-02-13T07:50:21+00:00" + "time": "2025-02-17T11:02:15+00:00" }, { "name": "utopia-php/mongo", @@ -5051,16 +5052,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.32", + "version": "0.40.1", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "2d02e1305ea5004fb0aec6b2618d6c597659b75c" + "reference": "df180676b6fbde7832ae1495af3e2f3e8f700837" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/2d02e1305ea5004fb0aec6b2618d6c597659b75c", - "reference": "2d02e1305ea5004fb0aec6b2618d6c597659b75c", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/df180676b6fbde7832ae1495af3e2f3e8f700837", + "reference": "df180676b6fbde7832ae1495af3e2f3e8f700837", "shasum": "" }, "require": { @@ -5096,9 +5097,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.32" + "source": "https://github.com/appwrite/sdk-generator/tree/0.40.1" }, - "time": "2025-01-29T04:04:19+00:00" + "time": "2025-02-26T07:07:10+00:00" }, { "name": "doctrine/annotations", @@ -5176,77 +5177,32 @@ }, "time": "2024-09-05T10:17:24+00:00" }, - { - "name": "doctrine/deprecations", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/doctrine/deprecations.git", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9 || ^12", - "phpstan/phpstan": "1.4.10 || 2.0.3", - "phpstan/phpstan-phpunit": "^1.0 || ^2", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psr/log": "^1 || ^2 || ^3" - }, - "suggest": { - "psr/log": "Allows logging deprecations via PSR-3 logger implementation" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Deprecations\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", - "support": { - "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.4" - }, - "time": "2024-12-07T21:18:45+00:00" - }, { "name": "doctrine/instantiator", - "version": "1.5.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^11", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.30 || ^5.4" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -5273,7 +5229,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -5289,7 +5245,7 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:15:36+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "doctrine/lexer", @@ -5370,16 +5326,16 @@ }, { "name": "laravel/pint", - "version": "v1.20.0", + "version": "v1.21.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b" + "reference": "531fa0871fbde719c51b12afa3a443b8f4e4b425" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/53072e8ea22213a7ed168a8a15b96fbb8b82d44b", - "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b", + "url": "https://api.github.com/repos/laravel/pint/zipball/531fa0871fbde719c51b12afa3a443b8f4e4b425", + "reference": "531fa0871fbde719c51b12afa3a443b8f4e4b425", "shasum": "" }, "require": { @@ -5387,15 +5343,15 @@ "ext-mbstring": "*", "ext-tokenizer": "*", "ext-xml": "*", - "php": "^8.1.0" + "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.66.0", - "illuminate/view": "^10.48.25", - "larastan/larastan": "^2.9.12", - "laravel-zero/framework": "^10.48.25", + "friendsofphp/php-cs-fixer": "^3.68.5", + "illuminate/view": "^11.42.0", + "larastan/larastan": "^3.0.4", + "laravel-zero/framework": "^11.36.1", "mockery/mockery": "^1.6.12", - "nunomaduro/termwind": "^1.17.0", + "nunomaduro/termwind": "^2.3", "pestphp/pest": "^2.36.0" }, "bin": [ @@ -5432,7 +5388,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2025-01-14T16:20:53+00:00" + "time": "2025-02-18T03:18:57+00:00" }, { "name": "matthiasmullie/minify", @@ -5943,298 +5899,6 @@ ], "time": "2025-01-26T19:54:45+00:00" }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.6.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", - "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", - "shasum": "" - }, - "require": { - "doctrine/deprecations": "^1.1", - "ext-filter": "*", - "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.7", - "phpstan/phpdoc-parser": "^1.7|^2.0", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "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", - "psalm/phar": "^5.26" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "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.6.1" - }, - "time": "2024-12-07T09:39:29+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a", - "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a", - "shasum": "" - }, - "require": { - "doctrine/deprecations": "^1.0", - "php": "^7.3 || ^8.0", - "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.18|^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "phpbench/phpbench": "^1.2", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-phpunit": "^1.1", - "phpunit/phpunit": "^9.5", - "rector/rector": "^0.13.9", - "vimeo/psalm": "^4.25" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "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.10.0" - }, - "time": "2024-11-09T15:12:26+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.20.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "a0165c648cab6a80311c74ffc708a07bb53ecc93" - }, - "dist": { - "type": "zip", - "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.* || 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" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "dev", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.20.0" - }, - "time": "2024-11-19T13:12:41+00:00" - }, - { - "name": "phpstan/phpdoc-parser", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "72e51f7c32c5aef7c8b462195b8c599b11199893" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/72e51f7c32c5aef7c8b462195b8c599b11199893", - "reference": "72e51f7c32c5aef7c8b462195b8c599b11199893", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0" - }, - "require-dev": { - "doctrine/annotations": "^2.0", - "nikic/php-parser": "^5.3.0", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/extension-installer": "^1.0", - "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", - "autoload": { - "psr-4": { - "PHPStan\\PhpDocParser\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "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/2.0.1" - }, - "time": "2025-02-13T12:25:43+00:00" - }, { "name": "phpunit/php-code-coverage", "version": "9.2.32", @@ -6556,55 +6220,50 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.20", + "version": "9.6.22", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "12bc8879fb65aef2138b26fc633cb1e3620cffba" + "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/12bc8879fb65aef2138b26fc633cb1e3620cffba", - "reference": "12bc8879fb65aef2138b26fc633cb1e3620cffba", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f80235cb4d3caa59ae09be3adf1ded27521d1a9c", + "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.1", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.13", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.0", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, - "require-dev": { - "ext-pdo": "*", - "phpspec/prophecy-phpunit": "^2.0.1" - }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -6612,7 +6271,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.5-dev" + "dev-master": "9.6-dev" } }, "autoload": { @@ -6643,7 +6302,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.20" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.22" }, "funding": [ { @@ -6653,9 +6313,13 @@ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "time": "2022-04-01T12:37:26+00:00" + "time": "2024-12-05T13:48:26+00:00" }, { "name": "psr/cache", @@ -8371,16 +8035,16 @@ }, { "name": "symfony/process", - "version": "v7.2.0", + "version": "v7.2.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e" + "reference": "d8f411ff3c7ddc4ae9166fb388d1190a2df5b5cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/d34b22ba9390ec19d2dd966c40aa9e8462f27a7e", - "reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e", + "url": "https://api.github.com/repos/symfony/process/zipball/d8f411ff3c7ddc4ae9166fb388d1190a2df5b5cf", + "reference": "d8f411ff3c7ddc4ae9166fb388d1190a2df5b5cf", "shasum": "" }, "require": { @@ -8412,7 +8076,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.2.0" + "source": "https://github.com/symfony/process/tree/v7.2.4" }, "funding": [ { @@ -8428,7 +8092,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T14:24:19+00:00" + "time": "2025-02-05T08:33:46+00:00" }, { "name": "symfony/string", @@ -8519,16 +8183,16 @@ }, { "name": "textalk/websocket", - "version": "1.5.7", + "version": "1.5.8", "source": { "type": "git", "url": "https://github.com/Textalk/websocket-php.git", - "reference": "1712325e99b6bf869ccbf9bf41ab749e7328ea46" + "reference": "d05dbaa97500176447ffb1f1800573f23085ab13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Textalk/websocket-php/zipball/1712325e99b6bf869ccbf9bf41ab749e7328ea46", - "reference": "1712325e99b6bf869ccbf9bf41ab749e7328ea46", + "url": "https://api.github.com/repos/Textalk/websocket-php/zipball/d05dbaa97500176447ffb1f1800573f23085ab13", + "reference": "d05dbaa97500176447ffb1f1800573f23085ab13", "shasum": "" }, "require": { @@ -8562,9 +8226,9 @@ "description": "WebSocket client and server", "support": { "issues": "https://github.com/Textalk/websocket-php/issues", - "source": "https://github.com/Textalk/websocket-php/tree/1.5.7" + "source": "https://github.com/Textalk/websocket-php/tree/1.5.8" }, - "time": "2022-03-29T09:46:59+00:00" + "time": "2022-04-26T06:28:24+00:00" }, { "name": "theseer/tokenizer", From 5ed1ca617fa34e11fcec92fcc14c84361176e99e Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 27 Feb 2025 11:02:27 +0200 Subject: [PATCH 238/279] cleanup --- app/controllers/general.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 1e57830d25..9c7a07e970 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -591,10 +591,6 @@ App::init() Query::equal('domain', [$domain->get()]) ]); } - var_dump([ - 'location' => 'general.php.1', - 'domainDocument' => $domainDocument - ]); if ($domainDocument->isEmpty()) { $domainDocument = new Document([ @@ -607,10 +603,6 @@ App::init() 'projectInternalId' => 'console' ]); - var_dump([ - 'location' => 'general.php.2', - 'domainDocument' => $domainDocument - ]); $domainDocument = $dbForPlatform->createDocument('rules', $domainDocument); Console::info('Issuing a TLS certificate for the main domain (' . $domain->get() . ') in a few seconds...'); From 921b9154ebc6c49538ad2ae7db4488409310f8b4 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 2 Mar 2025 20:56:28 +0200 Subject: [PATCH 239/279] debug --- src/Appwrite/Platform/Workers/Webhooks.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index c903dafdae..0f86861f1e 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -54,6 +54,12 @@ class Webhooks extends Action $this->errors = []; $payload = $message->getPayload() ?? []; + var_dump([ + 'id' => $project->getId(), + 'region' => $project->getAttribute('region'), + + ]); + if (empty($payload)) { throw new Exception('Missing payload'); } From 52a73856bc82e62d39f4e12fca39fad512e1f5e6 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 2 Mar 2025 21:19:45 +0200 Subject: [PATCH 240/279] debug --- src/Appwrite/Platform/Workers/Webhooks.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index 0f86861f1e..e7843ffc20 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -54,16 +54,12 @@ class Webhooks extends Action $this->errors = []; $payload = $message->getPayload() ?? []; - var_dump([ - 'id' => $project->getId(), - 'region' => $project->getAttribute('region'), - ]); if (empty($payload)) { throw new Exception('Missing payload'); } - + var_dump($project); $events = $payload['events']; $webhookPayload = json_encode($payload['payload']); $user = new Document($payload['user'] ?? []); From adb451234b3fea780c74480cff2b1ffc20390133 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 2 Mar 2025 22:27:13 +0200 Subject: [PATCH 241/279] debug --- src/Appwrite/Platform/Workers/Webhooks.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index e7843ffc20..ab6e1e6270 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -60,6 +60,7 @@ class Webhooks extends Action throw new Exception('Missing payload'); } var_dump($project); + $events = $payload['events']; $webhookPayload = json_encode($payload['payload']); $user = new Document($payload['user'] ?? []); From 12eb3b4eea15b33db0ed2e35ecf241b9679ee9bb Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 3 Mar 2025 10:47:28 +0200 Subject: [PATCH 242/279] debug --- src/Appwrite/Platform/Workers/Webhooks.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index ab6e1e6270..578e14a61b 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -59,7 +59,12 @@ class Webhooks extends Action if (empty($payload)) { throw new Exception('Missing payload'); } - var_dump($project); + var_dump([ + 'id' => $project->getId(), + 'webhooks' => $project->getAttribute('webhooks'), + 'region' => $project->getAttribute('region'), + ] + ); $events = $payload['events']; $webhookPayload = json_encode($payload['payload']); From f0477f894009e9f6ef69e7a763e95cfeb89dba0b Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 5 Mar 2025 17:30:59 +0200 Subject: [PATCH 243/279] sync with 1.6.x --- composer.lock | 77 +++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/composer.lock b/composer.lock index 550a82489b..869d8e933b 100644 --- a/composer.lock +++ b/composer.lock @@ -279,16 +279,16 @@ }, { "name": "brick/math", - "version": "0.12.2", + "version": "0.12.3", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "901eddb1e45a8e0f689302e40af871c181ecbe40" + "reference": "866551da34e9a618e64a819ee1e01c20d8a588ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/901eddb1e45a8e0f689302e40af871c181ecbe40", - "reference": "901eddb1e45a8e0f689302e40af871c181ecbe40", + "url": "https://api.github.com/repos/brick/math/zipball/866551da34e9a618e64a819ee1e01c20d8a588ba", + "reference": "866551da34e9a618e64a819ee1e01c20d8a588ba", "shasum": "" }, "require": { @@ -327,7 +327,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.12.2" + "source": "https://github.com/brick/math/tree/0.12.3" }, "funding": [ { @@ -335,7 +335,7 @@ "type": "github" } ], - "time": "2025-02-26T10:21:45+00:00" + "time": "2025-02-28T13:11:00+00:00" }, { "name": "chillerlan/php-qrcode", @@ -709,16 +709,16 @@ }, { "name": "google/protobuf", - "version": "v4.29.3", + "version": "v4.30.0", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "ab5077c2cfdd1f415f42d11fdbdf903ba8e3d9b7" + "reference": "e1d66682f6836aa87820400f0aa07d9eb566feb6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/ab5077c2cfdd1f415f42d11fdbdf903ba8e3d9b7", - "reference": "ab5077c2cfdd1f415f42d11fdbdf903ba8e3d9b7", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/e1d66682f6836aa87820400f0aa07d9eb566feb6", + "reference": "e1d66682f6836aa87820400f0aa07d9eb566feb6", "shasum": "" }, "require": { @@ -747,9 +747,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.3" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.30.0" }, - "time": "2025-01-08T21:00:13+00:00" + "time": "2025-03-04T22:54:49+00:00" }, { "name": "jean85/pretty-package-versions", @@ -2371,16 +2371,16 @@ }, { "name": "ramsey/collection", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/ramsey/collection.git", - "reference": "a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5" + "reference": "3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5", - "reference": "a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5", + "url": "https://api.github.com/repos/ramsey/collection/zipball/3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109", + "reference": "3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109", "shasum": "" }, "require": { @@ -2388,25 +2388,22 @@ }, "require-dev": { "captainhook/plugin-composer": "^5.3", - "ergebnis/composer-normalize": "^2.28.3", - "fakerphp/faker": "^1.21", + "ergebnis/composer-normalize": "^2.45", + "fakerphp/faker": "^1.24", "hamcrest/hamcrest-php": "^2.0", - "jangregor/phpstan-prophecy": "^1.0", - "mockery/mockery": "^1.5", + "jangregor/phpstan-prophecy": "^2.1", + "mockery/mockery": "^1.6", "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" + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpspec/prophecy-phpunit": "^2.3", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-mockery": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^10.5", + "ramsey/coding-standard": "^2.3", + "ramsey/conventional-commits": "^1.6", + "roave/security-advisories": "dev-latest" }, "type": "library", "extra": { @@ -2444,19 +2441,9 @@ ], "support": { "issues": "https://github.com/ramsey/collection/issues", - "source": "https://github.com/ramsey/collection/tree/2.0.0" + "source": "https://github.com/ramsey/collection/tree/2.1.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" + "time": "2025-03-02T04:48:29+00:00" }, { "name": "ramsey/uuid", From 7c91157dc82de709fb7c9abc1a9d25f444693cdf Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 6 Mar 2025 12:10:10 +0200 Subject: [PATCH 244/279] sync with 1.6.x --- composer.lock | 48 +++++++++++----------- src/Appwrite/Platform/Workers/Webhooks.php | 6 --- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/composer.lock b/composer.lock index 869d8e933b..cb00efad67 100644 --- a/composer.lock +++ b/composer.lock @@ -1237,16 +1237,16 @@ }, { "name": "open-telemetry/api", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/api.git", - "reference": "8b925df3047628968bc5be722468db1b98b82d51" + "reference": "199d7ddda88f5f5619fa73463f1a5a7149ccd1f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/8b925df3047628968bc5be722468db1b98b82d51", - "reference": "8b925df3047628968bc5be722468db1b98b82d51", + "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/199d7ddda88f5f5619fa73463f1a5a7149ccd1f1", + "reference": "199d7ddda88f5f5619fa73463f1a5a7149ccd1f1", "shasum": "" }, "require": { @@ -1303,7 +1303,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2025-02-03T21:49:11+00:00" + "time": "2025-03-05T21:42:54+00:00" }, { "name": "open-telemetry/context", @@ -3867,16 +3867,16 @@ }, { "name": "utopia-php/fetch", - "version": "0.3.0", + "version": "0.3.1", "source": { "type": "git", "url": "https://github.com/utopia-php/fetch.git", - "reference": "02b12c05aec13399dcc2da8d51f908e328ab63f4" + "reference": "524dd50afa8c64670c4fb18f1df4db9b5bb4b3d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/fetch/zipball/02b12c05aec13399dcc2da8d51f908e328ab63f4", - "reference": "02b12c05aec13399dcc2da8d51f908e328ab63f4", + "url": "https://api.github.com/repos/utopia-php/fetch/zipball/524dd50afa8c64670c4fb18f1df4db9b5bb4b3d0", + "reference": "524dd50afa8c64670c4fb18f1df4db9b5bb4b3d0", "shasum": "" }, "require": { @@ -3900,22 +3900,22 @@ "description": "A simple library that provides an interface for making HTTP Requests.", "support": { "issues": "https://github.com/utopia-php/fetch/issues", - "source": "https://github.com/utopia-php/fetch/tree/0.3.0" + "source": "https://github.com/utopia-php/fetch/tree/0.3.1" }, - "time": "2025-01-17T06:11:10+00:00" + "time": "2025-03-05T18:08:55+00:00" }, { "name": "utopia-php/framework", - "version": "0.33.17", + "version": "0.33.18", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644" + "reference": "00b3743264973a7e6e7bfef0c61ecb15b855036b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/73fac6fbce9f56282dba4e52a58cf836ec434644", - "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644", + "url": "https://api.github.com/repos/utopia-php/http/zipball/00b3743264973a7e6e7bfef0c61ecb15b855036b", + "reference": "00b3743264973a7e6e7bfef0c61ecb15b855036b", "shasum": "" }, "require": { @@ -3947,9 +3947,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.17" + "source": "https://github.com/utopia-php/http/tree/0.33.18" }, - "time": "2025-02-24T17:35:48+00:00" + "time": "2025-03-06T08:30:11+00:00" }, { "name": "utopia-php/image", @@ -4595,22 +4595,24 @@ }, { "name": "utopia-php/storage", - "version": "0.18.9", + "version": "0.18.10", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "1cf455404e8700b3093fd73d74a38d41cdced90c" + "reference": "76f31158f4251abb207f7a9b16f7cb0bfdb3b39e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/1cf455404e8700b3093fd73d74a38d41cdced90c", - "reference": "1cf455404e8700b3093fd73d74a38d41cdced90c", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/76f31158f4251abb207f7a9b16f7cb0bfdb3b39e", + "reference": "76f31158f4251abb207f7a9b16f7cb0bfdb3b39e", "shasum": "" }, "require": { "ext-brotli": "*", + "ext-curl": "*", "ext-fileinfo": "*", "ext-lz4": "*", + "ext-simplexml": "*", "ext-snappy": "*", "ext-xz": "*", "ext-zlib": "*", @@ -4644,9 +4646,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.9" + "source": "https://github.com/utopia-php/storage/tree/0.18.10" }, - "time": "2025-02-11T13:10:40+00:00" + "time": "2025-03-03T10:47:54+00:00" }, { "name": "utopia-php/swoole", diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index 578e14a61b..44e8bd3118 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -59,12 +59,6 @@ class Webhooks extends Action if (empty($payload)) { throw new Exception('Missing payload'); } - var_dump([ - 'id' => $project->getId(), - 'webhooks' => $project->getAttribute('webhooks'), - 'region' => $project->getAttribute('region'), - ] - ); $events = $payload['events']; $webhookPayload = json_encode($payload['payload']); From 1b3fe3046d8674418bc39be96ff58e9378150adc Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 6 Mar 2025 13:12:03 +0200 Subject: [PATCH 245/279] sync with 1.6.x --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 8257e6fd2a..307a279609 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "utopia-php/database": "0.60.*", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", - "utopia-php/framework": "0.33.*", + "utopia-php/framework": "0.33.17", "utopia-php/fetch": "0.3.*", "utopia-php/image": "0.8.*", "utopia-php/locale": "0.4.*", diff --git a/composer.lock b/composer.lock index cb00efad67..ee12bebe7a 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": "d7e31cf9078e9fb785aa196e5575cf74", + "content-hash": "a68743341adf549015be67fa5541b636", "packages": [ { "name": "adhocore/jwt", @@ -3906,16 +3906,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.18", + "version": "0.33.17", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "00b3743264973a7e6e7bfef0c61ecb15b855036b" + "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/00b3743264973a7e6e7bfef0c61ecb15b855036b", - "reference": "00b3743264973a7e6e7bfef0c61ecb15b855036b", + "url": "https://api.github.com/repos/utopia-php/http/zipball/73fac6fbce9f56282dba4e52a58cf836ec434644", + "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644", "shasum": "" }, "require": { @@ -3947,9 +3947,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.18" + "source": "https://github.com/utopia-php/http/tree/0.33.17" }, - "time": "2025-03-06T08:30:11+00:00" + "time": "2025-02-24T17:35:48+00:00" }, { "name": "utopia-php/image", From 0570567b2e5638f578cb832a05988d4a004d7836 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 9 Mar 2025 21:24:24 +0200 Subject: [PATCH 246/279] sync with 1.6.x --- composer.lock | 70 ++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/composer.lock b/composer.lock index ee12bebe7a..ad315eed89 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": "a68743341adf549015be67fa5541b636", + "content-hash": "9c60c30c8cc67a91164fb5a9bc427693", "packages": [ { "name": "adhocore/jwt", @@ -1366,16 +1366,16 @@ }, { "name": "open-telemetry/exporter-otlp", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/exporter-otlp.git", - "reference": "243d9657c44a06f740cf384f486afe954c2b725f" + "reference": "b7580440b7481a98da97aceabeb46e1b276c8747" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/exporter-otlp/zipball/243d9657c44a06f740cf384f486afe954c2b725f", - "reference": "243d9657c44a06f740cf384f486afe954c2b725f", + "url": "https://api.github.com/repos/opentelemetry-php/exporter-otlp/zipball/b7580440b7481a98da97aceabeb46e1b276c8747", + "reference": "b7580440b7481a98da97aceabeb46e1b276c8747", "shasum": "" }, "require": { @@ -1426,7 +1426,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2025-01-08T23:50:03+00:00" + "time": "2025-03-06T23:21:56+00:00" }, { "name": "open-telemetry/gen-otlp-protobuf", @@ -3508,23 +3508,24 @@ }, { "name": "utopia-php/cache", - "version": "0.11.0", + "version": "0.12.0", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "8ebcab5aac7606331cef69b0081f6c9eff2e58bc" + "reference": "646038f1d470b759c129348be8fc14da3c00bbd9" }, "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/646038f1d470b759c129348be8fc14da3c00bbd9", + "reference": "646038f1d470b759c129348be8fc14da3c00bbd9", "shasum": "" }, "require": { "ext-json": "*", "ext-memcached": "*", "ext-redis": "*", - "php": ">=8.0" + "php": ">=8.0", + "utopia-php/telemetry": "0.1.*" }, "require-dev": { "laravel/pint": "1.2.*", @@ -3552,9 +3553,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.12.0" }, - "time": "2024-11-05T16:53:58+00:00" + "time": "2025-02-25T09:09:21+00:00" }, { "name": "utopia-php/cli", @@ -3704,23 +3705,23 @@ }, { "name": "utopia-php/database", - "version": "0.60.3", + "version": "0.60.6", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "c4bc4af3f09a91aea76aac75b4b78fa06598c61d" + "reference": "f3c9aa964b39c6205069f038a26e709a15541406" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/c4bc4af3f09a91aea76aac75b4b78fa06598c61d", - "reference": "c4bc4af3f09a91aea76aac75b4b78fa06598c61d", + "url": "https://api.github.com/repos/utopia-php/database/zipball/f3c9aa964b39c6205069f038a26e709a15541406", + "reference": "f3c9aa964b39c6205069f038a26e709a15541406", "shasum": "" }, "require": { "ext-mbstring": "*", "ext-pdo": "*", "php": ">=8.1", - "utopia-php/cache": "0.11.*", + "utopia-php/cache": "0.12.*", "utopia-php/framework": "0.33.*", "utopia-php/mongo": "0.3.*" }, @@ -3754,9 +3755,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.60.3" + "source": "https://github.com/utopia-php/database/tree/0.60.6" }, - "time": "2025-02-17T12:46:59+00:00" + "time": "2025-03-05T01:23:14+00:00" }, { "name": "utopia-php/domains", @@ -4809,23 +4810,24 @@ }, { "name": "utopia-php/vcs", - "version": "0.8.6", + "version": "0.9.3", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "b10225f54d5670f09f83e82e09de9d820ada6931" + "reference": "865a00c67e81a20938b883f9aa802303790dd3b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/b10225f54d5670f09f83e82e09de9d820ada6931", - "reference": "b10225f54d5670f09f83e82e09de9d820ada6931", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/865a00c67e81a20938b883f9aa802303790dd3b5", + "reference": "865a00c67e81a20938b883f9aa802303790dd3b5", "shasum": "" }, "require": { "adhocore/jwt": "^1.1", "php": ">=8.0", - "utopia-php/cache": "^0.11.0", - "utopia-php/framework": "0.*.*" + "utopia-php/cache": "0.12.*", + "utopia-php/framework": "0.*.*", + "utopia-php/system": "0.9.*" }, "require-dev": { "laravel/pint": "1.2.*", @@ -4852,9 +4854,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.8.6" + "source": "https://github.com/utopia-php/vcs/tree/0.9.3" }, - "time": "2024-12-10T13:13:23+00:00" + "time": "2025-02-26T16:33:35+00:00" }, { "name": "utopia-php/websocket", @@ -5041,16 +5043,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.40.1", + "version": "0.40.2", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "df180676b6fbde7832ae1495af3e2f3e8f700837" + "reference": "56f09482d9e2f223911277ab887f197402708049" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/df180676b6fbde7832ae1495af3e2f3e8f700837", - "reference": "df180676b6fbde7832ae1495af3e2f3e8f700837", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/56f09482d9e2f223911277ab887f197402708049", + "reference": "56f09482d9e2f223911277ab887f197402708049", "shasum": "" }, "require": { @@ -5086,9 +5088,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.40.1" + "source": "https://github.com/appwrite/sdk-generator/tree/0.40.2" }, - "time": "2025-02-26T07:07:10+00:00" + "time": "2025-03-06T16:31:03+00:00" }, { "name": "doctrine/annotations", From 4b740dce86b929dc3a948e122fedee2f47a33ab2 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 11 Mar 2025 18:23:35 +0200 Subject: [PATCH 247/279] sync with 1.6.x --- app/init.php | 56 +++++++++++++++++++++++++++++++++++---------------- composer.lock | 28 +++++++++++++------------- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/app/init.php b/app/init.php index bc532da7ef..1311a1429f 100644 --- a/app/init.php +++ b/app/init.php @@ -347,7 +347,6 @@ Config::load('apis', __DIR__ . '/config/apis.php'); // List of APIs Config::load('errors', __DIR__ . '/config/errors.php'); Config::load('oAuthProviders', __DIR__ . '/config/oAuthProviders.php'); Config::load('platforms', __DIR__ . '/config/platforms.php'); -Config::load('console', __DIR__ . '/config/console.php'); Config::load('collections', __DIR__ . '/config/collections.php'); Config::load('runtimes', __DIR__ . '/config/runtimes.php'); Config::load('runtimes-v2', __DIR__ . '/config/runtimes-v2.php'); @@ -818,10 +817,6 @@ $register->set('logger', function () { $providerName = System::getEnv('_APP_LOGGING_PROVIDER', ''); $providerConfig = System::getEnv('_APP_LOGGING_CONFIG', ''); - if (empty($providerConfig)) { - return; - } - try { $loggingProvider = new DSN($providerConfig ?? ''); @@ -1384,17 +1379,6 @@ App::setResource('project', function ($dbForPlatform, $request, $console) { $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); - if (!empty($project->getAttribute('region')) && $project->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { - var_dump([ - 'x-projectId' => $projectId, - 'projectId' => $project->getId(), - 'projectRegion' => $project->getAttribute('region'), - '_APP_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; }, ['dbForPlatform', 'request', 'console']); @@ -1420,7 +1404,45 @@ App::setResource('session', function (Document $user) { }, ['user']); App::setResource('console', function () { - return new Document(Config::getParam('console')); + return new Document([ + '$id' => ID::custom('console'), + '$internalId' => ID::custom('console'), + 'name' => 'Appwrite', + '$collection' => ID::custom('projects'), + 'description' => 'Appwrite core engine', + 'logo' => '', + 'teamId' => null, + 'webhooks' => [], + 'keys' => [], + 'platforms' => [ + [ + '$collection' => ID::custom('platforms'), + 'name' => 'Localhost', + 'type' => Origin::CLIENT_TYPE_WEB, + 'hostname' => 'localhost', + ], // Current host is added on app init + ], + 'legalName' => '', + 'legalCountry' => '', + 'legalState' => '', + 'legalCity' => '', + 'legalAddress' => '', + 'legalTaxId' => '', + 'auths' => [ + 'mockNumbers' => [], + 'invites' => System::getEnv('_APP_CONSOLE_INVITES', 'enabled') === 'enabled', + 'limit' => (System::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled') === 'enabled') ? 1 : 0, // limit signup to 1 user + 'duration' => Auth::TOKEN_EXPIRATION_LOGIN_LONG, // 1 Year in seconds + 'sessionAlerts' => System::getEnv('_APP_CONSOLE_SESSION_ALERTS', 'disabled') === 'enabled' + ], + 'authWhitelistEmails' => (!empty(System::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', System::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], + 'authWhitelistIPs' => (!empty(System::getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', System::getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [], + 'oAuthProviders' => [ + 'githubEnabled' => true, + 'githubSecret' => System::getEnv('_APP_CONSOLE_GITHUB_SECRET', ''), + 'githubAppid' => System::getEnv('_APP_CONSOLE_GITHUB_APP_ID', '') + ], + ]); }, []); App::setResource('dbForProject', function (Group $pools, Database $dbForPlatform, Cache $cache, Document $project) { diff --git a/composer.lock b/composer.lock index ad315eed89..d3c0fdfd7b 100644 --- a/composer.lock +++ b/composer.lock @@ -5043,16 +5043,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.40.2", + "version": "0.40.6", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "56f09482d9e2f223911277ab887f197402708049" + "reference": "d8816209a07e7d64ef62dbcaf8ad4aa1262f58b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/56f09482d9e2f223911277ab887f197402708049", - "reference": "56f09482d9e2f223911277ab887f197402708049", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/d8816209a07e7d64ef62dbcaf8ad4aa1262f58b9", + "reference": "d8816209a07e7d64ef62dbcaf8ad4aa1262f58b9", "shasum": "" }, "require": { @@ -5088,9 +5088,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.40.2" + "source": "https://github.com/appwrite/sdk-generator/tree/0.40.6" }, - "time": "2025-03-06T16:31:03+00:00" + "time": "2025-03-10T19:04:24+00:00" }, { "name": "doctrine/annotations", @@ -5317,16 +5317,16 @@ }, { "name": "laravel/pint", - "version": "v1.21.0", + "version": "v1.21.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "531fa0871fbde719c51b12afa3a443b8f4e4b425" + "reference": "c44bffbb2334e90fba560933c45948fa4a3f3e86" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/531fa0871fbde719c51b12afa3a443b8f4e4b425", - "reference": "531fa0871fbde719c51b12afa3a443b8f4e4b425", + "url": "https://api.github.com/repos/laravel/pint/zipball/c44bffbb2334e90fba560933c45948fa4a3f3e86", + "reference": "c44bffbb2334e90fba560933c45948fa4a3f3e86", "shasum": "" }, "require": { @@ -5337,9 +5337,9 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.68.5", - "illuminate/view": "^11.42.0", - "larastan/larastan": "^3.0.4", + "friendsofphp/php-cs-fixer": "^3.70.2", + "illuminate/view": "^11.44.1", + "larastan/larastan": "^3.1.0", "laravel-zero/framework": "^11.36.1", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^2.3", @@ -5379,7 +5379,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2025-02-18T03:18:57+00:00" + "time": "2025-03-11T03:22:21+00:00" }, { "name": "matthiasmullie/minify", From d522b1a04c752b6f3a50fa40a43d7d18b24da780 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 11 Mar 2025 18:56:24 +0200 Subject: [PATCH 248/279] debug --- app/controllers/api/databases.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index d8d496089c..2049076e97 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -563,7 +563,8 @@ App::get('/v1/databases') ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->inject('response') ->inject('dbForProject') - ->action(function (array $queries, string $search, Response $response, Database $dbForProject) { + ->inject('project') + ->action(function (array $queries, string $search, Response $response, Database $dbForProject, Document $project) { $queries = Query::parseQueries($queries); if (!empty($search)) { @@ -597,6 +598,12 @@ App::get('/v1/databases') $filterQueries = Query::groupByType($queries)['filters']; + var_dump([ + 'projectId' => $project->getInternalId(), + 'queries' => $queries, + 'results' => $dbForProject->find('databases', $queries), + ]); + $response->dynamic(new Document([ 'databases' => $dbForProject->find('databases', $queries), 'total' => $dbForProject->count('databases', $filterQueries, APP_LIMIT_COUNT), From a60d916c516ada9c5436de6e8fb4e6eb0ed78b7e Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 11 Mar 2025 19:18:05 +0200 Subject: [PATCH 249/279] debug --- app/controllers/api/databases.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 2049076e97..76f054809b 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -598,12 +598,6 @@ App::get('/v1/databases') $filterQueries = Query::groupByType($queries)['filters']; - var_dump([ - 'projectId' => $project->getInternalId(), - 'queries' => $queries, - 'results' => $dbForProject->find('databases', $queries), - ]); - $response->dynamic(new Document([ 'databases' => $dbForProject->find('databases', $queries), 'total' => $dbForProject->count('databases', $filterQueries, APP_LIMIT_COUNT), From e019e426f132de42270fba1e2d66736aaf108a1d Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 16 Mar 2025 13:47:54 +0200 Subject: [PATCH 250/279] debug --- app/controllers/api/account.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 20f64496ac..6e7986160c 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2680,7 +2680,10 @@ App::get('/v1/account/prefs') ->action(function (Response $response, Document $user) { $prefs = $user->getAttribute('prefs', []); - + var_dump([ + 'location' => 'account::prefs', + '$user' => $user, + ]); $response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES); }); From b3db296f13c00fa539287550580abcb6cd3d9e26 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 16 Mar 2025 14:05:03 +0200 Subject: [PATCH 251/279] sync with main --- app/init/resources.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/init/resources.php b/app/init/resources.php index 96c52a2350..22ec4c3c96 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -285,6 +285,16 @@ App::setResource('project', function ($dbForPlatform, $request, $console) { $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); + if (!empty($project->getAttribute('region')) && $project->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { + var_dump([ + 'projectId' => $project->getId(), + 'projectRegion' => $project->getAttribute('region'), + '_APP_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; }, ['dbForPlatform', 'request', 'console']); From ff618a056571a7bddf3d9fd2491c1bbdb3fae76d Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 16 Mar 2025 14:42:22 +0200 Subject: [PATCH 252/279] debug --- app/controllers/api/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 6e7986160c..d85f1a8de0 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2682,7 +2682,7 @@ App::get('/v1/account/prefs') $prefs = $user->getAttribute('prefs', []); var_dump([ 'location' => 'account::prefs', - '$user' => $user, + '$prefs' => $prefs, ]); $response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES); }); From ab790f6c02aed52f05fa6af7229ab0677114d0f3 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 16 Mar 2025 15:24:29 +0200 Subject: [PATCH 253/279] debug --- app/controllers/api/account.php | 5 +++++ app/controllers/api/users.php | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index d85f1a8de0..ae5273ded2 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -3080,6 +3080,11 @@ App::patch('/v1/account/prefs') ->inject('queueForEvents') ->action(function (array $prefs, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) { + var_dump([ + 'userId' => $user->getId(), + 'account:setPrefs' => $prefs, + ]); + $user->setAttribute('prefs', $prefs); $user = $dbForProject->withRequestTimestamp($requestTimestamp, fn () => $dbForProject->updateDocument('users', $user->getId(), $user)); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 4a551b7478..22fffa6df1 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -1556,7 +1556,10 @@ App::patch('/v1/users/:userId/prefs') if ($user->isEmpty()) { throw new Exception(Exception::USER_NOT_FOUND); } - + var_dump([ + 'userId' => $user->getId(), + 'user:setPrefs' => $prefs, + ]); $user = $dbForProject->updateDocument('users', $user->getId(), $user->setAttribute('prefs', $prefs)); $queueForEvents From 5683c310db82ad0f3861f801d560296ae4ee9315 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 18 Mar 2025 18:36:46 +0200 Subject: [PATCH 254/279] debug --- 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 1e00b36d22..d17f19eca9 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -809,7 +809,7 @@ App::error() $file = $error->getFile(); $line = $error->getLine(); $trace = $error->getTrace(); - + Console::warning('Appwrite CE Method: ' . $route->getMethod(). 'URL: ' . $route->getPath()); if (php_sapi_name() === 'cli') { Console::error('[Error] Timestamp: ' . date('c', time())); From fca2e95fdd6fbb97feeb8279a4a7af6b24ee1ffe Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 18 Mar 2025 19:29:40 +0200 Subject: [PATCH 255/279] debug --- app/controllers/general.php | 5 +---- app/init/resources.php | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index d17f19eca9..a4d2f20a8b 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -519,8 +519,6 @@ App::init() */ $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); - - // Only run Router when external domain if ($host !== $mainDomain || !empty($previewHostname)) { if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $geodb, $isResourceBlocked, $previewHostname)) { @@ -809,7 +807,7 @@ App::error() $file = $error->getFile(); $line = $error->getLine(); $trace = $error->getTrace(); - Console::warning('Appwrite CE Method: ' . $route->getMethod(). 'URL: ' . $route->getPath()); + if (php_sapi_name() === 'cli') { Console::error('[Error] Timestamp: ' . date('c', time())); @@ -822,7 +820,6 @@ App::error() Console::error('[Error] Message: ' . $message); Console::error('[Error] File: ' . $file); Console::error('[Error] Line: ' . $line); - Console::error('[Error] Trace: ' . $error->getTraceAsString()); } switch ($class) { diff --git a/app/init/resources.php b/app/init/resources.php index 22ec4c3c96..9b6664a818 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -272,7 +272,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons return $user; }, ['mode', 'project', 'console', 'request', 'response', 'dbForProject', 'dbForPlatform']); -App::setResource('project', function ($dbForPlatform, $request, $console) { +App::setResource('project', function ($dbForPlatform, $request, $console, $utopia) { /** @var Appwrite\Utopia\Request $request */ /** @var Utopia\Database\Database $dbForPlatform */ /** @var Utopia\Database\Document $console */ @@ -289,6 +289,7 @@ App::setResource('project', function ($dbForPlatform, $request, $console) { var_dump([ 'projectId' => $project->getId(), 'projectRegion' => $project->getAttribute('region'), + 'params' => 'Method: ' . $route->getMethod(). 'URL: ' . $route->getPath(), '_APP_REGION' => System::getEnv('_APP_REGION'), ]); @@ -296,7 +297,7 @@ App::setResource('project', function ($dbForPlatform, $request, $console) { } return $project; -}, ['dbForPlatform', 'request', 'console']); +}, ['dbForPlatform', 'request', 'console', 'utopia']); App::setResource('session', function (Document $user) { if ($user->isEmpty()) { From 2be59a94da50aebff8a154d866f01e3755731989 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Mar 2025 11:13:30 +0200 Subject: [PATCH 256/279] update --- app/init/resources.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/app/init/resources.php b/app/init/resources.php index 9b6664a818..980c9f264a 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -285,17 +285,6 @@ App::setResource('project', function ($dbForPlatform, $request, $console, $utopi $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); - if (!empty($project->getAttribute('region')) && $project->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { - var_dump([ - 'projectId' => $project->getId(), - 'projectRegion' => $project->getAttribute('region'), - 'params' => 'Method: ' . $route->getMethod(). 'URL: ' . $route->getPath(), - '_APP_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; }, ['dbForPlatform', 'request', 'console', 'utopia']); From d3cabcd5aca1bb671cae224cc7ae4cfacfc1726a Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Mar 2025 11:15:25 +0200 Subject: [PATCH 257/279] composer --- app/controllers/api/account.php | 4 +- composer.lock | 181 ++++++++++++++++---------------- 2 files changed, 93 insertions(+), 92 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index ae5273ded2..a3dcb7926f 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2681,8 +2681,8 @@ App::get('/v1/account/prefs') $prefs = $user->getAttribute('prefs', []); var_dump([ - 'location' => 'account::prefs', - '$prefs' => $prefs, + 'location' => 'account::prefs', + '$prefs' => $prefs, ]); $response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES); }); diff --git a/composer.lock b/composer.lock index d3c0fdfd7b..4150edadca 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": "9c60c30c8cc67a91164fb5a9bc427693", + "content-hash": "699ad1a6fb9772c9108ec1efc3a5619e", "packages": [ { "name": "adhocore/jwt", @@ -709,16 +709,16 @@ }, { "name": "google/protobuf", - "version": "v4.30.0", + "version": "v4.30.1", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "e1d66682f6836aa87820400f0aa07d9eb566feb6" + "reference": "f29ba8a30dfd940efb3a8a75dc44446539101f24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/e1d66682f6836aa87820400f0aa07d9eb566feb6", - "reference": "e1d66682f6836aa87820400f0aa07d9eb566feb6", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/f29ba8a30dfd940efb3a8a75dc44446539101f24", + "reference": "f29ba8a30dfd940efb3a8a75dc44446539101f24", "shasum": "" }, "require": { @@ -747,9 +747,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.30.0" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.30.1" }, - "time": "2025-03-04T22:54:49+00:00" + "time": "2025-03-13T21:08:17+00:00" }, { "name": "jean85/pretty-package-versions", @@ -3364,16 +3364,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.51.0", + "version": "0.52.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "661687b03277f1d202a0e8cf9da6e58c97da2b5e" + "reference": "a0d6421e7e5baa3ac02755496dca9fdeaa814b93" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/661687b03277f1d202a0e8cf9da6e58c97da2b5e", - "reference": "661687b03277f1d202a0e8cf9da6e58c97da2b5e", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/a0d6421e7e5baa3ac02755496dca9fdeaa814b93", + "reference": "a0d6421e7e5baa3ac02755496dca9fdeaa814b93", "shasum": "" }, "require": { @@ -3381,7 +3381,7 @@ "ext-pdo": "*", "ext-redis": "*", "php": ">=8.0", - "utopia-php/database": "0.60.*" + "utopia-php/database": "0.*.*" }, "require-dev": { "laravel/pint": "1.*", @@ -3409,9 +3409,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.51.0" + "source": "https://github.com/utopia-php/abuse/tree/0.52.0" }, - "time": "2025-02-17T11:10:18+00:00" + "time": "2025-03-06T03:48:29+00:00" }, { "name": "utopia-php/analytics", @@ -3461,21 +3461,21 @@ }, { "name": "utopia-php/audit", - "version": "0.54.0", + "version": "0.55.0", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "1b0cb8ac6bfbd7703e3f9a753c6ba59ff1c39975" + "reference": "9f8cfe5fa5d5011b8dbf93b710236dfa91dc5518" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/1b0cb8ac6bfbd7703e3f9a753c6ba59ff1c39975", - "reference": "1b0cb8ac6bfbd7703e3f9a753c6ba59ff1c39975", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/9f8cfe5fa5d5011b8dbf93b710236dfa91dc5518", + "reference": "9f8cfe5fa5d5011b8dbf93b710236dfa91dc5518", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "0.60.*" + "utopia-php/database": "0.*.*" }, "require-dev": { "laravel/pint": "1.*", @@ -3502,9 +3502,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.54.0" + "source": "https://github.com/utopia-php/audit/tree/0.55.0" }, - "time": "2025-02-25T07:21:07+00:00" + "time": "2025-03-06T03:47:47+00:00" }, { "name": "utopia-php/cache", @@ -3705,16 +3705,16 @@ }, { "name": "utopia-php/database", - "version": "0.60.6", + "version": "0.61.2", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "f3c9aa964b39c6205069f038a26e709a15541406" + "reference": "349fbdf4bc088f7775c7dfb8b80239a617a88436" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/f3c9aa964b39c6205069f038a26e709a15541406", - "reference": "f3c9aa964b39c6205069f038a26e709a15541406", + "url": "https://api.github.com/repos/utopia-php/database/zipball/349fbdf4bc088f7775c7dfb8b80239a617a88436", + "reference": "349fbdf4bc088f7775c7dfb8b80239a617a88436", "shasum": "" }, "require": { @@ -3755,9 +3755,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.60.6" + "source": "https://github.com/utopia-php/database/tree/0.61.2" }, - "time": "2025-03-05T01:23:14+00:00" + "time": "2025-03-15T11:47:42+00:00" }, { "name": "utopia-php/domains", @@ -4159,16 +4159,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.20", + "version": "0.8.1", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "8c9ba52196f50aaef4aa1903f0d8fe0c8d9997ba" + "reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/8c9ba52196f50aaef4aa1903f0d8fe0c8d9997ba", - "reference": "8c9ba52196f50aaef4aa1903f0d8fe0c8d9997ba", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab", + "reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab", "shasum": "" }, "require": { @@ -4176,7 +4176,7 @@ "ext-curl": "*", "ext-openssl": "*", "php": ">=8.1", - "utopia-php/database": "0.60.*", + "utopia-php/database": "0.61.*", "utopia-php/dsn": "0.2.*", "utopia-php/framework": "0.33.*", "utopia-php/storage": "0.18.*" @@ -4209,9 +4209,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.20" + "source": "https://github.com/utopia-php/migration/tree/0.8.1" }, - "time": "2025-02-17T11:02:15+00:00" + "time": "2025-03-18T07:48:08+00:00" }, { "name": "utopia-php/mongo", @@ -4325,16 +4325,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.3", + "version": "0.7.4", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "463c2d817c893d7dbb678c2eac7a8291f2710e25" + "reference": "a5b93d8177702ec458c3af9137663133c012b71b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/463c2d817c893d7dbb678c2eac7a8291f2710e25", - "reference": "463c2d817c893d7dbb678c2eac7a8291f2710e25", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/a5b93d8177702ec458c3af9137663133c012b71b", + "reference": "a5b93d8177702ec458c3af9137663133c012b71b", "shasum": "" }, "require": { @@ -4343,7 +4343,7 @@ "php": ">=8.0", "utopia-php/cli": "0.15.*", "utopia-php/framework": "0.33.*", - "utopia-php/queue": "0.8.*" + "utopia-php/queue": "0.9.*" }, "require-dev": { "laravel/pint": "1.2.*", @@ -4369,31 +4369,32 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.3" + "source": "https://github.com/utopia-php/platform/tree/0.7.4" }, - "time": "2025-02-04T15:09:00+00:00" + "time": "2025-03-13T13:00:12+00:00" }, { "name": "utopia-php/pools", - "version": "0.5.0", + "version": "0.7.0", "source": { "type": "git", "url": "https://github.com/utopia-php/pools.git", - "reference": "6f716a213a08db95eda1b5dddfa90983c1834817" + "reference": "ad64d45afda08ec8b29e2642a8d18075964d40bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/pools/zipball/6f716a213a08db95eda1b5dddfa90983c1834817", - "reference": "6f716a213a08db95eda1b5dddfa90983c1834817", + "url": "https://api.github.com/repos/utopia-php/pools/zipball/ad64d45afda08ec8b29e2642a8d18075964d40bf", + "reference": "ad64d45afda08ec8b29e2642a8d18075964d40bf", "shasum": "" }, "require": { - "php": ">=8.0" + "php": ">=8.3", + "utopia-php/telemetry": "0.1.*" }, "require-dev": { - "laravel/pint": "1.2.*", - "phpstan/phpstan": "1.8.*", - "phpunit/phpunit": "^9.3" + "laravel/pint": "1.*", + "phpstan/phpstan": "1.*", + "phpunit/phpunit": "11.*" }, "type": "library", "autoload": { @@ -4420,9 +4421,9 @@ ], "support": { "issues": "https://github.com/utopia-php/pools/issues", - "source": "https://github.com/utopia-php/pools/tree/0.5.0" + "source": "https://github.com/utopia-php/pools/tree/0.7.0" }, - "time": "2024-04-19T11:11:54+00:00" + "time": "2025-03-18T03:55:33+00:00" }, { "name": "utopia-php/preloader", @@ -4479,16 +4480,16 @@ }, { "name": "utopia-php/queue", - "version": "0.8.6", + "version": "0.9.0", "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "b713b997285c29d120bbcbe3d6e93762d850f87c" + "reference": "077075f1d57afa430f76c35ed3bf4616e0eee8e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/queue/zipball/b713b997285c29d120bbcbe3d6e93762d850f87c", - "reference": "b713b997285c29d120bbcbe3d6e93762d850f87c", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/077075f1d57afa430f76c35ed3bf4616e0eee8e7", + "reference": "077075f1d57afa430f76c35ed3bf4616e0eee8e7", "shasum": "" }, "require": { @@ -4538,9 +4539,9 @@ ], "support": { "issues": "https://github.com/utopia-php/queue/issues", - "source": "https://github.com/utopia-php/queue/tree/0.8.6" + "source": "https://github.com/utopia-php/queue/tree/0.9.0" }, - "time": "2025-02-10T03:35:00+00:00" + "time": "2025-03-13T12:22:41+00:00" }, { "name": "utopia-php/registry", @@ -4760,16 +4761,16 @@ }, { "name": "utopia-php/telemetry", - "version": "0.1.0", + "version": "0.1.1", "source": { "type": "git", "url": "https://github.com/utopia-php/telemetry.git", - "reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80" + "reference": "437f0021777f0e575dfb9e8a1a081b3aed75e33f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/telemetry/zipball/d35f2f0632f4ee0be63fb7ace6a94a6adda71a80", - "reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80", + "url": "https://api.github.com/repos/utopia-php/telemetry/zipball/437f0021777f0e575dfb9e8a1a081b3aed75e33f", + "reference": "437f0021777f0e575dfb9e8a1a081b3aed75e33f", "shasum": "" }, "require": { @@ -4790,7 +4791,7 @@ "type": "library", "autoload": { "psr-4": { - "Utopia\\": "src/" + "Utopia\\Telemetry\\": "src/Telemetry" } }, "notification-url": "https://packagist.org/downloads/", @@ -4804,22 +4805,22 @@ ], "support": { "issues": "https://github.com/utopia-php/telemetry/issues", - "source": "https://github.com/utopia-php/telemetry/tree/0.1.0" + "source": "https://github.com/utopia-php/telemetry/tree/0.1.1" }, - "time": "2024-11-13T10:29:53+00:00" + "time": "2025-03-17T11:57:52+00:00" }, { "name": "utopia-php/vcs", - "version": "0.9.3", + "version": "0.9.4", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "865a00c67e81a20938b883f9aa802303790dd3b5" + "reference": "1a8d280b176acc99ea8d9e7364b8767cbb206b4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/865a00c67e81a20938b883f9aa802303790dd3b5", - "reference": "865a00c67e81a20938b883f9aa802303790dd3b5", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/1a8d280b176acc99ea8d9e7364b8767cbb206b4a", + "reference": "1a8d280b176acc99ea8d9e7364b8767cbb206b4a", "shasum": "" }, "require": { @@ -4854,9 +4855,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.9.3" + "source": "https://github.com/utopia-php/vcs/tree/0.9.4" }, - "time": "2025-02-26T16:33:35+00:00" + "time": "2025-03-13T10:09:45+00:00" }, { "name": "utopia-php/websocket", @@ -5043,16 +5044,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.40.6", + "version": "0.40.9", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "d8816209a07e7d64ef62dbcaf8ad4aa1262f58b9" + "reference": "dbb45a5db22cdc3368fe2573c07ba6088f188fa4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/d8816209a07e7d64ef62dbcaf8ad4aa1262f58b9", - "reference": "d8816209a07e7d64ef62dbcaf8ad4aa1262f58b9", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/dbb45a5db22cdc3368fe2573c07ba6088f188fa4", + "reference": "dbb45a5db22cdc3368fe2573c07ba6088f188fa4", "shasum": "" }, "require": { @@ -5088,9 +5089,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.40.6" + "source": "https://github.com/appwrite/sdk-generator/tree/0.40.9" }, - "time": "2025-03-10T19:04:24+00:00" + "time": "2025-03-17T18:39:14+00:00" }, { "name": "doctrine/annotations", @@ -5317,16 +5318,16 @@ }, { "name": "laravel/pint", - "version": "v1.21.1", + "version": "v1.21.2", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "c44bffbb2334e90fba560933c45948fa4a3f3e86" + "reference": "370772e7d9e9da087678a0edf2b11b6960e40558" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/c44bffbb2334e90fba560933c45948fa4a3f3e86", - "reference": "c44bffbb2334e90fba560933c45948fa4a3f3e86", + "url": "https://api.github.com/repos/laravel/pint/zipball/370772e7d9e9da087678a0edf2b11b6960e40558", + "reference": "370772e7d9e9da087678a0edf2b11b6960e40558", "shasum": "" }, "require": { @@ -5337,9 +5338,9 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.70.2", - "illuminate/view": "^11.44.1", - "larastan/larastan": "^3.1.0", + "friendsofphp/php-cs-fixer": "^3.72.0", + "illuminate/view": "^11.44.2", + "larastan/larastan": "^3.2.0", "laravel-zero/framework": "^11.36.1", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^2.3", @@ -5379,7 +5380,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2025-03-11T03:22:21+00:00" + "time": "2025-03-14T22:31:42+00:00" }, { "name": "matthiasmullie/minify", @@ -5794,16 +5795,16 @@ }, { "name": "phpbench/phpbench", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/phpbench/phpbench.git", - "reference": "4248817222514421cba466bfa7adc7d8932345d4" + "reference": "78cd98a9aa34e0f8f80ca01972a8b88d2c30194b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpbench/phpbench/zipball/4248817222514421cba466bfa7adc7d8932345d4", - "reference": "4248817222514421cba466bfa7adc7d8932345d4", + "url": "https://api.github.com/repos/phpbench/phpbench/zipball/78cd98a9aa34e0f8f80ca01972a8b88d2c30194b", + "reference": "78cd98a9aa34e0f8f80ca01972a8b88d2c30194b", "shasum": "" }, "require": { @@ -5880,7 +5881,7 @@ ], "support": { "issues": "https://github.com/phpbench/phpbench/issues", - "source": "https://github.com/phpbench/phpbench/tree/1.4.0" + "source": "https://github.com/phpbench/phpbench/tree/1.4.1" }, "funding": [ { @@ -5888,7 +5889,7 @@ "type": "github" } ], - "time": "2025-01-26T19:54:45+00:00" + "time": "2025-03-12T08:01:40+00:00" }, { "name": "phpunit/php-code-coverage", From 403e5773a2884e1af9bca99cb536cf1a3c166615 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 20 Mar 2025 14:26:11 +0200 Subject: [PATCH 258/279] cleanup --- app/controllers/api/account.php | 10 +--------- app/controllers/api/users.php | 5 +---- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index a3dcb7926f..20f64496ac 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2680,10 +2680,7 @@ App::get('/v1/account/prefs') ->action(function (Response $response, Document $user) { $prefs = $user->getAttribute('prefs', []); - var_dump([ - 'location' => 'account::prefs', - '$prefs' => $prefs, - ]); + $response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES); }); @@ -3080,11 +3077,6 @@ App::patch('/v1/account/prefs') ->inject('queueForEvents') ->action(function (array $prefs, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) { - var_dump([ - 'userId' => $user->getId(), - 'account:setPrefs' => $prefs, - ]); - $user->setAttribute('prefs', $prefs); $user = $dbForProject->withRequestTimestamp($requestTimestamp, fn () => $dbForProject->updateDocument('users', $user->getId(), $user)); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 22fffa6df1..4a551b7478 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -1556,10 +1556,7 @@ App::patch('/v1/users/:userId/prefs') if ($user->isEmpty()) { throw new Exception(Exception::USER_NOT_FOUND); } - var_dump([ - 'userId' => $user->getId(), - 'user:setPrefs' => $prefs, - ]); + $user = $dbForProject->updateDocument('users', $user->getId(), $user->setAttribute('prefs', $prefs)); $queueForEvents From 6c0ce5cc411fdefba81781541129d80b3ef6efd8 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 20 Mar 2025 15:05:48 +0200 Subject: [PATCH 259/279] debug --- app/controllers/api/migrations.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 75afc7ed2c..38193d1f89 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -409,7 +409,11 @@ App::get('/v1/migrations/appwrite/report') ->inject('user') ->action(function (array $resources, string $endpoint, string $projectID, string $key, Response $response) { $appwrite = new Appwrite($projectID, $endpoint, $key); - + var_dump([ + 'projectID' => $projectID, + 'endpoint' => $endpoint, + 'key' => $key + ]); try { $report = $appwrite->report($resources); } catch (\Throwable $e) { From bd19da2e7a36bcb62e2a8671f7298006bfda4a4b Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 20 Mar 2025 17:12:59 +0200 Subject: [PATCH 260/279] debug --- app/controllers/api/migrations.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 38193d1f89..3312929894 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -409,11 +409,11 @@ App::get('/v1/migrations/appwrite/report') ->inject('user') ->action(function (array $resources, string $endpoint, string $projectID, string $key, Response $response) { $appwrite = new Appwrite($projectID, $endpoint, $key); - var_dump([ - 'projectID' => $projectID, - 'endpoint' => $endpoint, - 'key' => $key - ]); +// var_dump([ +// 'projectID' => $projectID, +// 'endpoint' => $endpoint, +// 'key' => $key +// ]); try { $report = $appwrite->report($resources); } catch (\Throwable $e) { From ea02639767bd92bb980bf993dc83d18f553cf394 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 20 Mar 2025 18:15:51 +0200 Subject: [PATCH 261/279] debug --- app/controllers/shared/api.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 0f39f29fe9..dd57182bc9 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -191,6 +191,13 @@ App::init() ->action(function (App $utopia, Request $request, Database $dbForPlatform, Database $dbForProject, Audit $queueForAudits, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team, ?Key $apiKey) { $route = $utopia->getRoute(); + var_dump([ + 'location' => 'api.php', + 'projectId' => !empty($project->getId()) ? $project->getId() : 'NA', + 'params' => 'Method: ' . $route->getMethod(). ' URL: ' . $route->getPath(), + '_APP_REGION' => System::getEnv('_APP_REGION'), + ]); + if ($project->isEmpty()) { throw new Exception(Exception::PROJECT_NOT_FOUND); } From 69bdf50c85769d5a0f1f7a0dbe2bdbf79a96b36a Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 20 Mar 2025 18:27:23 +0200 Subject: [PATCH 262/279] debug --- app/controllers/shared/api.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index dd57182bc9..9f9abd2b6f 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -191,14 +191,15 @@ App::init() ->action(function (App $utopia, Request $request, Database $dbForPlatform, Database $dbForProject, Audit $queueForAudits, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team, ?Key $apiKey) { $route = $utopia->getRoute(); - var_dump([ - 'location' => 'api.php', - 'projectId' => !empty($project->getId()) ? $project->getId() : 'NA', - 'params' => 'Method: ' . $route->getMethod(). ' URL: ' . $route->getPath(), - '_APP_REGION' => System::getEnv('_APP_REGION'), - ]); - if ($project->isEmpty()) { + + var_dump([ + 'location' => 'api.php', + 'projectId' => !empty($project->getId()) ? $project->getId() : 'NA', + 'params' => 'Method: ' . $route->getMethod(). ' URL: ' . $route->getPath(), + '_APP_REGION' => System::getEnv('_APP_REGION'), + ]); + throw new Exception(Exception::PROJECT_NOT_FOUND); } From ed7c2fa4514aa2214c12eabc962b6ff9db1d113e Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 21 Mar 2025 19:08:37 +0200 Subject: [PATCH 263/279] debug --- app/init/resources.php | 8 ++++++++ src/Appwrite/Platform/Tasks/StatsResources.php | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/init/resources.php b/app/init/resources.php index 347d518d7b..099eb45e6e 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -284,7 +284,15 @@ App::setResource('project', function ($dbForPlatform, $request, $console, $utopi } $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); + if(empty($project)) { + var_dump([ + 'location' => 'project resource', + 'getParam(project)' => $request->getParam('project'), + 'x-appwrite-project' => $request->getHeader('x-appwrite-project', ''), + 'projectId' => $projectId, + ]); + } return $project; }, ['dbForPlatform', 'request', 'console', 'utopia']); diff --git a/src/Appwrite/Platform/Tasks/StatsResources.php b/src/Appwrite/Platform/Tasks/StatsResources.php index ac3b9ead73..88969ee2a4 100644 --- a/src/Appwrite/Platform/Tasks/StatsResources.php +++ b/src/Appwrite/Platform/Tasks/StatsResources.php @@ -67,7 +67,8 @@ class StatsResources extends Action * For each project that were accessed in last 24 hours */ $this->foreachDocument($this->dbForPlatform, 'projects', [ - Query::greaterThanEqual('accessedAt', DateTime::format($last24Hours)) + Query::greaterThanEqual('accessedAt', DateTime::format($last24Hours)), + Query::equal('region', System::getEnv('_APP_REGION', 'default')) ], function ($project) use ($queue) { $queue ->setProject($project) From a7199ff98047c2b2e1db0e42ac32641092b7c416 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 23 Mar 2025 10:44:00 +0200 Subject: [PATCH 264/279] debug --- app/init/resources.php | 8 -------- src/Appwrite/Platform/Tasks/Maintenance.php | 5 ++++- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/init/resources.php b/app/init/resources.php index 099eb45e6e..347d518d7b 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -284,15 +284,7 @@ App::setResource('project', function ($dbForPlatform, $request, $console, $utopi } $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); - if(empty($project)) { - var_dump([ - 'location' => 'project resource', - 'getParam(project)' => $request->getParam('project'), - 'x-appwrite-project' => $request->getHeader('x-appwrite-project', ''), - 'projectId' => $projectId, - ]); - } return $project; }, ['dbForPlatform', 'request', 'console', 'utopia']); diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index b9e312a3fb..b8e23223e0 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -47,7 +47,10 @@ class Maintenance extends Action Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds"); - $dbForPlatform->foreach('projects', function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) { + $dbForPlatform->foreach('projects', [ + Query::equal('region', System::getEnv('_APP_REGION', 'default')) + ], + function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) { $queueForDeletes ->setType(DELETE_TYPE_MAINTENANCE) ->setProject($project) From ab1683070bdf28e80cb69545d28caf23cb562816 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 23 Mar 2025 19:59:51 +0200 Subject: [PATCH 265/279] debug --- composer.json | 2 +- composer.lock | 41 +++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 5aeeb2998b..d7b8505b5c 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "utopia-php/database": "0.61.*", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", - "utopia-php/framework": "0.33.17", + "utopia-php/framework": "0.33.*", "utopia-php/fetch": "0.3.*", "utopia-php/image": "0.8.*", "utopia-php/locale": "0.4.*", diff --git a/composer.lock b/composer.lock index 4150edadca..4265da0d49 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": "699ad1a6fb9772c9108ec1efc3a5619e", + "content-hash": "e0d7f21b681e4591144fec16c4f0d6aa", "packages": [ { "name": "adhocore/jwt", @@ -753,16 +753,16 @@ }, { "name": "jean85/pretty-package-versions", - "version": "2.1.0", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10" + "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", - "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a", + "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a", "shasum": "" }, "require": { @@ -772,8 +772,9 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", "jean85/composer-provided-replaced-stub-package": "^1.0", - "phpstan/phpstan": "^1.4", + "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^7.5|^8.5|^9.6", + "rector/rector": "^2.0", "vimeo/psalm": "^4.3 || ^5.0" }, "type": "library", @@ -806,9 +807,9 @@ ], "support": { "issues": "https://github.com/Jean85/pretty-package-versions/issues", - "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.0" + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.1" }, - "time": "2024-11-18T16:19:46+00:00" + "time": "2025-03-19T14:43:43+00:00" }, { "name": "league/csv", @@ -2371,16 +2372,16 @@ }, { "name": "ramsey/collection", - "version": "2.1.0", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/ramsey/collection.git", - "reference": "3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109" + "reference": "344572933ad0181accbf4ba763e85a0306a8c5e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109", - "reference": "3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109", + "url": "https://api.github.com/repos/ramsey/collection/zipball/344572933ad0181accbf4ba763e85a0306a8c5e2", + "reference": "344572933ad0181accbf4ba763e85a0306a8c5e2", "shasum": "" }, "require": { @@ -2441,9 +2442,9 @@ ], "support": { "issues": "https://github.com/ramsey/collection/issues", - "source": "https://github.com/ramsey/collection/tree/2.1.0" + "source": "https://github.com/ramsey/collection/tree/2.1.1" }, - "time": "2025-03-02T04:48:29+00:00" + "time": "2025-03-22T05:38:12+00:00" }, { "name": "ramsey/uuid", @@ -3907,16 +3908,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.17", + "version": "0.33.19", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644" + "reference": "64c7b7bb8a8595ffe875fa8d4b7705684dbf46c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/73fac6fbce9f56282dba4e52a58cf836ec434644", - "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644", + "url": "https://api.github.com/repos/utopia-php/http/zipball/64c7b7bb8a8595ffe875fa8d4b7705684dbf46c0", + "reference": "64c7b7bb8a8595ffe875fa8d4b7705684dbf46c0", "shasum": "" }, "require": { @@ -3948,9 +3949,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.17" + "source": "https://github.com/utopia-php/http/tree/0.33.19" }, - "time": "2025-02-24T17:35:48+00:00" + "time": "2025-03-06T11:37:49+00:00" }, { "name": "utopia-php/image", From e4c4ffdb3cf3d39f3edc48c0a88b1cbf775d00d1 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 24 Mar 2025 10:54:18 +0200 Subject: [PATCH 266/279] pull resources changes --- app/init/resources.php | 4 ++-- app/worker.php | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/init/resources.php b/app/init/resources.php index 347d518d7b..4e53b24c06 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -272,7 +272,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons return $user; }, ['mode', 'project', 'console', 'request', 'response', 'dbForProject', 'dbForPlatform']); -App::setResource('project', function ($dbForPlatform, $request, $console, $utopia) { +App::setResource('project', function ($dbForPlatform, $request, $console) { /** @var Appwrite\Utopia\Request $request */ /** @var Utopia\Database\Database $dbForPlatform */ /** @var Utopia\Database\Document $console */ @@ -286,7 +286,7 @@ App::setResource('project', function ($dbForPlatform, $request, $console, $utopi $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); return $project; -}, ['dbForPlatform', 'request', 'console', 'utopia']); +}, ['dbForPlatform', 'request', 'console']); App::setResource('session', function (Document $user) { if ($user->isEmpty()) { diff --git a/app/worker.php b/app/worker.php index 491f266a18..eeefe80000 100644 --- a/app/worker.php +++ b/app/worker.php @@ -215,18 +215,15 @@ Server::setResource('getLogsDB', function (Group $pools, Cache $cache) { }, ['pools', 'cache']); Server::setResource('abuseRetention', function () { - return time() - (int) System::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', 86400); // 1 day + return time() - (int) System::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', 86400); }); Server::setResource('auditRetention', function () { - return [ - 'project' => DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 1209600)), // 14 days - 'console' => DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE', 15778800)) // 6 months - ]; + return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 1209600)); }); Server::setResource('executionRetention', function () { - return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', 1209600)); // 14 days + return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', 1209600)); }); Server::setResource('cache', function (Registry $register) { From 16aca35bd4b7a0283c550dbca47c9ac556dbda57 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 24 Mar 2025 20:33:51 +0200 Subject: [PATCH 267/279] debug --- app/controllers/shared/api.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 9f9abd2b6f..aee1ca5e09 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -288,6 +288,12 @@ App::init() } if (empty($adminRoles)) { + var_dump([ + 'location' => 'api.php l291', + 'projectId' => !empty($project->getId()) ? $project->getId() : 'NA', + '$user' => $user, + '$team' => $team, + ]); throw new Exception(Exception::USER_UNAUTHORIZED); } From 854256e8a6a6a3a248172cff0eb59934033adfeb Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 25 Mar 2025 10:47:05 +0200 Subject: [PATCH 268/279] debug --- composer.lock | 300 +++----------------------------------------------- 1 file changed, 15 insertions(+), 285 deletions(-) diff --git a/composer.lock b/composer.lock index 4265da0d49..e5cedf0a8c 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": "e0d7f21b681e4591144fec16c4f0d6aa", + "content-hash": "d2bec8137dcd84994121f89a29932d31", "packages": [ { "name": "adhocore/jwt", @@ -751,66 +751,6 @@ }, "time": "2025-03-13T21:08:17+00:00" }, - { - "name": "jean85/pretty-package-versions", - "version": "2.1.1", - "source": { - "type": "git", - "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a", - "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a", - "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": "^2.0", - "phpunit/phpunit": "^7.5|^8.5|^9.6", - "rector/rector": "^2.0", - "vimeo/psalm": "^4.3 || ^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Jean85\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alessandro Lai", - "email": "alessandro.lai85@gmail.com" - } - ], - "description": "A library to get pretty versions strings of installed dependencies", - "keywords": [ - "composer", - "package", - "release", - "versions" - ], - "support": { - "issues": "https://github.com/Jean85/pretty-package-versions/issues", - "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.1" - }, - "time": "2025-03-19T14:43:43+00:00" - }, { "name": "league/csv", "version": "9.14.0", @@ -969,75 +909,6 @@ }, "time": "2023-10-02T10:01:54+00:00" }, - { - "name": "mongodb/mongodb", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/mongodb/mongo-php-library.git", - "reference": "b0bbd657f84219212487d01a8ffe93a789e1e488" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/b0bbd657f84219212487d01a8ffe93a789e1e488", - "reference": "b0bbd657f84219212487d01a8ffe93a789e1e488", - "shasum": "" - }, - "require": { - "ext-hash": "*", - "ext-json": "*", - "ext-mongodb": "^1.11.0", - "jean85/pretty-package-versions": "^1.2 || ^2.0.1", - "php": "^7.1 || ^8.0", - "symfony/polyfill-php80": "^1.19" - }, - "require-dev": { - "doctrine/coding-standard": "^9.0", - "squizlabs/php_codesniffer": "^3.6", - "symfony/phpunit-bridge": "^5.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10.x-dev" - } - }, - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "MongoDB\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Andreas Braun", - "email": "andreas.braun@mongodb.com" - }, - { - "name": "Jeremy Mikola", - "email": "jmikola@gmail.com" - } - ], - "description": "MongoDB driver library", - "homepage": "https://jira.mongodb.org/browse/PHPLIB", - "keywords": [ - "database", - "driver", - "mongodb", - "persistence" - ], - "support": { - "issues": "https://github.com/mongodb/mongo-php-library/issues", - "source": "https://github.com/mongodb/mongo-php-library/tree/1.10.0" - }, - "time": "2021-10-20T22:22:37+00:00" - }, { "name": "mustangostang/spyc", "version": "0.6.3", @@ -2933,86 +2804,6 @@ ], "time": "2024-09-09T11:45:10+00:00" }, - { - "name": "symfony/polyfill-php80", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/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/polyfill-php82", "version": "v1.31.0", @@ -3706,16 +3497,16 @@ }, { "name": "utopia-php/database", - "version": "0.61.2", + "version": "0.62.1", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "349fbdf4bc088f7775c7dfb8b80239a617a88436" + "reference": "65dc51466c12552add10395900cdbb4728da4068" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/349fbdf4bc088f7775c7dfb8b80239a617a88436", - "reference": "349fbdf4bc088f7775c7dfb8b80239a617a88436", + "url": "https://api.github.com/repos/utopia-php/database/zipball/65dc51466c12552add10395900cdbb4728da4068", + "reference": "65dc51466c12552add10395900cdbb4728da4068", "shasum": "" }, "require": { @@ -3723,8 +3514,7 @@ "ext-pdo": "*", "php": ">=8.1", "utopia-php/cache": "0.12.*", - "utopia-php/framework": "0.33.*", - "utopia-php/mongo": "0.3.*" + "utopia-php/framework": "0.33.*" }, "require-dev": { "fakerphp/faker": "1.23.*", @@ -3756,9 +3546,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.61.2" + "source": "https://github.com/utopia-php/database/tree/0.62.1" }, - "time": "2025-03-15T11:47:42+00:00" + "time": "2025-03-24T08:27:18+00:00" }, { "name": "utopia-php/domains", @@ -4160,16 +3950,16 @@ }, { "name": "utopia-php/migration", - "version": "0.8.1", + "version": "0.8.2", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab" + "reference": "aa3b7a508feb7090f487e7bf9cd71f5c92fbc7c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab", - "reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/aa3b7a508feb7090f487e7bf9cd71f5c92fbc7c1", + "reference": "aa3b7a508feb7090f487e7bf9cd71f5c92fbc7c1", "shasum": "" }, "require": { @@ -4177,7 +3967,7 @@ "ext-curl": "*", "ext-openssl": "*", "php": ">=8.1", - "utopia-php/database": "0.61.*", + "utopia-php/database": "0.62.*", "utopia-php/dsn": "0.2.*", "utopia-php/framework": "0.33.*", "utopia-php/storage": "0.18.*" @@ -4210,69 +4000,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.8.1" + "source": "https://github.com/utopia-php/migration/tree/0.8.2" }, - "time": "2025-03-18T07:48:08+00:00" - }, - { - "name": "utopia-php/mongo", - "version": "0.3.1", - "source": { - "type": "git", - "url": "https://github.com/utopia-php/mongo.git", - "reference": "52326a9a43e2d27ff0c15c48ba746dacbe9a7aee" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/utopia-php/mongo/zipball/52326a9a43e2d27ff0c15c48ba746dacbe9a7aee", - "reference": "52326a9a43e2d27ff0c15c48ba746dacbe9a7aee", - "shasum": "" - }, - "require": { - "ext-mongodb": "*", - "mongodb/mongodb": "1.10.0", - "php": ">=8.0" - }, - "require-dev": { - "fakerphp/faker": "^1.14", - "laravel/pint": "1.2.*", - "phpstan/phpstan": "1.8.*", - "phpunit/phpunit": "^9.4", - "swoole/ide-helper": "4.8.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Utopia\\Mongo\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Eldad Fux", - "email": "eldad@appwrite.io" - }, - { - "name": "Wess", - "email": "wess@appwrite.io" - } - ], - "description": "A simple library to manage Mongo database", - "keywords": [ - "database", - "mongo", - "php", - "upf", - "utopia" - ], - "support": { - "issues": "https://github.com/utopia-php/mongo/issues", - "source": "https://github.com/utopia-php/mongo/tree/0.3.1" - }, - "time": "2023-09-01T17:25:28+00:00" + "time": "2025-03-24T09:05:31+00:00" }, { "name": "utopia-php/orchestration", From dedcdc2e0e71b1d8b9943c417fe32240aa6ad263 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 25 Mar 2025 19:13:11 +0200 Subject: [PATCH 269/279] adding region query to deleteProjectsByTeam --- app/controllers/shared/api.php | 8 -------- src/Appwrite/Platform/Workers/Deletes.php | 8 +++++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index aee1ca5e09..cd9752ee24 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -192,14 +192,6 @@ App::init() $route = $utopia->getRoute(); if ($project->isEmpty()) { - - var_dump([ - 'location' => 'api.php', - 'projectId' => !empty($project->getId()) ? $project->getId() : 'NA', - 'params' => 'Method: ' . $route->getMethod(). ' URL: ' . $route->getPath(), - '_APP_REGION' => System::getEnv('_APP_REGION'), - ]); - throw new Exception(Exception::PROJECT_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 6dff127784..63020b7b9a 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -481,7 +481,7 @@ class Deletes extends Action ); } - /** + /** * @param Database $dbForPlatform * @param Document $document * @return void @@ -492,11 +492,13 @@ class Deletes extends Action * @throws Structure * @throws Exception */ - private function deleteProjectsByTeam(Database $dbForPlatform, callable $getProjectDB, CertificatesAdapter $certificates, Document $document): void + protected function deleteProjectsByTeam(Database $dbForPlatform, callable $getProjectDB, CertificatesAdapter $certificates, Document $document): void { $projects = $dbForPlatform->find('projects', [ - Query::equal('teamInternalId', [$document->getInternalId()]) + Query::equal('teamInternalId', [$document->getInternalId(), + Query::equal('region', System::getEnv('_APP_REGION', 'default')) + ]) ]); foreach ($projects as $project) { From 62effa7bc43b41f8f88f9dee05995c0c2bda9ede Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 25 Mar 2025 20:23:08 +0200 Subject: [PATCH 270/279] adding region query to deleteProjectsByTeam --- src/Appwrite/Platform/Workers/Deletes.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 63020b7b9a..b5eccbf278 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -496,9 +496,8 @@ class Deletes extends Action { $projects = $dbForPlatform->find('projects', [ - Query::equal('teamInternalId', [$document->getInternalId(), - Query::equal('region', System::getEnv('_APP_REGION', 'default')) - ]) + Query::equal('teamInternalId', [$document->getInternalId()]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]) ]); foreach ($projects as $project) { From 9f446da0a56dff3158c5c86035acc81f93262cda Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 25 Mar 2025 20:28:29 +0200 Subject: [PATCH 271/279] adding region query to deleteProjectsByTeam --- src/Appwrite/Platform/Workers/Deletes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index b5eccbf278..e5abe1e348 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -494,7 +494,7 @@ class Deletes extends Action */ protected function deleteProjectsByTeam(Database $dbForPlatform, callable $getProjectDB, CertificatesAdapter $certificates, Document $document): void { - + var_dump('deleteProjectsByTeam appwrite CE'); $projects = $dbForPlatform->find('projects', [ Query::equal('teamInternalId', [$document->getInternalId()]), Query::equal('region', [System::getEnv('_APP_REGION', 'default')]) From 844773261463bfbc24ee82be916792eb51e89d1b Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 25 Mar 2025 21:11:41 +0200 Subject: [PATCH 272/279] adding region query to deleteProjectsByTeam --- app/controllers/api/proxy.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 393caad93d..845d5c6f45 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -61,7 +61,11 @@ App::post('/v1/proxy/rules') } $functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); - if ($functionsDomain != '' && str_ends_with($domain, $functionsDomain)) { + $functionsDomainFallback = System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''); + if ( + ($functionsDomain !== '' && str_ends_with($domain, $functionsDomain)) || + ($functionsDomainFallback !== '' && str_ends_with($domain, $functionsDomainFallback)) + ) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or it\'s subdomain to specific resource. Please use different domain.'); } From a9d1f6668f9c1c7a92b1185268b38c34ef457f22 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 26 Mar 2025 09:05:36 +0200 Subject: [PATCH 273/279] adding custom domain validation against _APP_CUSTOM_DOMAIN_DENY_LIST --- .env | 1 + app/controllers/api/proxy.php | 13 ++++++------- docker-compose.yml | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.env b/.env index c10c12613b..5ea2ba2852 100644 --- a/.env +++ b/.env @@ -15,6 +15,7 @@ _APP_SYSTEM_TEAM_EMAIL=team@appwrite.io _APP_EMAIL_SECURITY=security@appwrite.io _APP_EMAIL_CERTIFICATES=certificates@appwrite.io _APP_SYSTEM_RESPONSE_FORMAT= +_APP_CUSTOM_DOMAIN_DENY_LIST= _APP_OPTIONS_ABUSE=disabled _APP_OPTIONS_ROUTER_PROTECTION=disabled _APP_OPTIONS_FORCE_HTTPS=disabled diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 845d5c6f45..7f063bd495 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -55,18 +55,17 @@ App::post('/v1/proxy/rules') ->inject('dbForPlatform') ->inject('dbForProject') ->action(function (string $domain, string $resourceType, string $resourceId, Response $response, Document $project, Certificate $queueForCertificates, Event $queueForEvents, Database $dbForPlatform, Database $dbForProject) { + $mainDomain = System::getEnv('_APP_DOMAIN', ''); if ($domain === $mainDomain) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your main domain to specific resource. Please use subdomain or a different domain.'); } - $functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); - $functionsDomainFallback = System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''); - if ( - ($functionsDomain !== '' && str_ends_with($domain, $functionsDomain)) || - ($functionsDomainFallback !== '' && str_ends_with($domain, $functionsDomainFallback)) - ) { - throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or it\'s subdomain to specific resource. Please use different domain.'); + $deniedDomains = System::getEnv('_APP_CUSTOM_DOMAIN_DENY_LIST', ''); + foreach ($deniedDomains as $deniedDomain) { + if (str_ends_with($domain, $deniedDomain)) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or its subdomain to a specific resource. Please use a different domain.'); + } } if ($domain === 'localhost' || $domain === APP_HOSTNAME_INTERNAL) { diff --git a/docker-compose.yml b/docker-compose.yml index d15cfdf0f8..ea332e02ba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -199,6 +199,7 @@ services: - _APP_DATABASE_SHARED_NAMESPACE - _APP_FUNCTIONS_CREATION_ABUSE_LIMIT - _APP_DATABASE_KEYS + - _APP_CUSTOM_DOMAIN_DENY_LIST appwrite-console: <<: *x-logging From cb2d0dc59277beee916365610bf78b9b351950e8 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 26 Mar 2025 09:07:38 +0200 Subject: [PATCH 274/279] adding custom domain validation against _APP_CUSTOM_DOMAIN_DENY_LIST --- app/controllers/api/migrations.php | 7 ++----- app/controllers/shared/api.php | 6 ------ src/Appwrite/Platform/Workers/Deletes.php | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 3312929894..4061f2c2c4 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -408,12 +408,9 @@ App::get('/v1/migrations/appwrite/report') ->inject('project') ->inject('user') ->action(function (array $resources, string $endpoint, string $projectID, string $key, Response $response) { + $appwrite = new Appwrite($projectID, $endpoint, $key); -// var_dump([ -// 'projectID' => $projectID, -// 'endpoint' => $endpoint, -// 'key' => $key -// ]); + try { $report = $appwrite->report($resources); } catch (\Throwable $e) { diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index cd9752ee24..0f39f29fe9 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -280,12 +280,6 @@ App::init() } if (empty($adminRoles)) { - var_dump([ - 'location' => 'api.php l291', - 'projectId' => !empty($project->getId()) ? $project->getId() : 'NA', - '$user' => $user, - '$team' => $team, - ]); throw new Exception(Exception::USER_UNAUTHORIZED); } diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index e5abe1e348..b5eccbf278 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -494,7 +494,7 @@ class Deletes extends Action */ protected function deleteProjectsByTeam(Database $dbForPlatform, callable $getProjectDB, CertificatesAdapter $certificates, Document $document): void { - var_dump('deleteProjectsByTeam appwrite CE'); + $projects = $dbForPlatform->find('projects', [ Query::equal('teamInternalId', [$document->getInternalId()]), Query::equal('region', [System::getEnv('_APP_REGION', 'default')]) From 989fa2b8a011a0c72fa7d99cf109b11d77becc61 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 26 Mar 2025 09:25:49 +0200 Subject: [PATCH 275/279] adding custom domain validation against _APP_CUSTOM_DOMAIN_DENY_LIST --- app/controllers/api/proxy.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 7f063bd495..514b21fe47 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -61,8 +61,11 @@ App::post('/v1/proxy/rules') throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your main domain to specific resource. Please use subdomain or a different domain.'); } - $deniedDomains = System::getEnv('_APP_CUSTOM_DOMAIN_DENY_LIST', ''); + $denyListString = System::getEnv('_APP_CUSTOM_DOMAIN_DENY_LIST', ''); + $deniedDomains = array_map('trim', explode(',', $denyListString)); + var_dump($deniedDomains); foreach ($deniedDomains as $deniedDomain) { + var_dump(str_ends_with($domain, $deniedDomain)); if (str_ends_with($domain, $deniedDomain)) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or its subdomain to a specific resource. Please use a different domain.'); } From 35cd2b52957e1bf2093fb6c556012a6f4f04e2b8 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 26 Mar 2025 09:39:53 +0200 Subject: [PATCH 276/279] adding custom domain validation against _APP_CUSTOM_DOMAIN_DENY_LIST --- app/controllers/api/proxy.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 514b21fe47..cc5b96c78b 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -63,9 +63,8 @@ App::post('/v1/proxy/rules') $denyListString = System::getEnv('_APP_CUSTOM_DOMAIN_DENY_LIST', ''); $deniedDomains = array_map('trim', explode(',', $denyListString)); - var_dump($deniedDomains); + foreach ($deniedDomains as $deniedDomain) { - var_dump(str_ends_with($domain, $deniedDomain)); if (str_ends_with($domain, $deniedDomain)) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or its subdomain to a specific resource. Please use a different domain.'); } From 31c326fe878905d4676cb6101083bb25db9ded50 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 3 Apr 2025 11:31:45 +0300 Subject: [PATCH 277/279] sync with 1.6.x --- composer.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index 5971a33ccb..510b9a2f53 100644 --- a/composer.lock +++ b/composer.lock @@ -2965,16 +2965,16 @@ }, { "name": "tbachert/spi", - "version": "v1.0.2", + "version": "v1.0.3", "source": { "type": "git", "url": "https://github.com/Nevay/spi.git", - "reference": "2ddfaf815dafb45791a61b08170de8d583c16062" + "reference": "506a79c98e1a51522e76ee921ccb6c62d52faf3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Nevay/spi/zipball/2ddfaf815dafb45791a61b08170de8d583c16062", - "reference": "2ddfaf815dafb45791a61b08170de8d583c16062", + "url": "https://api.github.com/repos/Nevay/spi/zipball/506a79c98e1a51522e76ee921ccb6c62d52faf3a", + "reference": "506a79c98e1a51522e76ee921ccb6c62d52faf3a", "shasum": "" }, "require": { @@ -3011,9 +3011,9 @@ ], "support": { "issues": "https://github.com/Nevay/spi/issues", - "source": "https://github.com/Nevay/spi/tree/v1.0.2" + "source": "https://github.com/Nevay/spi/tree/v1.0.3" }, - "time": "2024-10-04T16:36:12+00:00" + "time": "2025-04-02T19:38:14+00:00" }, { "name": "thecodingmachine/safe", @@ -8126,7 +8126,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From ff89da513f9720270c4305ca7ebbf174d82994e6 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 10 Apr 2025 17:20:05 +0300 Subject: [PATCH 278/279] addressing comments --- app/config/variables.php | 9 +++++++++ app/controllers/api/databases.php | 3 +-- app/controllers/api/proxy.php | 8 +++++++- composer.lock | 12 ++++++------ docker-compose.yml | 1 - 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/config/variables.php b/app/config/variables.php index 27463d2fee..a828ceda61 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -79,6 +79,15 @@ return [ 'question' => 'Enter your Appwrite hostname', 'filter' => '' ], + [ + 'name' => '_APP_CUSTOM_DOMAIN_DENY_LIST', + 'description' => 'List of reserved or prohibited domains when configuring custom domains.', + 'introduction' => '', + 'default' => 'example.com,test.com,app.example.com', + 'required' => false, + 'question' => '', + 'filter' => '' + ], [ 'name' => '_APP_DOMAIN_FUNCTIONS', 'description' => 'A domain to use for function preview URLs. Setting to empty turns off function preview URLs.', diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 24a28202ed..0c37e1a765 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -563,8 +563,7 @@ App::get('/v1/databases') ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->inject('response') ->inject('dbForProject') - ->inject('project') - ->action(function (array $queries, string $search, Response $response, Database $dbForProject, Document $project) { + ->action(function (array $queries, string $search, Response $response, Database $dbForProject) { $queries = Query::parseQueries($queries); if (!empty($search)) { diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index cc5b96c78b..7ee2fa1dee 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -61,7 +61,13 @@ App::post('/v1/proxy/rules') throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your main domain to specific resource. Please use subdomain or a different domain.'); } - $denyListString = System::getEnv('_APP_CUSTOM_DOMAIN_DENY_LIST', ''); + $functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS'); + $denyListString = System::getEnv('_APP_CUSTOM_DOMAIN_DENY_LIST'); + + if (!empty($functionsDomain)) { + $denyListString .= ',' . $functionsDomain; + } + $deniedDomains = array_map('trim', explode(',', $denyListString)); foreach ($deniedDomains as $deniedDomain) { diff --git a/composer.lock b/composer.lock index 5b179768e7..5409db78ec 100644 --- a/composer.lock +++ b/composer.lock @@ -3497,16 +3497,16 @@ }, { "name": "utopia-php/database", - "version": "0.64.1", + "version": "0.64.2", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "6530a8a6d3c1fe92d0f9a92f0f05eda698d92e0b" + "reference": "dc9c4a68c93e8bea2dfaa76d1ba308be539998bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/6530a8a6d3c1fe92d0f9a92f0f05eda698d92e0b", - "reference": "6530a8a6d3c1fe92d0f9a92f0f05eda698d92e0b", + "url": "https://api.github.com/repos/utopia-php/database/zipball/dc9c4a68c93e8bea2dfaa76d1ba308be539998bd", + "reference": "dc9c4a68c93e8bea2dfaa76d1ba308be539998bd", "shasum": "" }, "require": { @@ -3547,9 +3547,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.64.1" + "source": "https://github.com/utopia-php/database/tree/0.64.2" }, - "time": "2025-04-02T00:35:29+00:00" + "time": "2025-04-09T07:53:05+00:00" }, { "name": "utopia-php/domains", diff --git a/docker-compose.yml b/docker-compose.yml index 7d9018676c..74ef34603b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -198,7 +198,6 @@ services: - _APP_DATABASE_SHARED_TABLES_V1 - _APP_DATABASE_SHARED_NAMESPACE - _APP_FUNCTIONS_CREATION_ABUSE_LIMIT - - _APP_DATABASE_KEYS - _APP_CUSTOM_DOMAIN_DENY_LIST extra_hosts: - "host.docker.internal:host-gateway" From fb802c7fe4a0555807e0608de67f106c72ca74aa Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 10 Apr 2025 18:35:45 +0300 Subject: [PATCH 279/279] addressing comments --- app/controllers/api/proxy.php | 8 ++++---- src/Appwrite/Platform/Tasks/Maintenance.php | 22 ++++++++++++--------- src/Appwrite/Platform/Workers/Deletes.php | 22 ++++++++++----------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 7ee2fa1dee..80f3df2605 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -62,13 +62,13 @@ App::post('/v1/proxy/rules') } $functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS'); - $denyListString = System::getEnv('_APP_CUSTOM_DOMAIN_DENY_LIST'); + $denyListDomains = System::getEnv('_APP_CUSTOM_DOMAIN_DENY_LIST'); - if (!empty($functionsDomain)) { - $denyListString .= ',' . $functionsDomain; + if (!empty($denyListDomains)) { + $functionsDomain .= ',' . $denyListDomains; } - $deniedDomains = array_map('trim', explode(',', $denyListString)); + $deniedDomains = array_map('trim', explode(',', $functionsDomain)); foreach ($deniedDomains as $deniedDomain) { if (str_ends_with($domain, $deniedDomain)) { diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index b8e23223e0..62f504acf0 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -47,18 +47,22 @@ class Maintenance extends Action Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds"); - $dbForPlatform->foreach('projects', [ + $dbForPlatform->foreach( + 'projects', + [ Query::equal('region', System::getEnv('_APP_REGION', 'default')) ], function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) { - $queueForDeletes - ->setType(DELETE_TYPE_MAINTENANCE) - ->setProject($project) - ->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly)) - ->trigger(); - }, [ - Query::limit(100), - ]); + $queueForDeletes + ->setType(DELETE_TYPE_MAINTENANCE) + ->setProject($project) + ->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly)) + ->trigger(); + }, + [ + Query::limit(100), + ] + ); $queueForDeletes ->setType(DELETE_TYPE_MAINTENANCE) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index af346aa2e9..5be865f42b 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -493,17 +493,17 @@ class Deletes extends Action ); } - /** - * @param Database $dbForPlatform - * @param Document $document - * @return void - * @throws Authorization - * @throws DatabaseException - * @throws Conflict - * @throws Restricted - * @throws Structure - * @throws Exception - */ + /** + * @param Database $dbForPlatform + * @param Document $document + * @return void + * @throws Authorization + * @throws DatabaseException + * @throws Conflict + * @throws Restricted + * @throws Structure + * @throws Exception + */ protected function deleteProjectsByTeam(Database $dbForPlatform, callable $getProjectDB, CertificatesAdapter $certificates, Document $document): void {