mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 16:31:11 +01:00
Fix connection to the database when a password is accidentally provided but none is required
This commit is contained in:
parent
909ed2f238
commit
1b6d7e5a36
@ -699,8 +699,8 @@ Want to add your own open-source project to this list? [Click here!](https://doc
|
||||
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.updatePinnedMessage.html" name="messages.updatePinnedMessage">Pin a message: messages.updatePinnedMessage</a>
|
||||
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.updatePinnedForumTopic.html" name="channels.updatePinnedForumTopic">Pin or unpin forum topics: channels.updatePinnedForumTopic</a>
|
||||
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.toggleDialogPin.html" name="messages.toggleDialogPin">Pin/unpin a dialog: messages.toggleDialogPin</a>
|
||||
* <a href="https://docs.madelineproto.xyz/PHP/danog/MadelineProto/API.html#callplay-int-id-danog-madelineproto-localfile-danog-madelineproto-remoteurl-danog-madelineproto-ipc-wrapper-readablestream-string-file-void" name="callPlay">Play file in call: callPlay</a>
|
||||
* <a href="https://docs.madelineproto.xyz/PHP/danog/MadelineProto/API.html#callplayonhold-int-id-string-localfile-remoteurl-amp-bytestream-readablestream-files-void" name="callPlayOnHold">Play files on hold in call: callPlayOnHold</a>
|
||||
* <a href="https://docs.madelineproto.xyz/PHP/danog/MadelineProto/API.html#callplay-int-id-danog-madelineproto-localfile-danog-madelineproto-remoteurl-amp-bytestream-readablestream-file-void" name="callPlay">Play file in call: callPlay</a>
|
||||
* <a href="https://docs.madelineproto.xyz/PHP/danog/MadelineProto/API.html#callplayonhold-int-id-localfile-remoteurl-amp-bytestream-readablestream-files-void" name="callPlayOnHold">Play files on hold in call: callPlayOnHold</a>
|
||||
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getMessages.html" name="channels.getMessages">Please use the event handler: channels.getMessages</a>
|
||||
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getHistory.html" name="messages.getHistory">Please use the event handler: messages.getHistory</a>
|
||||
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getMessages.html" name="messages.getMessages">Please use the event handler: messages.getMessages</a>
|
||||
|
@ -91,7 +91,10 @@
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"danog\\MadelineProto\\": "src"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"src/polyfill.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
|
2
docs
2
docs
@ -1 +1 @@
|
||||
Subproject commit 3c53d289d2cf28630f61c267067be80d7b80712b
|
||||
Subproject commit 71f5df203c83c7ef7f4454c09966e03a2f6307da
|
@ -313,7 +313,9 @@ class MyEventHandler extends SimpleEventHandler
|
||||
$settings = new Settings;
|
||||
$settings->getLogger()->setLevel(Logger::LEVEL_ULTRA_VERBOSE);
|
||||
|
||||
// You can also use Redis, MySQL or PostgreSQL
|
||||
// You can also use Redis, MySQL or PostgreSQL.
|
||||
// Data is migrated automatically.
|
||||
//
|
||||
// $settings->setDb((new Redis)->setDatabase(0)->setPassword('pony'));
|
||||
// $settings->setDb((new Postgres)->setDatabase('MadelineProto')->setUsername('daniil')->setPassword('pony'));
|
||||
// $settings->setDb((new Mysql)->setDatabase('MadelineProto')->setUsername('daniil')->setPassword('pony'));
|
||||
|
@ -23,6 +23,7 @@ use danog\MadelineProto\Exception;
|
||||
use danog\MadelineProto\Logger;
|
||||
use danog\MadelineProto\Settings\Database\Mysql as DatabaseMysql;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@ -58,13 +59,23 @@ final class Mysql
|
||||
throw Exception::extension('pdo_mysql');
|
||||
}
|
||||
|
||||
self::$connections[$dbKey] = [
|
||||
new MysqlConnectionPool($config, $settings->getMaxConnections(), $settings->getIdleTimeout()),
|
||||
new PDO(
|
||||
try {
|
||||
$pdo = new PDO(
|
||||
"mysql:host={$host};port={$port};charset=UTF8",
|
||||
$settings->getUsername(),
|
||||
$settings->getPassword(),
|
||||
)
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
$config = $config->withPassword(null);
|
||||
$pdo = new PDO(
|
||||
"mysql:host={$host};port={$port};charset=UTF8",
|
||||
$settings->getUsername(),
|
||||
);
|
||||
}
|
||||
|
||||
self::$connections[$dbKey] = [
|
||||
new MysqlConnectionPool($config, $settings->getMaxConnections(), $settings->getIdleTimeout()),
|
||||
$pdo
|
||||
];
|
||||
}
|
||||
} finally {
|
||||
|
@ -121,5 +121,3 @@ final class MemoryArray extends ArrayIterator implements DbArray
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
\class_alias(MemoryArray::class, '\\danog\\MadelineProto\\Db\\NullCache\\MemoryArray');
|
||||
|
@ -142,5 +142,3 @@ final class MysqlArray extends SqlArray
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
\class_alias(MysqlArray::class, '\\danog\\MadelineProto\\Db\\NullCache\\MysqlArray');
|
||||
|
@ -109,5 +109,3 @@ final class PostgresArray extends PostgresArrayBytea
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
\class_alias(PostgresArray::class, '\\danog\\MadelineProto\\Db\\NullCache\\PostgresArray');
|
||||
|
@ -127,5 +127,3 @@ class PostgresArrayBytea extends SqlArray
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
\class_alias(PostgresArrayBytea::class, '\\danog\\MadelineProto\\Db\\NullCache\\PostgresArrayBytea');
|
||||
|
@ -155,5 +155,3 @@ final class RedisArray extends DriverArray
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\class_alias(RedisArray::class, '\\danog\\MadelineProto\\Db\\NullCache\\RedisArray');
|
||||
|
@ -242,7 +242,6 @@ final class MinDatabase implements TLCallback
|
||||
public function clearPeer(int $id): void
|
||||
{
|
||||
unset($this->db[$id], $this->pendingDb[$id]);
|
||||
|
||||
}
|
||||
public function __debugInfo()
|
||||
{
|
||||
|
14
src/polyfill.php
Normal file
14
src/polyfill.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
if (class_exists('\\danog\\MadelineProto\\Db\\NullCache\\MysqlArray')) {
|
||||
return;
|
||||
}
|
||||
use danog\MadelineProto\Db\MysqlArray;
|
||||
use danog\MadelineProto\Db\PostgresArray;
|
||||
use danog\MadelineProto\Db\PostgresArrayBytea;
|
||||
use danog\MadelineProto\Db\RedisArray;
|
||||
|
||||
class_alias(MysqlArray::class, '\\danog\\MadelineProto\\Db\\NullCache\\MysqlArray');
|
||||
class_alias(PostgresArray::class, '\\danog\\MadelineProto\\Db\\NullCache\\PostgresArray');
|
||||
class_alias(PostgresArrayBytea::class, '\\danog\\MadelineProto\\Db\\NullCache\\PostgresArrayBytea');
|
||||
class_alias(RedisArray::class, '\\danog\\MadelineProto\\Db\\NullCache\\RedisArray');
|
Loading…
x
Reference in New Issue
Block a user