1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 06:59:01 +01:00

Even more migration fixes

This commit is contained in:
Daniil Gentili 2024-04-06 21:40:04 +02:00
parent a29164a0d0
commit a6e5e5e354
7 changed files with 57 additions and 18 deletions

View File

@ -24,7 +24,6 @@ use Amp\DeferredFuture;
use Amp\Future;
use Amp\Sync\LocalMutex;
use AssertionError;
use danog\AsyncOrm\DbAutoProperties;
use danog\Loop\PeriodicLoop;
use danog\MadelineProto\EventHandler\Attributes\Cron;
use danog\MadelineProto\EventHandler\Attributes\Handler;
@ -49,9 +48,9 @@ use function Amp\File\listFiles;
*/
abstract class EventHandler extends AbstractAPI
{
use DbAutoProperties {
DbAutoProperties::initDbProperties as private internalInitDbProperties;
DbAutoProperties::saveDbProperties as private privateInternalSaveDbProperties;
use LegacyMigrator {
LegacyMigrator::initDbProperties as private internalInitDbProperties;
LegacyMigrator::saveDbProperties as private privateInternalSaveDbProperties;
}
/** @internal Do not use manually. */

View File

@ -37,7 +37,6 @@ use AssertionError;
use danog\AsyncOrm\Annotations\OrmMappedArray;
use danog\AsyncOrm\DbArray;
use danog\AsyncOrm\DbArrayBuilder;
use danog\AsyncOrm\DbAutoProperties;
use danog\AsyncOrm\Driver\MemoryArray;
use danog\AsyncOrm\KeyType;
use danog\AsyncOrm\Settings as OrmSettings;
@ -117,9 +116,9 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
use Login;
use Loop;
use Start;
use DbAutoProperties {
DbAutoProperties::initDbProperties as private internalInitDbProperties;
DbAutoProperties::saveDbProperties as private internalSaveDbProperties;
use LegacyMigrator {
LegacyMigrator::initDbProperties as private internalInitDbProperties;
LegacyMigrator::saveDbProperties as private internalSaveDbProperties;
}
use Broadcast;
private const MAX_ENTITY_LENGTH = 100;

View File

@ -23,10 +23,10 @@ namespace danog\MadelineProto\MTProtoTools;
use Amp\Sync\LocalKeyedMutex;
use danog\AsyncOrm\Annotations\OrmMappedArray;
use danog\AsyncOrm\DbArray;
use danog\AsyncOrm\DbAutoProperties;
use danog\AsyncOrm\KeyType;
use danog\AsyncOrm\ValueType;
use danog\MadelineProto\Exception;
use danog\MadelineProto\LegacyMigrator;
use danog\MadelineProto\Logger;
use danog\MadelineProto\MTProto;
use danog\MadelineProto\TL\TLCallback;
@ -39,7 +39,7 @@ use Revolt\EventLoop;
*/
final class MinDatabase implements TLCallback
{
use DbAutoProperties;
use LegacyMigrator;
public const SWITCH_CONSTRUCTORS = ['inputChannel', 'inputUser', 'inputPeerUser', 'inputPeerChannel'];
public const CATCH_PEERS = ['message', 'messageService', 'peerUser', 'peerChannel', 'messageEntityMentionName', 'messageFwdHeader', 'messageActionChatCreate', 'messageActionChatAddUser', 'messageActionChatDeleteUser', 'messageActionChatJoinedByLink'];

View File

@ -25,10 +25,10 @@ use Amp\Sync\LocalMutex;
use AssertionError;
use danog\AsyncOrm\Annotations\OrmMappedArray;
use danog\AsyncOrm\DbArray;
use danog\AsyncOrm\DbAutoProperties;
use danog\AsyncOrm\KeyType;
use danog\AsyncOrm\ValueType;
use danog\MadelineProto\Exception;
use danog\MadelineProto\LegacyMigrator;
use danog\MadelineProto\Logger;
use danog\MadelineProto\MTProto;
use danog\MadelineProto\PeerNotInDbException;
@ -47,7 +47,7 @@ use Webmozart\Assert\Assert;
*/
final class PeerDatabase implements TLCallback
{
use DbAutoProperties;
use LegacyMigrator;
private const V = 0;

View File

@ -23,10 +23,10 @@ namespace danog\MadelineProto\MTProtoTools;
use Amp\Sync\LocalKeyedMutex;
use danog\AsyncOrm\Annotations\OrmMappedArray;
use danog\AsyncOrm\DbArray;
use danog\AsyncOrm\DbAutoProperties;
use danog\AsyncOrm\KeyType;
use danog\AsyncOrm\ValueType;
use danog\MadelineProto\Exception;
use danog\MadelineProto\LegacyMigrator;
use danog\MadelineProto\Logger;
use danog\MadelineProto\MTProto;
use danog\MadelineProto\MTProto\MTProtoOutgoingMessage;
@ -42,7 +42,7 @@ use Webmozart\Assert\Assert;
*/
final class ReferenceDatabase implements TLCallback
{
use DbAutoProperties;
use LegacyMigrator;
// Reference from a document
public const DOCUMENT_LOCATION = 0;

View File

@ -26,9 +26,9 @@ use Amp\Sync\LocalMutex;
use AssertionError;
use danog\AsyncOrm\Annotations\OrmMappedArray;
use danog\AsyncOrm\DbArray;
use danog\AsyncOrm\DbAutoProperties;
use danog\AsyncOrm\KeyType;
use danog\AsyncOrm\ValueType;
use danog\MadelineProto\LegacyMigrator;
use danog\MadelineProto\Logger;
use danog\MadelineProto\Loop\Secret\SecretFeedLoop;
use danog\MadelineProto\Loop\Update\UpdateLoop;
@ -51,7 +51,7 @@ use Webmozart\Assert\Assert;
*/
final class SecretChatController implements Stringable
{
use DbAutoProperties;
use LegacyMigrator;
/**
* @var DbArray<int, array>

View File

@ -1,12 +1,16 @@
<?php declare(strict_types=1);
namespace danog\MadelineProto\Db;
if (class_exists('\\danog\\MadelineProto\\Db\\NullCache\\MysqlArray')) {
return;
}
use AssertionError;
use danog\AsyncOrm\DbArray;
use danog\AsyncOrm\DbArrayBuilder;
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\PostgresArray;
use danog\AsyncOrm\Internal\Driver\RedisArray;
@ -20,9 +24,46 @@ class_alias(PostgresArray::class, '\\danog\\MadelineProto\\Db\\PostgresArray');
class_alias(PostgresArray::class, '\\danog\\MadelineProto\\Db\\PostgresArrayBytea');
class_alias(RedisArray::class, '\\danog\\MadelineProto\\Db\\RedisArray');
class_alias(MemoryArray::class, '\\danog\\MadelineProto\\Db\\MemoryArray');
class_alias(CachedArray::class, '\\danog\\MadelineProto\\Db\\CachedArray');
class_alias(CacheContainer::class, '\\danog\\MadelineProto\\Db\\CacheContainer');
/** @deprecated */
final class CachedArray extends DbArray
{
private readonly CacheContainer $cache;
public function unset(string|int $key): void
{
throw new AssertionError("Unreachable");
}
public function set(string|int $key, mixed $value): void
{
throw new AssertionError("Unreachable");
}
public function get(string|int $key): mixed
{
throw new AssertionError("Unreachable");
}
public function clear(): void
{
throw new AssertionError("Unreachable");
}
public function count(): int
{
throw new AssertionError("Unreachable");
}
public function getIterator(): \Traversable
{
throw new AssertionError("Unreachable");
}
public static function getInstance(DbArrayBuilder $config, DbArray|null $previous): DbArray
{
throw new AssertionError("Unreachable");
}
}
if ((PHP_MINOR_VERSION === 2 && PHP_VERSION_ID < 80204)
|| PHP_MAJOR_VERSION < 8
|| (PHP_MAJOR_VERSION === 8 && PHP_MINOR_VERSION < 2)