mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #12616 from appwrite/fix/drop-pdoproxy
refactor(database): drop Swoole PDOProxy, construct Utopia\Database\PDO directly
This commit is contained in:
4 files changed
+109
-60
No files matched your search
+16
-19
@@ -6,7 +6,6 @@ use Appwrite\Hooks\Hooks;
|
||||
use Appwrite\PubSub\Adapter\Redis as PubSub;
|
||||
use Appwrite\URL\URL as AppwriteURL;
|
||||
use MaxMind\Db\Reader;
|
||||
use Swoole\Database\PDOProxy;
|
||||
use Utopia\Cache\Adapter\Redis as RedisCache;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Console;
|
||||
@@ -291,15 +290,14 @@ $register->set('pools', function () {
|
||||
$resource = match ($dsnScheme) {
|
||||
'mysql',
|
||||
'mariadb' => function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
return new PDOProxy(function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
return new PDO("mysql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};charset=utf8mb4", $dsnUser, $dsnPass, [
|
||||
\PDO::ATTR_TIMEOUT => 3, // Seconds
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
\PDO::ATTR_EMULATE_PREPARES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true
|
||||
]);
|
||||
});
|
||||
return new PDO("mysql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};charset=utf8mb4", $dsnUser, $dsnPass, [
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_TIMEOUT => 3, // Seconds
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
\PDO::ATTR_EMULATE_PREPARES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true
|
||||
]);
|
||||
},
|
||||
'mongodb' => function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
try {
|
||||
@@ -312,15 +310,14 @@ $register->set('pools', function () {
|
||||
}
|
||||
},
|
||||
'postgresql' => function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
return new PDOProxy(function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
return new PDO("pgsql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};connect_timeout=3", $dsnUser, $dsnPass, array(
|
||||
\PDO::ATTR_TIMEOUT => 3, // Seconds
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
\PDO::ATTR_EMULATE_PREPARES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true
|
||||
));
|
||||
});
|
||||
return new PDO("pgsql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};connect_timeout=3", $dsnUser, $dsnPass, array(
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_TIMEOUT => 3, // Seconds
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
\PDO::ATTR_EMULATE_PREPARES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true
|
||||
));
|
||||
},
|
||||
default => function () use ($dsnHost, $dsnPort, $dsnPass) {
|
||||
$redis = new \Redis();
|
||||
|
||||
+4
-4
@@ -53,17 +53,17 @@
|
||||
"ext-sockets": "*",
|
||||
"appwrite/php-runtimes": "0.20.*",
|
||||
"appwrite/php-clamav": "2.0.*",
|
||||
"utopia-php/abuse": "1.3.*",
|
||||
"utopia-php/abuse": "1.4.*",
|
||||
"utopia-php/agents": "2.*",
|
||||
"utopia-php/analytics": "0.15.*",
|
||||
"utopia-php/audit": "^2.4",
|
||||
"utopia-php/audit": "2.5.*",
|
||||
"utopia-php/auth": "0.5.*",
|
||||
"utopia-php/cache": "^3.0",
|
||||
"utopia-php/cli": "^0.24",
|
||||
"utopia-php/compression": "0.1.*",
|
||||
"utopia-php/config": "1.*",
|
||||
"utopia-php/console": "0.1.*",
|
||||
"utopia-php/database": "5.*",
|
||||
"utopia-php/database": "6.0.*",
|
||||
"utopia-php/detector": "0.2.*",
|
||||
"utopia-php/domains": "^2.2",
|
||||
"utopia-php/emails": "0.7.*",
|
||||
@@ -77,7 +77,7 @@
|
||||
"utopia-php/lock": "0.2.*",
|
||||
"utopia-php/logger": "0.8.*",
|
||||
"utopia-php/messaging": "^1.1",
|
||||
"utopia-php/migration": "1.*",
|
||||
"utopia-php/migration": "1.14.*",
|
||||
"utopia-php/platform": "^1.0@RC",
|
||||
"utopia-php/pools": "1.*",
|
||||
"utopia-php/span": "3.0.*",
|
||||
|
||||
Generated
+37
-37
@@ -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": "2dfcf2f234c0ef563a0ee4b47534ddc5",
|
||||
"content-hash": "264c11d2628eeebe5722497eca10e576",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
@@ -69,16 +69,16 @@
|
||||
},
|
||||
{
|
||||
"name": "appwrite/appwrite",
|
||||
"version": "24.2.0",
|
||||
"version": "26.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/appwrite/sdk-for-php.git",
|
||||
"reference": "d3217b6524b9d174ab91fb7ffc555c68bfa1da97"
|
||||
"reference": "533865f24f306cf6ac6f1737965553a5c54672e0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/d3217b6524b9d174ab91fb7ffc555c68bfa1da97",
|
||||
"reference": "d3217b6524b9d174ab91fb7ffc555c68bfa1da97",
|
||||
"url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/533865f24f306cf6ac6f1737965553a5c54672e0",
|
||||
"reference": "533865f24f306cf6ac6f1737965553a5c54672e0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -88,7 +88,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "1.6.12",
|
||||
"phpunit/phpunit": "^10"
|
||||
"phpunit/phpunit": "^12"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@@ -104,10 +104,10 @@
|
||||
"support": {
|
||||
"email": "team@appwrite.io",
|
||||
"issues": "https://github.com/appwrite/sdk-for-php/issues",
|
||||
"source": "https://github.com/appwrite/sdk-for-php/tree/24.2.0",
|
||||
"source": "https://github.com/appwrite/sdk-for-php/tree/26.1.0",
|
||||
"url": "https://appwrite.io/support"
|
||||
},
|
||||
"time": "2026-05-21T18:56:51+00:00"
|
||||
"time": "2026-06-19T08:16:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "appwrite/php-clamav",
|
||||
@@ -3118,25 +3118,25 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/abuse",
|
||||
"version": "1.3.1",
|
||||
"version": "1.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/abuse.git",
|
||||
"reference": "00e59c89a1ac5f4ad771695e5dbee020b3c7ac44"
|
||||
"reference": "8f5df0274869cf9022eea7d8030ca1a0d458b3b2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/00e59c89a1ac5f4ad771695e5dbee020b3c7ac44",
|
||||
"reference": "00e59c89a1ac5f4ad771695e5dbee020b3c7ac44",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/8f5df0274869cf9022eea7d8030ca1a0d458b3b2",
|
||||
"reference": "8f5df0274869cf9022eea7d8030ca1a0d458b3b2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"appwrite/appwrite": "24.*",
|
||||
"appwrite/appwrite": "^26.0",
|
||||
"ext-curl": "*",
|
||||
"ext-pdo": "*",
|
||||
"ext-redis": "*",
|
||||
"php": ">=8.2",
|
||||
"utopia-php/database": "5.*"
|
||||
"utopia-php/database": "^6.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "1.*",
|
||||
@@ -3164,9 +3164,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/abuse/issues",
|
||||
"source": "https://github.com/utopia-php/abuse/tree/1.3.1"
|
||||
"source": "https://github.com/utopia-php/abuse/tree/1.4.1"
|
||||
},
|
||||
"time": "2026-06-03T07:30:05+00:00"
|
||||
"time": "2026-06-18T11:18:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/agents",
|
||||
@@ -3269,21 +3269,21 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/audit",
|
||||
"version": "2.4.2",
|
||||
"version": "2.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/audit.git",
|
||||
"reference": "6f15caaac5455c98cec06e02fe8da3af9477ff38"
|
||||
"reference": "d9e9bb50f2150e0a7ccbe24668ff7230e7cb7a20"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/6f15caaac5455c98cec06e02fe8da3af9477ff38",
|
||||
"reference": "6f15caaac5455c98cec06e02fe8da3af9477ff38",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/d9e9bb50f2150e0a7ccbe24668ff7230e7cb7a20",
|
||||
"reference": "d9e9bb50f2150e0a7ccbe24668ff7230e7cb7a20",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.4",
|
||||
"utopia-php/database": "5.*",
|
||||
"utopia-php/database": "^6.0.0",
|
||||
"utopia-php/fetch": "^1.1",
|
||||
"utopia-php/query": "0.1.*",
|
||||
"utopia-php/validators": "0.2.*"
|
||||
@@ -3313,9 +3313,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/audit/issues",
|
||||
"source": "https://github.com/utopia-php/audit/tree/2.4.2"
|
||||
"source": "https://github.com/utopia-php/audit/tree/2.5.0"
|
||||
},
|
||||
"time": "2026-06-03T03:42:22+00:00"
|
||||
"time": "2026-06-18T11:19:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/auth",
|
||||
@@ -3682,16 +3682,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "5.9.2",
|
||||
"version": "6.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "698952455dd645ff41057621c90a4cea977fb1bf"
|
||||
"reference": "fff9f0effbd40359ff925741ff9424856d8b4fde"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/698952455dd645ff41057621c90a4cea977fb1bf",
|
||||
"reference": "698952455dd645ff41057621c90a4cea977fb1bf",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/fff9f0effbd40359ff925741ff9424856d8b4fde",
|
||||
"reference": "fff9f0effbd40359ff925741ff9424856d8b4fde",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3736,9 +3736,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/5.9.2"
|
||||
"source": "https://github.com/utopia-php/database/tree/6.0.0"
|
||||
},
|
||||
"time": "2026-06-12T08:33:14+00:00"
|
||||
"time": "2026-06-18T10:37:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
@@ -4406,25 +4406,25 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/migration",
|
||||
"version": "1.13.2",
|
||||
"version": "1.14.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/migration.git",
|
||||
"reference": "50526e121efcf73e11309446f194623a431d7e32"
|
||||
"reference": "f70dba326f1499d1ff4dd18b218b26a858aff1dd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/50526e121efcf73e11309446f194623a431d7e32",
|
||||
"reference": "50526e121efcf73e11309446f194623a431d7e32",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/f70dba326f1499d1ff4dd18b218b26a858aff1dd",
|
||||
"reference": "f70dba326f1499d1ff4dd18b218b26a858aff1dd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"appwrite/appwrite": "24.*",
|
||||
"appwrite/appwrite": "^26.0",
|
||||
"ext-curl": "*",
|
||||
"ext-openssl": "*",
|
||||
"halaxa/json-machine": "^1.2",
|
||||
"php": ">=8.2",
|
||||
"utopia-php/database": "5.*",
|
||||
"utopia-php/database": "^6.0.0",
|
||||
"utopia-php/dsn": "0.2.*",
|
||||
"utopia-php/storage": "2.*"
|
||||
},
|
||||
@@ -4455,9 +4455,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/migration/issues",
|
||||
"source": "https://github.com/utopia-php/migration/tree/1.13.2"
|
||||
"source": "https://github.com/utopia-php/migration/tree/1.14.0"
|
||||
},
|
||||
"time": "2026-06-04T05:09:07+00:00"
|
||||
"time": "2026-06-18T11:19:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/mongo",
|
||||
|
||||
@@ -4,7 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Utopia;
|
||||
|
||||
use Appwrite\Models\Project as GeneratedProject;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model\Project as ProjectModel;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionProperty;
|
||||
@@ -110,6 +112,56 @@ final class ResponseTest extends TestCase
|
||||
]), 'single');
|
||||
}
|
||||
|
||||
public function testProjectResponseCanHydrateGeneratedSdkProjectWithoutOAuth2Fields(): void
|
||||
{
|
||||
$this->response->setModel(new ProjectModel());
|
||||
|
||||
$project = $this->response->output(new Document([
|
||||
'$id' => 'project',
|
||||
'$createdAt' => '2026-06-19T00:00:00.000+00:00',
|
||||
'$updatedAt' => '2026-06-19T00:00:00.000+00:00',
|
||||
'name' => 'Project',
|
||||
'teamId' => 'team',
|
||||
'region' => 'default',
|
||||
]), Response::MODEL_PROJECT);
|
||||
|
||||
$generated = GeneratedProject::from($project);
|
||||
|
||||
foreach ([
|
||||
'oAuth2ServerEnabled',
|
||||
'oAuth2ServerAuthorizationUrl',
|
||||
'oAuth2ServerScopes',
|
||||
'oAuth2ServerAuthorizationDetailsTypes',
|
||||
'oAuth2ServerAccessTokenDuration',
|
||||
'oAuth2ServerRefreshTokenDuration',
|
||||
'oAuth2ServerPublicAccessTokenDuration',
|
||||
'oAuth2ServerPublicRefreshTokenDuration',
|
||||
'oAuth2ServerConfidentialPkce',
|
||||
'oAuth2ServerVerificationUrl',
|
||||
'oAuth2ServerUserCodeLength',
|
||||
'oAuth2ServerUserCodeFormat',
|
||||
'oAuth2ServerDeviceCodeDuration',
|
||||
'oAuth2ServerDiscoveryUrl',
|
||||
] as $key) {
|
||||
$this->assertArrayNotHasKey($key, $project);
|
||||
}
|
||||
|
||||
$this->assertNull($generated->oAuth2ServerEnabled);
|
||||
$this->assertNull($generated->oAuth2ServerAuthorizationUrl);
|
||||
$this->assertNull($generated->oAuth2ServerScopes);
|
||||
$this->assertNull($generated->oAuth2ServerAuthorizationDetailsTypes);
|
||||
$this->assertNull($generated->oAuth2ServerAccessTokenDuration);
|
||||
$this->assertNull($generated->oAuth2ServerRefreshTokenDuration);
|
||||
$this->assertNull($generated->oAuth2ServerPublicAccessTokenDuration);
|
||||
$this->assertNull($generated->oAuth2ServerPublicRefreshTokenDuration);
|
||||
$this->assertNull($generated->oAuth2ServerConfidentialPkce);
|
||||
$this->assertNull($generated->oAuth2ServerVerificationUrl);
|
||||
$this->assertNull($generated->oAuth2ServerUserCodeLength);
|
||||
$this->assertNull($generated->oAuth2ServerUserCodeFormat);
|
||||
$this->assertNull($generated->oAuth2ServerDeviceCodeDuration);
|
||||
$this->assertNull($generated->oAuth2ServerDiscoveryUrl);
|
||||
}
|
||||
|
||||
public function testResponseModelLists(): void
|
||||
{
|
||||
$output = $this->response->output(new Document([
|
||||
|
||||
Reference in new issue
Block a user