From 4c3de2573d1c207019886bb0bb15e9539d1e65ec Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 13 Feb 2017 13:27:59 +0100 Subject: [PATCH 1/2] Bugfixes --- CONTRIBUTING.md | 2 +- src/danog/MadelineProto/API.php | 15 ++------------- src/danog/MadelineProto/MTProto.php | 10 ++++++++++ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35e49905..bfe15e44 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,6 +4,6 @@ To contribute to this project simply fork it, make all improvements, commit chan If you have an issue, please *always* upload MadelineProto logs from when the error occurred to hastebin or similar websites. -If you make breaking changes, make sure to increase the number returned by the getV function on line 54 of API.php. +If you make breaking changes, make sure to increase the number returned by the getV function in MTProto.php. Bye :) diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index d3143d0a..7022ea06 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -41,7 +41,7 @@ class API extends APIFactory \danog\MadelineProto\Logger::log(['Pong: '.$pong['ping_id']], Logger::ULTRA_VERBOSE); \danog\MadelineProto\Logger::log(['Getting future salts...'], Logger::ULTRA_VERBOSE); $this->future_salts = $this->get_future_salts([3]); - $this->v = $this->getV(); + $this->API->v = $this->API->getV(); \danog\MadelineProto\Logger::log(['MadelineProto is ready!'], Logger::NOTICE); } @@ -49,24 +49,13 @@ class API extends APIFactory { //$this->API->reset_session(false); - return ['API', 'v']; - } - - public function getV() - { - return 1; + return ['API']; } public function __wakeup() { set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']); $this->APIFactory(); - $this->API->setup_logger(); - if (!isset($this->v) || $this->v !== $this->getV()) { - \danog\MadelineProto\Logger::log(['Serialization is out of date, reconstructing object!'], Logger::WARNING); - $this->API->__construct($this->API->settings); - $this->v = $this->getV(); - } } public function __destruct() diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index e48be431..936f1f67 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -63,6 +63,11 @@ class MTProto extends PrimeModule public function __wakeup() { $this->setup_logger(); + if (!isset($this->v) || $this->v !== $this->getV()) { + \danog\MadelineProto\Logger::log(['Serialization is out of date, reconstructing object!'], Logger::WARNING); + $this->__construct($this->settings); + $this->v = $this->getV(); + } $this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']); $this->reset_session(); if ($this->datacenter->authorized && $this->settings['updates']['handle_updates']) { @@ -355,4 +360,9 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB $this->settings['connection'][$test][$ipv6][$id] = $dc; } } + public function getV() + { + return 1; + } + } From bfc7684fee65fdc5ab76973b450a1a0d18f9d6c2 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 13 Feb 2017 12:28:45 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/danog/MadelineProto/MTProto.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 936f1f67..d0bc13fb 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -360,9 +360,9 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB $this->settings['connection'][$test][$ipv6][$id] = $dc; } } + public function getV() { return 1; } - }