Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2017-11-08 12:06:13 +00:00 committed by StyleCI Bot
parent 2cb942b407
commit 983d70a402
2 changed files with 44 additions and 40 deletions

View File

@ -68,6 +68,7 @@ class API extends APIFactory
$this->API = $unserialized->API; $this->API = $unserialized->API;
$this->APIFactory(); $this->APIFactory();
} }
return; return;
} }
$this->API = new MTProto($params); $this->API = new MTProto($params);

View File

@ -58,48 +58,51 @@ class Serialization
*/ */
public static function deserialize($filename, $no_updates = false) public static function deserialize($filename, $no_updates = false)
{ {
if (file_exists($filename)) { if (file_exists($filename)) {
if (!file_exists($lock = $filename.'.lock')) { if (!file_exists($lock = $filename.'.lock')) {
touch($lock); touch($lock);
clearstatcache(); 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 ($unserialized === false) { $lock = fopen($lock, 'r');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['deserialization_error']); 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; return $unserialized;
} }
} }