mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 07:18:57 +01:00
More BC fixes
This commit is contained in:
parent
a3eedc9504
commit
d0c62513c4
@ -4,7 +4,9 @@ namespace danog\MadelineProto;
|
||||
|
||||
use danog\AsyncOrm\Annotations\OrmMappedArray;
|
||||
use danog\AsyncOrm\DbAutoProperties;
|
||||
use danog\AsyncOrm\Driver\MemoryArray as DriverMemoryArray;
|
||||
use danog\MadelineProto\Db\CachedArray;
|
||||
use danog\MadelineProto\Db\MemoryArray;
|
||||
use ReflectionClass;
|
||||
|
||||
/** @internal */
|
||||
@ -17,8 +19,12 @@ trait LegacyMigrator
|
||||
{
|
||||
$res = [];
|
||||
$closure = function (string $propName): void {
|
||||
if (isset($this->{$propName}) && $this->{$propName} instanceof CachedArray) {
|
||||
unset($this->{$propName});
|
||||
if (isset($this->{$propName})) {
|
||||
if ($this->{$propName} instanceof CachedArray) {
|
||||
unset($this->{$propName});
|
||||
} elseif ($this->{$propName} instanceof MemoryArray) {
|
||||
$this->{$propName} = new DriverMemoryArray($this->{$propName}->getArrayCopy());
|
||||
}
|
||||
}
|
||||
};
|
||||
foreach ((new ReflectionClass(static::class))->getProperties() as $property) {
|
||||
|
@ -224,9 +224,10 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
/**
|
||||
* Cached parameters for fetching channel participants.
|
||||
*
|
||||
* @var DbArray<string, array>
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::STRING, ValueType::SCALAR)]
|
||||
public DbArray $channelParticipants;
|
||||
public $channelParticipants;
|
||||
/**
|
||||
* When we last stored data in remote peer database (now doesn't exist anymore).
|
||||
*
|
||||
@ -239,9 +240,11 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
public array $qres = [];
|
||||
/**
|
||||
* Sponsored message database.
|
||||
*
|
||||
* @var DbArray<int, array>
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::INT, ValueType::SCALAR)]
|
||||
public DbArray $sponsoredMessages;
|
||||
public $sponsoredMessages;
|
||||
/**
|
||||
* Latest chat message ID map for update handling.
|
||||
*
|
||||
@ -387,8 +390,8 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
/**
|
||||
* Nullcache array for storing main session file to DB.
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::STRING, ValueType::SCALAR, cacheTtl: 0, optimizeIfWastedMb: 1)]
|
||||
public DbArray $session;
|
||||
#[OrmMappedArray(KeyType::STRING, ValueType::SCALAR, cacheTtl: 0, optimizeIfWastedMb: 1, tablePostfix: 'session')]
|
||||
public DbArray $sessionDb;
|
||||
|
||||
/**
|
||||
* Returns an instance of a client by session name.
|
||||
@ -408,10 +411,10 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
public function serializeSession(object $data)
|
||||
{
|
||||
/** @psalm-suppress TypeDoesNotContainType */
|
||||
if (!isset($this->session) || $this->session instanceof MemoryArray) {
|
||||
if (!isset($this->sessionDb) || $this->sessionDb instanceof MemoryArray) {
|
||||
return $data;
|
||||
}
|
||||
$this->session['data'] = $data;
|
||||
$this->sessionDb['data'] = $data;
|
||||
|
||||
$db = [];
|
||||
$db []= async($this->referenceDatabase->saveDbProperties(...));
|
||||
|
@ -48,9 +48,10 @@ final class MinDatabase implements TLCallback
|
||||
/**
|
||||
* References indexed by location.
|
||||
*
|
||||
* @var DbArray<int, array>
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::INT, ValueType::SCALAR)]
|
||||
private DbArray $db;
|
||||
private $db;
|
||||
private array $pendingDb = [];
|
||||
/**
|
||||
* Temporary cache during deserialization.
|
||||
|
@ -58,17 +58,17 @@ final class PeerDatabase implements TLCallback
|
||||
* @var DbArray<int, array>
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::INT, ValueType::SCALAR, tablePostfix: 'MTProto_chats')]
|
||||
private DbArray $db;
|
||||
private $db;
|
||||
/**
|
||||
* @var DbArray<int, array>
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::INT, ValueType::SCALAR, tablePostfix: 'MTProto_full_chats')]
|
||||
private DbArray $fullDb;
|
||||
private $fullDb;
|
||||
/**
|
||||
* @var DbArray<string, int>
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::STRING, ValueType::INT)]
|
||||
private DbArray $usernames;
|
||||
private $usernames;
|
||||
private bool $hasInfo = true;
|
||||
private bool $hasUsernames = true;
|
||||
|
||||
|
@ -77,9 +77,10 @@ final class ReferenceDatabase implements TLCallback
|
||||
private const V = 1;
|
||||
/**
|
||||
* References indexed by location.
|
||||
* @var DbArray<string, array>
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::STRING, ValueType::SCALAR)]
|
||||
private DbArray $db;
|
||||
private $db;
|
||||
/**
|
||||
* @var array<string, list{string, int, array}>
|
||||
*/
|
||||
|
@ -144,8 +144,9 @@ trait UpdateHandler
|
||||
/** @deprecated */
|
||||
private CombinedUpdatesState $channels_state;
|
||||
private CombinedUpdatesState $updateState;
|
||||
/** @var DbArray<int, array> */
|
||||
#[OrmMappedArray(KeyType::INT, ValueType::SCALAR)]
|
||||
private DbArray $getUpdatesQueue;
|
||||
private $getUpdatesQueue;
|
||||
private int $getUpdatesQueueKey = 0;
|
||||
private SplQueue $updateQueue;
|
||||
|
||||
|
@ -57,17 +57,17 @@ final class SecretChatController implements Stringable
|
||||
* @var DbArray<int, array>
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::INT, ValueType::SCALAR)]
|
||||
private DbArray $incoming;
|
||||
private $incoming;
|
||||
/**
|
||||
* @var DbArray<int, array>
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::INT, ValueType::SCALAR)]
|
||||
private DbArray $outgoing;
|
||||
private $outgoing;
|
||||
/**
|
||||
* @var DbArray<int, list{int, bool}> Seq, outgoing
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::INT, ValueType::SCALAR)]
|
||||
private DbArray $randomIdMap;
|
||||
private $randomIdMap;
|
||||
private int $in_seq_no = 0;
|
||||
private int $out_seq_no = 0;
|
||||
private int $remote_in_seq_no = 0;
|
||||
|
@ -6,10 +6,11 @@ if (class_exists('\\danog\\MadelineProto\\Db\\NullCache\\MysqlArray')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use ArrayObject;
|
||||
use AssertionError;
|
||||
use Countable;
|
||||
use danog\AsyncOrm\DbArray;
|
||||
use danog\AsyncOrm\DbArrayBuilder;
|
||||
use danog\AsyncOrm\Driver\MemoryArray;
|
||||
use danog\AsyncOrm\Internal\Containers\CacheContainer;
|
||||
use danog\AsyncOrm\Internal\Driver\MysqlArray;
|
||||
use danog\AsyncOrm\Internal\Driver\PostgresArray;
|
||||
@ -23,9 +24,42 @@ class_alias(MysqlArray::class, '\\danog\\MadelineProto\\Db\\MysqlArray');
|
||||
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(CacheContainer::class, '\\danog\\MadelineProto\\Db\\CacheContainer');
|
||||
class_alias(Countable::class, '\\danog\\MadelineProto\\Db\\DbArray');
|
||||
|
||||
/** @deprecated */
|
||||
final class MemoryArray extends ArrayObject
|
||||
{
|
||||
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(): \Iterator
|
||||
{
|
||||
throw new AssertionError("Unreachable");
|
||||
}
|
||||
|
||||
public static function getInstance(DbArrayBuilder $config, DbArray|null $previous): DbArray
|
||||
{
|
||||
throw new AssertionError("Unreachable");
|
||||
}
|
||||
}
|
||||
/** @deprecated */
|
||||
final class CachedArray extends DbArray
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user