mirror of
https://github.com/danog/MadelineProto.git
synced 2024-12-02 10:17:46 +01:00
More migration fixes
This commit is contained in:
parent
2c340f9963
commit
c955345b22
@ -36,6 +36,7 @@ use Amp\Sync\LocalMutex;
|
|||||||
use AssertionError;
|
use AssertionError;
|
||||||
use danog\AsyncOrm\Annotations\OrmMappedArray;
|
use danog\AsyncOrm\Annotations\OrmMappedArray;
|
||||||
use danog\AsyncOrm\DbArray;
|
use danog\AsyncOrm\DbArray;
|
||||||
|
use danog\AsyncOrm\DbArrayBuilder;
|
||||||
use danog\AsyncOrm\DbAutoProperties;
|
use danog\AsyncOrm\DbAutoProperties;
|
||||||
use danog\AsyncOrm\Driver\MemoryArray;
|
use danog\AsyncOrm\Driver\MemoryArray;
|
||||||
use danog\AsyncOrm\KeyType;
|
use danog\AsyncOrm\KeyType;
|
||||||
@ -422,7 +423,12 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
|||||||
$db []= async($this->event_handler_instance->internalSaveDbProperties(...));
|
$db []= async($this->event_handler_instance->internalSaveDbProperties(...));
|
||||||
}
|
}
|
||||||
await($db);
|
await($db);
|
||||||
return $this->getDbPrefix().'session';
|
return new DbArrayBuilder(
|
||||||
|
$this->getDbPrefix().'session',
|
||||||
|
$this->getDbSettings(),
|
||||||
|
KeyType::STRING,
|
||||||
|
ValueType::SCALAR
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,6 +107,7 @@ final class ReferenceDatabase implements TLCallback
|
|||||||
}
|
}
|
||||||
public function init(): void
|
public function init(): void
|
||||||
{
|
{
|
||||||
|
var_dump($this->db);
|
||||||
$this->initDbProperties($this->API->getDbSettings(), $this->API->getDbPrefix());
|
$this->initDbProperties($this->API->getDbSettings(), $this->API->getDbPrefix());
|
||||||
if ($this->v === 0) {
|
if ($this->v === 0) {
|
||||||
$this->db->clear();
|
$this->db->clear();
|
||||||
|
@ -220,29 +220,35 @@ abstract class Serialization
|
|||||||
} else {
|
} else {
|
||||||
$unserialized = null;
|
$unserialized = null;
|
||||||
}
|
}
|
||||||
if ($unserialized instanceof DriverArray || \is_string($unserialized) || !$exists) {
|
if ($unserialized instanceof DriverArray || $unserialized instanceof DbArrayBuilder || !$exists) {
|
||||||
if ($settings instanceof Settings) {
|
if ($settings instanceof Settings) {
|
||||||
$settings = $settings->getDb();
|
$settings = $settings->getDb();
|
||||||
}
|
}
|
||||||
|
$tableName = null;
|
||||||
|
$array = null;
|
||||||
if ($settings instanceof DriverDatabaseAbstract
|
if ($settings instanceof DriverDatabaseAbstract
|
||||||
&& $prefix = $settings->getEphemeralFilesystemPrefix()
|
&& $prefix = $settings->getEphemeralFilesystemPrefix()
|
||||||
) {
|
) {
|
||||||
$tableName = "{$prefix}_MTProto_session";
|
$tableName = "{$prefix}_MTProto_session";
|
||||||
} elseif ($unserialized instanceof DriverArray) {
|
} elseif ($unserialized instanceof DriverArray) {
|
||||||
$tableName = ((array) $unserialized)["\0*\0table"];
|
$unserialized = (array) $unserialized;
|
||||||
|
$tableName = $unserialized["\0*\0table"];
|
||||||
|
$settings = $unserialized["\0*\0dbSettings"];
|
||||||
} else {
|
} else {
|
||||||
$tableName = $unserialized;
|
\assert($unserialized instanceof DbArrayBuilder);
|
||||||
|
$array = $unserialized->build();
|
||||||
}
|
}
|
||||||
$unserialized = null;
|
|
||||||
if ($tableName !== null && $settings instanceof DriverDatabaseAbstract) {
|
if ($tableName !== null && $settings instanceof DriverDatabaseAbstract) {
|
||||||
Logger::log('Extracting session from database...');
|
Logger::log('Extracting session from database...');
|
||||||
$unserialized = (new DbArrayBuilder(
|
$array = (new DbArrayBuilder(
|
||||||
$tableName,
|
$tableName,
|
||||||
$settings->getOrmSettings(),
|
$settings->getOrmSettings(),
|
||||||
KeyType::STRING,
|
KeyType::STRING,
|
||||||
ValueType::SCALAR,
|
ValueType::SCALAR,
|
||||||
))->build()->get('data');
|
))->build();
|
||||||
}
|
}
|
||||||
|
\assert($array !== null);
|
||||||
|
$unserialized = $array->get('data');
|
||||||
if (!$unserialized && $exists) {
|
if (!$unserialized && $exists) {
|
||||||
throw new Exception('Could not extract session from database!');
|
throw new Exception('Could not extract session from database!');
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ if (class_exists('\\danog\\MadelineProto\\Db\\NullCache\\MysqlArray')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
use danog\AsyncOrm\Driver\MemoryArray;
|
use danog\AsyncOrm\Driver\MemoryArray;
|
||||||
|
use danog\AsyncOrm\Internal\Containers\CacheContainer;
|
||||||
|
use danog\AsyncOrm\Internal\Driver\CachedArray;
|
||||||
use danog\AsyncOrm\Internal\Driver\MysqlArray;
|
use danog\AsyncOrm\Internal\Driver\MysqlArray;
|
||||||
use danog\AsyncOrm\Internal\Driver\PostgresArray;
|
use danog\AsyncOrm\Internal\Driver\PostgresArray;
|
||||||
use danog\AsyncOrm\Internal\Driver\RedisArray;
|
use danog\AsyncOrm\Internal\Driver\RedisArray;
|
||||||
@ -18,6 +20,8 @@ class_alias(PostgresArray::class, '\\danog\\MadelineProto\\Db\\PostgresArray');
|
|||||||
class_alias(PostgresArray::class, '\\danog\\MadelineProto\\Db\\PostgresArrayBytea');
|
class_alias(PostgresArray::class, '\\danog\\MadelineProto\\Db\\PostgresArrayBytea');
|
||||||
class_alias(RedisArray::class, '\\danog\\MadelineProto\\Db\\RedisArray');
|
class_alias(RedisArray::class, '\\danog\\MadelineProto\\Db\\RedisArray');
|
||||||
class_alias(MemoryArray::class, '\\danog\\MadelineProto\\Db\\MemoryArray');
|
class_alias(MemoryArray::class, '\\danog\\MadelineProto\\Db\\MemoryArray');
|
||||||
|
class_alias(CachedArray::class, '\\danog\\MadelineProto\\Db\\CachedArray');
|
||||||
|
class_alias(CacheContainer::class, '\\danog\\MadelineProto\\Db\\CacheContainer');
|
||||||
|
|
||||||
if ((PHP_MINOR_VERSION === 2 && PHP_VERSION_ID < 80204)
|
if ((PHP_MINOR_VERSION === 2 && PHP_VERSION_ID < 80204)
|
||||||
|| PHP_MAJOR_VERSION < 8
|
|| PHP_MAJOR_VERSION < 8
|
||||||
|
@ -10,7 +10,6 @@ use danog\MadelineProto\Bug74586Exception;
|
|||||||
use danog\MadelineProto\Connection;
|
use danog\MadelineProto\Connection;
|
||||||
use danog\MadelineProto\DataCenter;
|
use danog\MadelineProto\DataCenter;
|
||||||
use danog\MadelineProto\DataCenterConnection;
|
use danog\MadelineProto\DataCenterConnection;
|
||||||
use danog\MadelineProto\Db\DbPropertiesTrait;
|
|
||||||
use danog\MadelineProto\Doc\MethodDoc;
|
use danog\MadelineProto\Doc\MethodDoc;
|
||||||
use danog\MadelineProto\Doc\NamespaceDoc;
|
use danog\MadelineProto\Doc\NamespaceDoc;
|
||||||
use danog\MadelineProto\DocsBuilder;
|
use danog\MadelineProto\DocsBuilder;
|
||||||
@ -110,9 +109,6 @@ $filter = static function (string $class) use ($ignore): bool {
|
|||||||
|| str_starts_with($class, 'danog\\MadelineProto\\Db\\NullCache')) {
|
|| str_starts_with($class, 'danog\\MadelineProto\\Db\\NullCache')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($class === DbPropertiesTrait::class) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$class = new ReflectionClass($class);
|
$class = new ReflectionClass($class);
|
||||||
return !$class->isTrait();
|
return !$class->isTrait();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user