diff --git a/app/cli.php b/app/cli.php index 404c3cdf8e..6074185461 100644 --- a/app/cli.php +++ b/app/cli.php @@ -88,7 +88,7 @@ $logError $log->addExtra('file', $error->getFile()); $log->addExtra('line', $error->getLine()); $log->addExtra('trace', $error->getTraceAsString()); - $log->addExtra('trace', $error->getTraceAsString()); + $log->addExtra('trace', $error->getTraceAsString()); $log->setAction($action); diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index a974e7cd68..04c560b71f 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -54,16 +54,9 @@ use Utopia\Storage\Validator\File; use Utopia\Storage\Validator\FileExt; use Utopia\Storage\Validator\FileSize; use Utopia\Storage\Validator\Upload; -use Utopia\Swoole\Request; use Utopia\System\System; use Utopia\Validator\AnyOf; -use Utopia\Validator\ArrayList; -use Utopia\Validator\Assoc; -use Utopia\Validator\Boolean; use Utopia\Validator\Nullable; -use Utopia\Validator\Range; -use Utopia\Validator\Text; -use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub; use Utopia\VCS\Exception\RepositoryNotFound; @@ -193,7 +186,7 @@ Http::post('/v1/functions') ->inject('dbForConsole') ->inject('gitHub') ->inject('authorization') - ->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 $templateBranch, string $specification Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github, Authorization $authorization) 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 $templateBranch, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github, Authorization $authorization) use ($redeployVcs) { $functionId = ($functionId == 'unique()') ? ID::unique() : $functionId; $allowList = \array_filter(\explode(',', System::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); diff --git a/app/controllers/general.php b/app/controllers/general.php index 34e139516c..5b79709176 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -33,7 +33,6 @@ use Utopia\Http\Route; use Utopia\Http\Validator\Hostname; use Utopia\Http\Validator\Text; use Utopia\Locale\Locale; -use Utopia\Logger\Adapter\Sentry; use Utopia\Logger\Log; use Utopia\Logger\Log\User; use Utopia\Logger\Logger; diff --git a/app/init.php b/app/init.php index 9a6b608507..b3fd0a833f 100644 --- a/app/init.php +++ b/app/init.php @@ -1,4 +1,5 @@ set('logger', function () { throw new Exception(Exception::GENERAL_SERVER_ERROR, "Logging provider not supported. Logging is disabled"); } - try{ + try { $adapter = match ($providerName) { 'sentry' => new Sentry($providerConfig['projectId'], $providerConfig['key'], $providerConfig['host']), 'logowl' => new LogOwl($providerConfig['ticket'], $providerConfig['host']), diff --git a/app/realtime.php b/app/realtime.php index 2415051940..1020ca0cc5 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -16,8 +16,6 @@ use Swoole\Table; use Swoole\Timer; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\Database\TimeLimit; -use Utopia\Cache\Adapter\Sharding; -use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Database\DateTime; use Utopia\Database\Document; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index fc4c88aebf..bded4397a9 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -175,23 +175,23 @@ abstract class Migration Console::log('Migrating Collection ' . $collection['$id'] . ':'); foreach ($this->documentsIterator($collection['$id']) as $document) { - if (empty($document->getId()) || empty($document->getCollection())) { - return; - } + if (empty($document->getId()) || empty($document->getCollection())) { + return; + } - $old = $document->getArrayCopy(); - $new = call_user_func($callback, $document); + $old = $document->getArrayCopy(); + $new = call_user_func($callback, $document); - if (is_null($new) || $new->getArrayCopy() == $old) { - return; - } + if (is_null($new) || $new->getArrayCopy() == $old) { + return; + } - try { - $this->projectDB->updateDocument($document->getCollection(), $document->getId(), $document); - } catch (\Throwable $th) { - Console::error('Failed to update document: ' . $th->getMessage()); - return; - } + try { + $this->projectDB->updateDocument($document->getCollection(), $document->getId(), $document); + } catch (\Throwable $th) { + Console::error('Failed to update document: ' . $th->getMessage()); + return; + } } } } diff --git a/src/Appwrite/Platform/Tasks/Migrate.php b/src/Appwrite/Platform/Tasks/Migrate.php index bcabbc8595..55be0b81c2 100644 --- a/src/Appwrite/Platform/Tasks/Migrate.php +++ b/src/Appwrite/Platform/Tasks/Migrate.php @@ -5,7 +5,6 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Migration\Migration; use Redis; use Utopia\App; -use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\Document; @@ -38,8 +37,8 @@ class Migrate extends Action ->inject('authorization') ->inject('console') ->callback(function ($version, $dbForConsole, $getProjectDB, Registry $register, Authorization $authorization, Document $console) { - \Co\run(function () use ($version, $dbForConsole, $getProjectDB, $register, Authorization $authorization, Document $console) { - $this->action($version, $dbForConsole, $getProjectDB, $register, Authorization $authorization, Document $console); + \Co\run(function () use ($version, $dbForConsole, $getProjectDB, $register, $authorization, $console) { + $this->action($version, $dbForConsole, $getProjectDB, $register, $authorization, $console); }); }); } @@ -47,7 +46,16 @@ class Migrate extends Action private function clearProjectsCache(Document $project) { try { - $cache->purge("cache-_{$project->getInternalId()}:*"); + $iterator = null; + do { + $pattern = "default-cache-_{$project->getInternalId()}:*"; + $keys = $this->redis->scan($iterator, $pattern, 1000); + if ($keys !== false) { + foreach ($keys as $key) { + $this->redis->del($key); + } + } + } while ($iterator > 0); } catch (\Throwable $th) { Console::error('Failed to clear project ("' . $project->getId() . '") cache with error: ' . $th->getMessage()); } diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 666e0649e9..a1f87ecbcd 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -6,10 +6,10 @@ use Appwrite\Utopia\Fetch\BodyMultipart; use Appwrite\Utopia\Response\Filter; use Exception; use JsonException; -use Swoole\Http\Response as SwooleHTTPResponse; // Keep last use Utopia\Database\Document; use Utopia\Swoole\Response as SwooleResponse; + // Keep last /** diff --git a/src/Appwrite/Utopia/Response/Models.php b/src/Appwrite/Utopia/Response/Models.php index 1c3ef92b8b..8f26035778 100644 --- a/src/Appwrite/Utopia/Response/Models.php +++ b/src/Appwrite/Utopia/Response/Models.php @@ -2,9 +2,6 @@ namespace Appwrite\Utopia\Response; -use Appwrite\Utopia\Fetch\BodyMultipart; -use Appwrite\Utopia\Response\Filter; -use Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response\Model\Account; use Appwrite\Utopia\Response\Model\AlgoArgon2; use Appwrite\Utopia\Response\Model\AlgoBcrypt; @@ -109,11 +106,8 @@ use Appwrite\Utopia\Response\Model\Variable; use Appwrite\Utopia\Response\Model\VcsContent; use Appwrite\Utopia\Response\Model\Webhook; use Exception; -use JsonException; -use Swoole\Http\Response as SwooleHTTPResponse; + // Keep last -use Utopia\Database\Document; -use Utopia\Swoole\Response as SwooleResponse; class Models {