Speed up deserialization
This commit is contained in:
parent
af1cbe9107
commit
c8a19d9f89
@ -100,23 +100,28 @@ class Serialization
|
|||||||
\danog\MadelineProto\Logger::log('Lock acquired, deserializing');
|
\danog\MadelineProto\Logger::log('Lock acquired, deserializing');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$unserialized = file_get_contents($realpaths['file']);
|
$tounserialize = file_get_contents($realpaths['file']);
|
||||||
} finally {
|
} finally {
|
||||||
flock($realpaths['lockfile'], LOCK_UN);
|
flock($realpaths['lockfile'], LOCK_UN);
|
||||||
fclose($realpaths['lockfile']);
|
fclose($realpaths['lockfile']);
|
||||||
}
|
}
|
||||||
$tounserialize = str_replace('O:26:"danog\\MadelineProto\\Button":', 'O:35:"danog\\MadelineProto\\TL\\Types\\Button":', $unserialized);
|
|
||||||
foreach (['RSA', 'TL\\TLMethod', 'TL\\TLConstructor', 'MTProto', 'API', 'DataCenter', 'Connection', 'TL\\Types\\Button', 'TL\\Types\\Bytes', 'APIFactory'] as $class) {
|
|
||||||
class_exists('\\danog\\MadelineProto\\'.$class);
|
|
||||||
}
|
|
||||||
class_exists('\\Volatile');
|
|
||||||
\danog\MadelineProto\Logger::class_exists();
|
\danog\MadelineProto\Logger::class_exists();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$unserialized = unserialize($tounserialize);
|
$unserialized = unserialize($tounserialize);
|
||||||
} catch (\danog\MadelineProto\Bug74586Exception $e) {
|
} catch (\danog\MadelineProto\Bug74586Exception $e) {
|
||||||
|
$tounserialize = str_replace('O:26:"danog\\MadelineProto\\Button":', 'O:35:"danog\\MadelineProto\\TL\\Types\\Button":', $unserialized);
|
||||||
|
foreach (['RSA', 'TL\\TLMethod', 'TL\\TLConstructor', 'MTProto', 'API', 'DataCenter', 'Connection', 'TL\\Types\\Button', 'TL\\Types\\Bytes', 'APIFactory'] as $class) {
|
||||||
|
class_exists('\\danog\\MadelineProto\\'.$class);
|
||||||
|
}
|
||||||
|
class_exists('\\Volatile');
|
||||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
|
$tounserialize = str_replace('O:26:"danog\\MadelineProto\\Button":', 'O:35:"danog\\MadelineProto\\TL\\Types\\Button":', $unserialized);
|
||||||
|
foreach (['RSA', 'TL\\TLMethod', 'TL\\TLConstructor', 'MTProto', 'API', 'DataCenter', 'Connection', 'TL\\Types\\Button', 'TL\\Types\\Bytes', 'APIFactory'] as $class) {
|
||||||
|
class_exists('\\danog\\MadelineProto\\'.$class);
|
||||||
|
}
|
||||||
|
class_exists('\\Volatile');
|
||||||
Logger::log((string) $e, Logger::ERROR);
|
Logger::log((string) $e, Logger::ERROR);
|
||||||
if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\\Math\\BigInteger'") === 0) {
|
if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\\Math\\BigInteger'") === 0) {
|
||||||
$tounserialize = str_replace('phpseclib\\Math\\BigInteger', 'phpseclib\\Math\\BigIntegor', $unserialized);
|
$tounserialize = str_replace('phpseclib\\Math\\BigInteger', 'phpseclib\\Math\\BigIntegor', $unserialized);
|
||||||
|
Loading…
Reference in New Issue
Block a user