From 42d0589d324c34660ea44bbcb7c9d7437c1c00c8 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 7 Feb 2022 13:25:15 +0100 Subject: [PATCH] fix: permissions and collections schema --- app/controllers/api/database.php | 57 +++++------ app/controllers/api/projects.php | 8 +- app/init.php | 4 +- app/realtime.php | 12 +-- app/tasks/usage.php | 16 ++-- app/workers/database.php | 10 +- composer.json | 2 +- composer.lock | 160 +++++++++++++++++-------------- src/Appwrite/Resque/Worker.php | 4 +- 9 files changed, 144 insertions(+), 129 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 46b989720..53767d164 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -111,7 +111,7 @@ function createAttribute(string $collectionId, Document $attribute, Response $re } $dbForProject->deleteCachedDocument('collections', $collectionId); - $dbForProject->deleteCachedCollection('collection_' . $collectionId); + $dbForProject->deleteCachedCollection('collection_' . $collection->getInternalId()); // Pass clone of $attribute object to workers // so we can later modify Document to fit response model @@ -166,7 +166,7 @@ App::post('/v1/database/collections') $collectionId = $collectionId == 'unique()' ? $dbForProject->getId() : $collectionId; try { - $collection = $dbForProject->createDocument('collections', new Document([ + $dbForProject->createDocument('collections', new Document([ '$id' => $collectionId, '$read' => $read ?? [], // Collection permissions for collection documents (based on permission model) '$write' => $write ?? [], // Collection permissions for collection documents (based on permission model) @@ -177,8 +177,9 @@ App::post('/v1/database/collections') 'name' => $name, 'search' => implode(' ', [$collectionId, $name]), ])); + $collection = $dbForProject->getDocument('collections', $collectionId); - $dbForProject->createCollection('collection_' . $collectionId); + $dbForProject->createCollection('collection_' . $collection->getInternalId()); } catch (DuplicateException $th) { throw new Exception('Collection already exists', 409); } catch (LimitException $th) { @@ -402,7 +403,8 @@ App::get('/v1/database/:collectionId/usage') /** @var Utopia\Database\Database $dbForProject */ /** @var Utopia\Registry\Registry $register */ - $collection = $dbForProject->getCollection('collection_' . $collectionId); + $collectionDocument = $dbForProject->getDocument('collections', $collectionId); + $collection = $dbForProject->getCollection('collection_' . $collectionDocument->getInternalId()); if ($collection->isEmpty()) { throw new Exception('Collection not found', 404); @@ -513,7 +515,8 @@ App::get('/v1/database/collections/:collectionId/logs') /** @var Utopia\Locale\Locale $locale */ /** @var MaxMind\Db\Reader $geodb */ - $collection = $dbForProject->getCollection('collection_' . $collectionId); + $collectionDocument = $dbForProject->getDocument('collections', $collectionId); + $collection = $dbForProject->getCollection('collection_' . $collectionDocument->getInternalId()); if ($collection->isEmpty()) { throw new Exception('Collection not found', 404); @@ -676,7 +679,7 @@ App::delete('/v1/database/collections/:collectionId') throw new Exception('Failed to remove collection from DB', 500); } - $dbForProject->deleteCachedCollection('collection_' . $collectionId); + $dbForProject->deleteCachedCollection('collection_' . $collection->getInternalId()); $deletes ->setParam('type', DELETE_TYPE_DOCUMENT) @@ -1259,7 +1262,7 @@ App::delete('/v1/database/collections/:collectionId/attributes/:key') } $dbForProject->deleteCachedDocument('collections', $collectionId); - $dbForProject->deleteCachedCollection('collection_' . $collectionId); + $dbForProject->deleteCachedCollection('collection_' . $collection->getInternalId()); $database ->setParam('type', DATABASE_TYPE_DELETE_ATTRIBUTE) @@ -1641,9 +1644,9 @@ App::post('/v1/database/collections/:collectionId/documents') try { if ($collection->getAttribute('permission') === 'collection') { /** @var Document $document */ - $document = Authorization::skip(fn() => $dbForProject->createDocument('collection_' . $collectionId, new Document($data))); + $document = Authorization::skip(fn() => $dbForProject->createDocument('collection_' . $collection->getInternalId(), new Document($data))); } else { - $document = $dbForProject->createDocument('collection_' . $collectionId, new Document($data)); + $document = $dbForProject->createDocument('collection_' . $collection->getInternalId(), new Document($data)); } $document->setAttribute('$collection', $collectionId); } @@ -1741,8 +1744,8 @@ App::get('/v1/database/collections/:collectionId/documents') $cursorDocument = null; if (!empty($cursor)) { $cursorDocument = $collection->getAttribute('permission') === 'collection' - ? Authorization::skip(fn () => $dbForProject->getDocument('collection_' . $collectionId, $cursor)) - : $dbForProject->getDocument('collection_' . $collectionId, $cursor); + ? Authorization::skip(fn () => $dbForProject->getDocument('collection_' . $collection->getInternalId(), $cursor)) + : $dbForProject->getDocument('collection_' . $collection->getInternalId(), $cursor); if ($cursorDocument->isEmpty()) { throw new Exception("Document '{$cursor}' for the 'cursor' value not found.", 400); @@ -1751,11 +1754,11 @@ App::get('/v1/database/collections/:collectionId/documents') if ($collection->getAttribute('permission') === 'collection') { /** @var Document[] $documents */ - $documents = Authorization::skip(fn() => $dbForProject->find('collection_' . $collectionId, $queries, $limit, $offset, $orderAttributes, $orderTypes, $cursorDocument ?? null, $cursorDirection)); - $sum = Authorization::skip(fn() => $dbForProject->count('collection_' . $collectionId, $queries, APP_LIMIT_COUNT)); + $documents = Authorization::skip(fn() => $dbForProject->find('collection_' . $collection->getInternalId(), $queries, $limit, $offset, $orderAttributes, $orderTypes, $cursorDocument ?? null, $cursorDirection)); + $sum = Authorization::skip(fn() => $dbForProject->count('collection_' . $collection->getInternalId(), $queries, APP_LIMIT_COUNT)); } else { - $documents = $dbForProject->find('collection_' . $collectionId, $queries, $limit, $offset, $orderAttributes, $orderTypes, $cursorDocument ?? null, $cursorDirection); - $sum = $dbForProject->count('collection_' . $collectionId, $queries, APP_LIMIT_COUNT); + $documents = $dbForProject->find('collection_' . $collection->getInternalId(), $queries, $limit, $offset, $orderAttributes, $orderTypes, $cursorDocument ?? null, $cursorDirection); + $sum = $dbForProject->count('collection_' . $collection->getInternalId(), $queries, APP_LIMIT_COUNT); } /** @@ -1817,9 +1820,9 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId') if ($collection->getAttribute('permission') === 'collection') { /** @var Document $document */ - $document = Authorization::skip(fn() => $dbForProject->getDocument('collection_' . $collectionId, $documentId)); + $document = Authorization::skip(fn() => $dbForProject->getDocument('collection_' . $collection->getInternalId(), $documentId)); } else { - $document = $dbForProject->getDocument('collection_' . $collectionId, $documentId); + $document = $dbForProject->getDocument('collection_' . $collection->getInternalId(), $documentId); } /** @@ -1871,7 +1874,7 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId/logs') throw new Exception('Collection not found', 404); } - $document = $dbForProject->getDocument('collection_' . $collectionId, $documentId); + $document = $dbForProject->getDocument('collection_' . $collection->getInternalId(), $documentId); if ($document->isEmpty()) { throw new Exception('No document found', 404); @@ -1980,9 +1983,9 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId') throw new Exception('Unauthorized permissions', 401); } - $document = Authorization::skip(fn() => $dbForProject->getDocument('collection_' . $collectionId, $documentId)); + $document = Authorization::skip(fn() => $dbForProject->getDocument('collection_' . $collection->getInternalId(), $documentId)); } else { - $document = $dbForProject->getDocument('collection_' . $collectionId, $documentId); + $document = $dbForProject->getDocument('collection_' . $collection->getInternalId(), $documentId); } @@ -2030,9 +2033,9 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId') try { if ($collection->getAttribute('permission') === 'collection') { /** @var Document $document */ - $document = Authorization::skip(fn() => $dbForProject->updateDocument('collection_' . $collection->getId(), $document->getId(), new Document($data))); + $document = Authorization::skip(fn() => $dbForProject->updateDocument('collection_' . $collection->getInternalId(), $document->getId(), new Document($data))); } else { - $document = $dbForProject->updateDocument('collection_' . $collection->getId(), $document->getId(), new Document($data)); + $document = $dbForProject->updateDocument('collection_' . $collection->getInternalId(), $document->getId(), new Document($data)); } /** * Reset $collection attribute to remove prefix. @@ -2115,9 +2118,9 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId') if ($collection->getAttribute('permission') === 'collection') { /** @var Document $document */ - $document = Authorization::skip(fn() => $dbForProject->getDocument('collection_' . $collectionId, $documentId)); + $document = Authorization::skip(fn() => $dbForProject->getDocument('collection_' . $collection->getInternalId(), $documentId)); } else { - $document = $dbForProject->getDocument('collection_' . $collectionId, $documentId); + $document = $dbForProject->getDocument('collection_' . $collection->getInternalId(), $documentId); } if ($document->isEmpty()) { @@ -2125,12 +2128,12 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId') } if ($collection->getAttribute('permission') === 'collection') { - Authorization::skip(fn() => $dbForProject->deleteDocument('collection_' . $collectionId, $documentId)); + Authorization::skip(fn() => $dbForProject->deleteDocument('collection_' . $collection->getInternalId(), $documentId)); } else { - $dbForProject->deleteDocument('collection_' . $collectionId, $documentId); + $dbForProject->deleteDocument('collection_' . $collection->getInternalId(), $documentId); } - $dbForProject->deleteCachedDocument('collection_' . $collectionId, $documentId); + $dbForProject->deleteCachedDocument('collection_' . $collection->getInternalId(), $documentId); /** * Reset $collection attribute to remove prefix. diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index b65eb5db7..50889d86e 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -101,10 +101,10 @@ App::post('/v1/projects') 'auths' => $auths, 'search' => implode(' ', [$projectId, $name]), ])); + /** @var array $collections */ + $collections = Config::getParam('collections', []); - $collections = Config::getParam('collections', []); /** @var array $collections */ - - $dbForProject->setNamespace('_project_' . $project->getId()); + $dbForProject->setNamespace("_{$project->getId()}"); $dbForProject->create('appwrite'); $audit = new Audit($dbForProject); @@ -266,7 +266,7 @@ App::get('/v1/projects/:projectId/usage') ], ]; - $dbForProject->setNamespace('_project_' . $projectId); + $dbForProject->setNamespace("_{$projectId}"); $metrics = [ 'requests', diff --git a/app/init.php b/app/init.php index a45ac69ae..23992e2b1 100644 --- a/app/init.php +++ b/app/init.php @@ -804,7 +804,7 @@ App::setResource('dbForProject', function($db, $cache, $project) { $database = new Database(new MariaDB($db), $cache); $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); - $database->setNamespace('_project_'.$project->getId()); + $database->setNamespace("_{$project->getId()}"); return $database; }, ['db', 'cache', 'project']); @@ -814,7 +814,7 @@ App::setResource('dbForConsole', function($db, $cache) { $database = new Database(new MariaDB($db), $cache); $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); - $database->setNamespace('_project_console'); + $database->setNamespace('_console'); return $database; }, ['db', 'cache']); diff --git a/app/realtime.php b/app/realtime.php index b2ddf6763..d72af7f60 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -137,7 +137,7 @@ $server->onStart(function () use ($stats, $register, $containerId, &$statsDocume */ go(function () use ($register, $containerId, &$statsDocument, $logError) { try { - [$database, $returnDatabase] = getDatabase($register, '_project_console'); + [$database, $returnDatabase] = getDatabase($register, '_console'); $document = new Document([ '$id' => $database->getId(), '$collection' => 'realtime', @@ -190,7 +190,7 @@ $server->onStart(function () use ($stats, $register, $containerId, &$statsDocume } try { - [$database, $returnDatabase] = getDatabase($register, '_project_console'); + [$database, $returnDatabase] = getDatabase($register, '_console'); $statsDocument ->setAttribute('timestamp', time()) @@ -217,7 +217,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, */ if ($realtime->hasSubscriber('console', 'role:member', 'project')) { - [$database, $returnDatabase] = getDatabase($register, '_project_console'); + [$database, $returnDatabase] = getDatabase($register, '_console'); $payload = []; @@ -321,7 +321,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, return; } - [$database, $returnDatabase] = getDatabase($register, '_project_' . $projectId); + [$database, $returnDatabase] = getDatabase($register, "_{$projectId}"); $user = $database->getDocument('users', $userId); @@ -397,7 +397,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, $cache = new Cache(new RedisCache($redis)); $database = new Database(new MariaDB($db), $cache); $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); - $database->setNamespace('_project_' . $project->getId()); + $database->setNamespace("_{$project->getId()}"); /* * Project Check @@ -504,7 +504,7 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re $cache = new Cache(new RedisCache($redis)); $database = new Database(new MariaDB($db), $cache); $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); - $database->setNamespace('_project_' . $realtime->connections[$connection]['projectId']); + $database->setNamespace("_{$realtime->connections[$connection]['projectId']}"); /* * Abuse Check diff --git a/app/tasks/usage.php b/app/tasks/usage.php index e341dad3d..d2180dbb7 100644 --- a/app/tasks/usage.php +++ b/app/tasks/usage.php @@ -223,7 +223,7 @@ $cli $dbForConsole = new Database(new MariaDB($db), $cacheAdapter); $dbForProject->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); $dbForConsole->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); - $dbForConsole->setNamespace('_project_console'); + $dbForConsole->setNamespace('_console'); $latestTime = []; @@ -289,7 +289,7 @@ $cli $projectId = $point['projectId']; if (!empty($projectId) && $projectId !== 'console') { - $dbForProject->setNamespace('_project_' . $projectId); + $dbForProject->setNamespace("_{$projectId}"); $metricUpdated = $metric; if (!empty($groupBy)) { @@ -369,7 +369,7 @@ $cli $projectId = $project->getId(); // Get total storage - $dbForProject->setNamespace('_project_' . $projectId); + $dbForProject->setNamespace("_{$projectId}"); $storageTotal = $dbForProject->sum('files', 'sizeOriginal') + $dbForProject->sum('tags', 'size'); $time = (int) (floor(time() / 1800) * 1800); // Time rounded to nearest 30 minutes @@ -433,7 +433,7 @@ $cli foreach ($collections as $collection => $options) { try { - $dbForProject->setNamespace("_project_{$projectId}"); + $dbForProject->setNamespace("_{$projectId}"); $count = $dbForProject->count($collection); $metricPrefix = $options['metricPrefix'] ?? ''; $metric = empty($metricPrefix) ? "{$collection}.count" : "{$metricPrefix}.{$collection}.count"; @@ -488,7 +488,7 @@ $cli $subCollectionCounts = []; //total project level count of sub collections do { // Loop over all the parent collection document for each sub collection - $dbForProject->setNamespace("_project_{$projectId}"); + $dbForProject->setNamespace("_{$projectId}"); $parents = $dbForProject->find($collection, [], 100, cursor: $latestParent); // Get all the parents for the sub collections for example for documents, this will get all the collections if (empty($parents)) { @@ -499,12 +499,12 @@ $cli foreach ($parents as $parent) { foreach ($subCollections as $subCollection => $subOptions) { // Sub collection counts, like database.collections.collectionId.documents.count - $dbForProject->setNamespace("_project_{$projectId}"); + $dbForProject->setNamespace("_{$projectId}"); $count = $dbForProject->count($parent->getId()); $subCollectionCounts[$subCollection] = ($subCollectionCounts[$subCollection] ?? 0) + $count; // Project level counts for sub collections like database.documents.count - $dbForProject->setNamespace("_project_{$projectId}"); + $dbForProject->setNamespace("_{$projectId}"); $metric = empty($metricPrefix) ? "{$collection}.{$parent->getId()}.{$subCollection}.count" : "{$metricPrefix}.{$collection}.{$parent->getId()}.{$subCollection}.count"; $time = (int) (floor(time() / 1800) * 1800); // Time rounded to nearest 30 minutes @@ -554,7 +554,7 @@ $cli * Inserting project level counts for sub collections like database.documents.count */ foreach ($subCollectionCounts as $subCollection => $count) { - $dbForProject->setNamespace("_project_{$projectId}"); + $dbForProject->setNamespace("_{$projectId}"); $metric = empty($metricPrefix) ? "{$subCollection}.count" : "{$metricPrefix}.{$subCollection}.count"; diff --git a/app/workers/database.php b/app/workers/database.php index 94318e8ce..d95ce122d 100644 --- a/app/workers/database.php +++ b/app/workers/database.php @@ -86,7 +86,7 @@ class DatabaseV1 extends Worker $project = $dbForConsole->getDocument('projects', $projectId); try { - if(!$dbForProject->createAttribute('collection_' . $collectionId, $key, $type, $size, $required, $default, $signed, $array, $format, $formatOptions, $filters)) { + if(!$dbForProject->createAttribute('collection_' . $collection->getInternalId(), $key, $type, $size, $required, $default, $signed, $array, $format, $formatOptions, $filters)) { throw new Exception('Failed to create Attribute'); } $dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'available')); @@ -135,7 +135,7 @@ class DatabaseV1 extends Worker // - failed: attribute was never created // - stuck: attribute was available but cannot be removed try { - if($status !== 'failed' && !$dbForProject->deleteAttribute('collection_' . $collectionId, $key)) { + if($status !== 'failed' && !$dbForProject->deleteAttribute('collection_' . $collection->getInternalId(), $key)) { throw new Exception('Failed to delete Attribute'); } $dbForProject->deleteDocument('attributes', $attribute->getId()); @@ -210,7 +210,7 @@ class DatabaseV1 extends Worker } $dbForProject->deleteCachedDocument('collections', $collectionId); - $dbForProject->deleteCachedCollection('collection_' . $collectionId); + $dbForProject->deleteCachedCollection('collection_' . $collection->getInternalId()); } /** @@ -233,7 +233,7 @@ class DatabaseV1 extends Worker $project = $dbForConsole->getDocument('projects', $projectId); try { - if(!$dbForProject->createIndex('collection_' . $collectionId, $key, $type, $attributes, $lengths, $orders)) { + if(!$dbForProject->createIndex('collection_' . $collection->getInternalId(), $key, $type, $attributes, $lengths, $orders)) { throw new Exception('Failed to create Index'); } $dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'available')); @@ -276,7 +276,7 @@ class DatabaseV1 extends Worker $project = $dbForConsole->getDocument('projects', $projectId); try { - if($status !== 'failed' && !$dbForProject->deleteIndex('collection_' . $collectionId, $key)) { + if($status !== 'failed' && !$dbForProject->deleteIndex('collection_' . $collection->getInternalId(), $key)) { throw new Exception('Failed to delete index'); } $dbForProject->deleteDocument('indexes', $index->getId()); diff --git a/composer.json b/composer.json index e7bd6646a..0eca95287 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "utopia-php/cache": "0.4.*", "utopia-php/cli": "0.11.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.14.*", + "utopia-php/database": "dev-fix-perms as 0.14.99", "utopia-php/locale": "0.4.*", "utopia-php/orchestration": "0.2.*", "utopia-php/registry": "0.5.*", diff --git a/composer.lock b/composer.lock index 91440e4a7..145c13d22 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": "ab493f0a7f01a1105f8bc5caaf9b928b", + "content-hash": "eba5438fb1baf147ea65b20bba4dd5e8", "packages": [ { "name": "adhocore/jwt", @@ -1766,12 +1766,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -2141,16 +2141,16 @@ }, { "name": "utopia-php/database", - "version": "0.14.0", + "version": "dev-fix-perms", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "2f2527bb080cf578fba327ea2ec637064561d403" + "reference": "195fd16b69c0cd388c16051826ec59fa4647a610" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/2f2527bb080cf578fba327ea2ec637064561d403", - "reference": "2f2527bb080cf578fba327ea2ec637064561d403", + "url": "https://api.github.com/repos/utopia-php/database/zipball/195fd16b69c0cd388c16051826ec59fa4647a610", + "reference": "195fd16b69c0cd388c16051826ec59fa4647a610", "shasum": "" }, "require": { @@ -2198,9 +2198,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.14.0" + "source": "https://github.com/utopia-php/database/tree/fix-perms" }, - "time": "2022-01-21T16:34:34+00:00" + "time": "2022-02-07T12:09:11+00:00" }, { "name": "utopia-php/domains", @@ -2688,16 +2688,16 @@ }, { "name": "utopia-php/swoole", - "version": "0.3.2", + "version": "0.3.3", "source": { "type": "git", "url": "https://github.com/utopia-php/swoole.git", - "reference": "2b714eddf77cd5eda1889219c9656d7c0a63ce73" + "reference": "8312df69233b5dcd3992de88f131f238002749de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/swoole/zipball/2b714eddf77cd5eda1889219c9656d7c0a63ce73", - "reference": "2b714eddf77cd5eda1889219c9656d7c0a63ce73", + "url": "https://api.github.com/repos/utopia-php/swoole/zipball/8312df69233b5dcd3992de88f131f238002749de", + "reference": "8312df69233b5dcd3992de88f131f238002749de", "shasum": "" }, "require": { @@ -2738,9 +2738,9 @@ ], "support": { "issues": "https://github.com/utopia-php/swoole/issues", - "source": "https://github.com/utopia-php/swoole/tree/0.3.2" + "source": "https://github.com/utopia-php/swoole/tree/0.3.3" }, - "time": "2021-12-13T15:37:41+00:00" + "time": "2022-01-20T09:58:43+00:00" }, { "name": "utopia-php/system", @@ -3037,12 +3037,12 @@ } }, "autoload": { - "psr-4": { - "Amp\\ByteStream\\": "lib" - }, "files": [ "lib/functions.php" - ] + ], + "psr-4": { + "Amp\\ByteStream\\": "lib" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3132,23 +3132,23 @@ }, { "name": "composer/pcre", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "3d322d715c43a1ac36c7fe215fa59336265500f2" + "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/3d322d715c43a1ac36c7fe215fa59336265500f2", - "reference": "3d322d715c43a1ac36c7fe215fa59336265500f2", + "url": "https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560", + "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^1", + "phpstan/phpstan": "^1.3", "phpstan/phpstan-strict-rules": "^1.1", "symfony/phpunit-bridge": "^4.2 || ^5" }, @@ -3183,7 +3183,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/1.0.0" + "source": "https://github.com/composer/pcre/tree/1.0.1" }, "funding": [ { @@ -3199,27 +3199,27 @@ "type": "tidelift" } ], - "time": "2021-12-06T15:17:27+00:00" + "time": "2022-01-21T20:24:37+00:00" }, { "name": "composer/semver", - "version": "3.2.7", + "version": "3.2.9", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "deac27056b57e46faf136fae7b449eeaa71661ee" + "reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/deac27056b57e46faf136fae7b449eeaa71661ee", - "reference": "deac27056b57e46faf136fae7b449eeaa71661ee", + "url": "https://api.github.com/repos/composer/semver/zipball/a951f614bd64dcd26137bc9b7b2637ddcfc57649", + "reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.54", + "phpstan/phpstan": "^1.4", "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", @@ -3264,7 +3264,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.2.7" + "source": "https://github.com/composer/semver/tree/3.2.9" }, "funding": [ { @@ -3280,7 +3280,7 @@ "type": "tidelift" } ], - "time": "2022-01-04T09:57:54+00:00" + "time": "2022-02-04T13:58:43+00:00" }, { "name": "composer/xdebug-handler", @@ -3703,6 +3703,9 @@ "require": { "php": "^7.1 || ^8.0" }, + "replace": { + "myclabs/deep-copy": "self.version" + }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", @@ -3710,12 +3713,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, "files": [ "src/DeepCopy/deep_copy.php" - ] + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -5721,16 +5724,16 @@ }, { "name": "symfony/console", - "version": "v6.0.2", + "version": "v6.0.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "dd434fa8d69325e5d210f63070014d889511fcb3" + "reference": "22e8efd019c3270c4f79376234a3f8752cd25490" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/dd434fa8d69325e5d210f63070014d889511fcb3", - "reference": "dd434fa8d69325e5d210f63070014d889511fcb3", + "url": "https://api.github.com/repos/symfony/console/zipball/22e8efd019c3270c4f79376234a3f8752cd25490", + "reference": "22e8efd019c3270c4f79376234a3f8752cd25490", "shasum": "" }, "require": { @@ -5796,7 +5799,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.0.2" + "source": "https://github.com/symfony/console/tree/v6.0.3" }, "funding": [ { @@ -5812,7 +5815,7 @@ "type": "tidelift" } ], - "time": "2021-12-27T21:05:08+00:00" + "time": "2022-01-26T17:23:29+00:00" }, { "name": "symfony/polyfill-intl-grapheme", @@ -5845,12 +5848,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -5926,12 +5929,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -6090,12 +6093,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -6222,16 +6225,16 @@ }, { "name": "symfony/string", - "version": "v6.0.2", + "version": "v6.0.3", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "bae261d0c3ac38a1f802b4dfed42094296100631" + "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/bae261d0c3ac38a1f802b4dfed42094296100631", - "reference": "bae261d0c3ac38a1f802b4dfed42094296100631", + "url": "https://api.github.com/repos/symfony/string/zipball/522144f0c4c004c80d56fa47e40e17028e2eefc2", + "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2", "shasum": "" }, "require": { @@ -6287,7 +6290,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.0.2" + "source": "https://github.com/symfony/string/tree/v6.0.3" }, "funding": [ { @@ -6303,7 +6306,7 @@ "type": "tidelift" } ], - "time": "2021-12-16T22:13:01+00:00" + "time": "2022-01-02T09:55:41+00:00" }, { "name": "textalk/websocket", @@ -6406,16 +6409,16 @@ }, { "name": "twig/twig", - "version": "v2.14.10", + "version": "v2.14.11", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "95fb194cd4dd6ac373a27af2bde2bad5d3f27aba" + "reference": "66baa66f29ee30e487e05f1679903e36eb01d727" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/95fb194cd4dd6ac373a27af2bde2bad5d3f27aba", - "reference": "95fb194cd4dd6ac373a27af2bde2bad5d3f27aba", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/66baa66f29ee30e487e05f1679903e36eb01d727", + "reference": "66baa66f29ee30e487e05f1679903e36eb01d727", "shasum": "" }, "require": { @@ -6470,7 +6473,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v2.14.10" + "source": "https://github.com/twigphp/Twig/tree/v2.14.11" }, "funding": [ { @@ -6482,7 +6485,7 @@ "type": "tidelift" } ], - "time": "2022-01-03T21:13:26+00:00" + "time": "2022-02-04T06:57:25+00:00" }, { "name": "vimeo/psalm", @@ -6561,13 +6564,13 @@ } }, "autoload": { - "psr-4": { - "Psalm\\": "src/Psalm/" - }, "files": [ "src/functions.php", "src/spl_object_id.php" - ] + ], + "psr-4": { + "Psalm\\": "src/Psalm/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -6642,9 +6645,18 @@ "time": "2015-12-17T08:42:14+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-fix-perms", + "alias": "0.14.99", + "alias_normalized": "0.14.99.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -6666,5 +6678,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.1.0" } diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index b9ed5af27..d9bad8b90 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -178,10 +178,10 @@ abstract class Worker if (!$projectId) { throw new \Exception('ProjectID not provided - cannot get database'); } - $namespace = "_project_{$projectId}"; + $namespace = "_{$projectId}"; break; case self::DATABASE_CONSOLE: - $namespace = "_project_console"; + $namespace = "_console"; $sleep = 5; // ConsoleDB needs extra sleep time to ensure tables are created break; default: