Apply fixes from StyleCI
This commit is contained in:
parent
2cb942b407
commit
983d70a402
@ -68,6 +68,7 @@ class API extends APIFactory
|
||||
$this->API = $unserialized->API;
|
||||
$this->APIFactory();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
$this->API = new MTProto($params);
|
||||
|
@ -58,48 +58,51 @@ class Serialization
|
||||
*/
|
||||
public static function deserialize($filename, $no_updates = false)
|
||||
{
|
||||
if (file_exists($filename)) {
|
||||
if (!file_exists($lock = $filename.'.lock')) {
|
||||
touch($lock);
|
||||
clearstatcache();
|
||||
}
|
||||
$lock = fopen($lock, 'r');
|
||||
flock($lock, LOCK_SH);
|
||||
$unserialized = file_get_contents($filename);
|
||||
flock($lock, LOCK_UN);
|
||||
fclose($lock);
|
||||
|
||||
$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();
|
||||
|
||||
try {
|
||||
// $unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
$unserialized = unserialize($tounserialize);
|
||||
} catch (\danog\MadelineProto\Bug74586Exception $e) {
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
if (Logger::$constructed) {
|
||||
Logger::log([(string) $e], Logger::ERROR);
|
||||
}
|
||||
if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\Math\BigInteger'") === 0) {
|
||||
$tounserialize = str_replace('phpseclib\Math\BigInteger', 'phpseclib\Math\BigIntegor', $unserialized);
|
||||
}
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
}
|
||||
if ($unserialized instanceof \danog\PlaceHolder) {
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
}
|
||||
} else {
|
||||
throw new Exception(\danog\MadelineProto\Lang::$current_lang['file_not_exist']);
|
||||
if (file_exists($filename)) {
|
||||
if (!file_exists($lock = $filename.'.lock')) {
|
||||
touch($lock);
|
||||
clearstatcache();
|
||||
}
|
||||
if ($unserialized === false) {
|
||||
throw new Exception(\danog\MadelineProto\Lang::$current_lang['deserialization_error']);
|
||||
$lock = fopen($lock, 'r');
|
||||
flock($lock, LOCK_SH);
|
||||
$unserialized = file_get_contents($filename);
|
||||
flock($lock, LOCK_UN);
|
||||
fclose($lock);
|
||||
|
||||
$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);
|
||||
}
|
||||
if ($unserialized instanceof \danog\MadelineProto\API) $unserialized->session = $filename;
|
||||
class_exists('\Volatile');
|
||||
\danog\MadelineProto\Logger::class_exists();
|
||||
|
||||
try {
|
||||
// $unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
$unserialized = unserialize($tounserialize);
|
||||
} catch (\danog\MadelineProto\Bug74586Exception $e) {
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
if (Logger::$constructed) {
|
||||
Logger::log([(string) $e], Logger::ERROR);
|
||||
}
|
||||
if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\Math\BigInteger'") === 0) {
|
||||
$tounserialize = str_replace('phpseclib\Math\BigInteger', 'phpseclib\Math\BigIntegor', $unserialized);
|
||||
}
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
}
|
||||
if ($unserialized instanceof \danog\PlaceHolder) {
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
}
|
||||
} else {
|
||||
throw new Exception(\danog\MadelineProto\Lang::$current_lang['file_not_exist']);
|
||||
}
|
||||
if ($unserialized === false) {
|
||||
throw new Exception(\danog\MadelineProto\Lang::$current_lang['deserialization_error']);
|
||||
}
|
||||
if ($unserialized instanceof \danog\MadelineProto\API) {
|
||||
$unserialized->session = $filename;
|
||||
}
|
||||
|
||||
return $unserialized;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user