mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Refactor Auth::encodeCredentials to remove utf8_encode and update Client constructor to conditionally use coroutines
This commit is contained in:
1 parent
b7a4901f55
commit
da2237950b
2 files changed
+17
-2
No files matched your search
+1
-1
@@ -283,6 +283,6 @@ class Auth
|
||||
*/
|
||||
public static function encodeCredentials($username, $password): string
|
||||
{
|
||||
return \md5(\utf8_encode($username . ':mongo:' . $password));
|
||||
return \md5($username . ':mongo:' . $password);
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -7,6 +7,9 @@ use MongoDB\BSON\ObjectId;
|
||||
use Swoole\Client as SwooleClient;
|
||||
use Swoole\Coroutine\Client as CoroutineClient;
|
||||
use stdClass;
|
||||
use Swoole\Coroutine;
|
||||
|
||||
|
||||
|
||||
class Client
|
||||
{
|
||||
@@ -78,13 +81,25 @@ class Client
|
||||
int $port,
|
||||
string $user,
|
||||
string $password,
|
||||
bool $useCoroutine = true
|
||||
bool $useCoroutine = false
|
||||
) {
|
||||
$this->id = uniqid('utopia.mongo.client');
|
||||
$this->database = $database;
|
||||
$this->host = $host;
|
||||
$this->port = $port;
|
||||
|
||||
// Only use coroutines if explicitly requested and we're in a coroutine context
|
||||
if ($useCoroutine) {
|
||||
try {
|
||||
$cid = \Swoole\Coroutine::getCid();
|
||||
if ($cid === false || $cid === 0) {
|
||||
$useCoroutine = false;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$useCoroutine = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->client = $useCoroutine
|
||||
? new CoroutineClient(SWOOLE_SOCK_TCP | SWOOLE_KEEP)
|
||||
: new SwooleClient(SWOOLE_SOCK_TCP | SWOOLE_KEEP);
|
||||
|
||||
Reference in new issue
Block a user