1
0
Fork 0
mirror of synced 2024-10-02 10:16:27 +13:00

feat: merge and fix conflicts

This commit is contained in:
Christy Jacob 2022-07-14 04:11:35 +04:00
parent 662800cc67
commit 6662fa7b7b
3 changed files with 20 additions and 28 deletions

View file

@ -26,6 +26,7 @@ use Appwrite\Auth\Phone\Mock;
use Appwrite\Auth\Phone\TextMagic; use Appwrite\Auth\Phone\TextMagic;
use Appwrite\Auth\Phone\Twilio; use Appwrite\Auth\Phone\Twilio;
use Appwrite\Auth\Phone\Msg91; use Appwrite\Auth\Phone\Msg91;
use Appwrite\Auth\Phone\Telesign;
use Appwrite\Auth\Phone\Vonage; use Appwrite\Auth\Phone\Vonage;
use Appwrite\DSN\DSN; use Appwrite\DSN\DSN;
use Appwrite\Event\Audit; use Appwrite\Event\Audit;
@ -46,11 +47,10 @@ use Utopia\Locale\Locale;
use Utopia\Registry\Registry; use Utopia\Registry\Registry;
use MaxMind\Db\Reader; use MaxMind\Db\Reader;
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\PHPMailer;
use Utopia\Cache\Adapter\Redis as RedisCache;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Database; use Utopia\Database\Database;
use Appwrite\Database\DatabasePool;
use Appwrite\Event\Delete;
use Utopia\Database\Validator\Structure; use Utopia\Database\Validator\Structure;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Validator\Range; use Utopia\Validator\Range;

27
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "eacaae6ec0973349a9b9f4ec78877b0a", "content-hash": "dedc6a6328b4fdc5dfbd556a08534403",
"packages": [ "packages": [
{ {
"name": "adhocore/jwt", "name": "adhocore/jwt",
@ -2051,16 +2051,16 @@
}, },
{ {
"name": "utopia-php/database", "name": "utopia-php/database",
"version": "dev-feat-permissions-maxlength", "version": "0.18.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/database.git", "url": "https://github.com/utopia-php/database.git",
"reference": "85c304075bb42b91e3cb98762921f15fa28af13c" "reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/85c304075bb42b91e3cb98762921f15fa28af13c", "url": "https://api.github.com/repos/utopia-php/database/zipball/d542ee433f1a545d926ffaf707bdf952dc18a52e",
"reference": "85c304075bb42b91e3cb98762921f15fa28af13c", "reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2109,9 +2109,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/database/issues", "issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/feat-permissions-maxlength" "source": "https://github.com/utopia-php/database/tree/0.18.7"
}, },
"time": "2022-07-10T17:08:47+00:00" "time": "2022-07-11T10:20:33+00:00"
}, },
{ {
"name": "utopia-php/domains", "name": "utopia-php/domains",
@ -5346,18 +5346,9 @@
"time": "2022-05-17T05:48:52+00:00" "time": "2022-05-17T05:48:52+00:00"
} }
], ],
"aliases": [ "aliases": [],
{
"package": "utopia-php/database",
"version": "dev-feat-permissions-maxlength",
"alias": "0.18.1",
"alias_normalized": "0.18.1.0"
}
],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": [],
"utopia-php/database": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {

View file

@ -115,10 +115,10 @@ class DatabasePool {
* *
* Function to return the name of the database from the project ID * Function to return the name of the database from the project ID
*/ */
private function getName(string $projectID, \Redis $redis): string private function getName(string $projectID, \Redis $redis): array
{ {
if ($projectID === 'console') { if ($projectID === 'console') {
return $this->consoleDB; return [$this->consoleDB, 'console'];
} }
$pdo = $this->getPDO($this->consoleDB); $pdo = $this->getPDO($this->consoleDB);
@ -128,9 +128,10 @@ class DatabasePool {
$database->setNamespace("_console"); $database->setNamespace("_console");
$project = Authorization::skip(fn() => $database->getDocument('projects', $projectID)); $project = Authorization::skip(fn() => $database->getDocument('projects', $projectID));
$internalID = $project->getInternalId();
$database = $project->getAttribute('database', ''); $database = $project->getAttribute('database', '');
return $database; return [$database, $internalID];
} }
/** /**
@ -143,7 +144,7 @@ class DatabasePool {
public function getDB(string $projectID, \Redis $redis): ?Database public function getDB(string $projectID, \Redis $redis): ?Database
{ {
/** Get DB name from the console database */ /** Get DB name from the console database */
$name = $this->getName($projectID, $redis); [$name, $internalID] = $this->getName($projectID, $redis);
if (empty($name)) { if (empty($name)) {
throw new Exception("Database with name : $name not found.", 500); throw new Exception("Database with name : $name not found.", 500);
@ -154,7 +155,7 @@ class DatabasePool {
$cache = new Cache(new RedisCache($redis)); $cache = new Cache(new RedisCache($redis));
$database = new Database(new MariaDB($pdo), $cache); $database = new Database(new MariaDB($pdo), $cache);
$database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
$database->setNamespace("_{$projectID}"); $database->setNamespace("_{$internalID}");
return $database; return $database;
} }
@ -175,10 +176,10 @@ class DatabasePool {
public function getDBFromPool(string $projectID, \Redis $redis): array public function getDBFromPool(string $projectID, \Redis $redis): array
{ {
/** Get DB name from the console database */ /** Get DB name from the console database */
$name = $this->getName($projectID, $redis); [$name, $internalID] = $this->getName($projectID, $redis);
$pool = $this->pools[$name] ?? throw new Exception("Database pool with name : $name not found. Check the value of _APP_PROJECT_DB in .env", 500); $pool = $this->pools[$name] ?? throw new Exception("Database pool with name : $name not found. Check the value of _APP_PROJECT_DB in .env", 500);
$namespace = "_$projectID"; $namespace = "_$internalID";
$attempts = 0; $attempts = 0;
do { do {
try { try {