feat: merge and fix conflicts
This commit is contained in:
parent
662800cc67
commit
6662fa7b7b
3 changed files with 20 additions and 28 deletions
|
@ -26,6 +26,7 @@ use Appwrite\Auth\Phone\Mock;
|
|||
use Appwrite\Auth\Phone\TextMagic;
|
||||
use Appwrite\Auth\Phone\Twilio;
|
||||
use Appwrite\Auth\Phone\Msg91;
|
||||
use Appwrite\Auth\Phone\Telesign;
|
||||
use Appwrite\Auth\Phone\Vonage;
|
||||
use Appwrite\DSN\DSN;
|
||||
use Appwrite\Event\Audit;
|
||||
|
@ -46,11 +47,10 @@ use Utopia\Locale\Locale;
|
|||
use Utopia\Registry\Registry;
|
||||
use MaxMind\Db\Reader;
|
||||
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\Database;
|
||||
use Appwrite\Database\DatabasePool;
|
||||
use Appwrite\Event\Delete;
|
||||
use Utopia\Database\Validator\Structure;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Validator\Range;
|
||||
|
|
27
composer.lock
generated
27
composer.lock
generated
|
@ -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": "eacaae6ec0973349a9b9f4ec78877b0a",
|
||||
"content-hash": "dedc6a6328b4fdc5dfbd556a08534403",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
@ -2051,16 +2051,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "dev-feat-permissions-maxlength",
|
||||
"version": "0.18.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "85c304075bb42b91e3cb98762921f15fa28af13c"
|
||||
"reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/85c304075bb42b91e3cb98762921f15fa28af13c",
|
||||
"reference": "85c304075bb42b91e3cb98762921f15fa28af13c",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/d542ee433f1a545d926ffaf707bdf952dc18a52e",
|
||||
"reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2109,9 +2109,9 @@
|
|||
],
|
||||
"support": {
|
||||
"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",
|
||||
|
@ -5346,18 +5346,9 @@
|
|||
"time": "2022-05-17T05:48:52+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [
|
||||
{
|
||||
"package": "utopia-php/database",
|
||||
"version": "dev-feat-permissions-maxlength",
|
||||
"alias": "0.18.1",
|
||||
"alias_normalized": "0.18.1.0"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"utopia-php/database": 20
|
||||
},
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
|
|
|
@ -115,10 +115,10 @@ class DatabasePool {
|
|||
*
|
||||
* 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') {
|
||||
return $this->consoleDB;
|
||||
return [$this->consoleDB, 'console'];
|
||||
}
|
||||
|
||||
$pdo = $this->getPDO($this->consoleDB);
|
||||
|
@ -128,9 +128,10 @@ class DatabasePool {
|
|||
$database->setNamespace("_console");
|
||||
|
||||
$project = Authorization::skip(fn() => $database->getDocument('projects', $projectID));
|
||||
$internalID = $project->getInternalId();
|
||||
$database = $project->getAttribute('database', '');
|
||||
|
||||
return $database;
|
||||
return [$database, $internalID];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,7 +144,7 @@ class DatabasePool {
|
|||
public function getDB(string $projectID, \Redis $redis): ?Database
|
||||
{
|
||||
/** Get DB name from the console database */
|
||||
$name = $this->getName($projectID, $redis);
|
||||
[$name, $internalID] = $this->getName($projectID, $redis);
|
||||
|
||||
if (empty($name)) {
|
||||
throw new Exception("Database with name : $name not found.", 500);
|
||||
|
@ -154,7 +155,7 @@ class DatabasePool {
|
|||
$cache = new Cache(new RedisCache($redis));
|
||||
$database = new Database(new MariaDB($pdo), $cache);
|
||||
$database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
|
||||
$database->setNamespace("_{$projectID}");
|
||||
$database->setNamespace("_{$internalID}");
|
||||
|
||||
return $database;
|
||||
}
|
||||
|
@ -175,10 +176,10 @@ class DatabasePool {
|
|||
public function getDBFromPool(string $projectID, \Redis $redis): array
|
||||
{
|
||||
/** 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);
|
||||
|
||||
$namespace = "_$projectID";
|
||||
$namespace = "_$internalID";
|
||||
$attempts = 0;
|
||||
do {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue