From e67c06e355097841155aa9fa09189c40e907f44b Mon Sep 17 00:00:00 2001 From: Alexander Pankratov <34161928+xtrime-ru@users.noreply.github.com> Date: Sat, 22 Jun 2019 20:54:44 +0300 Subject: [PATCH] Cleanup memory and session files (#608) * Cleanup memory and session files * Codestyle * composer.json * add setting to control cleanup * Typo fix * revert composer edits * Version change --- docs | 2 +- src/danog/MadelineProto/MTProto.php | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs b/docs index 3b2fb466..47fa1f01 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 3b2fb46659932f3a812279b64f31b8933474978c +Subproject commit 47fa1f01763372bab5bc64332bced8fcdc8b7100 diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 5f708b01..010b5262 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -73,7 +73,7 @@ class MTProto extends AsyncConstruct implements TLCallback /* const V = 71; */ - const V = 123; + const V = 124; const RELEASE = '4.0'; const NOT_LOGGED_IN = 0; const WAITING_CODE = 1; @@ -229,9 +229,22 @@ class MTProto extends AsyncConstruct implements TLCallback public function __sleep() { + if ($this->settings['serialization']['cleanup_before_serialization']) { + $this->cleanup(); + } return ['supportUser', 'referenceDatabase', 'channel_participants', 'event_handler', 'event_handler_instance', 'loop_callback', 'web_template', 'encrypted_layer', 'settings', 'config', 'authorization', 'authorized', 'rsa_keys', 'dh_config', 'chats', 'last_stored', 'qres', 'got_state', 'channels_state', 'updates', 'updates_key', 'full_chats', 'msg_ids', 'dialog_params', 'datacenter', 'v', 'constructors', 'td_constructors', 'methods', 'td_methods', 'td_descriptions', 'tl_callbacks', 'temp_requested_secret_chats', 'temp_rekeyed_secret_chats', 'secret_chats', 'hook_url', 'storage', 'authorized_dc', 'tos']; } + /** + * Cleanup memory and session file. + */ + private function cleanup() + { + $this->referenceDatabase = new ReferenceDatabase($this); + $this->construct_TL($this->settings['tl_schema']['src'], [$this, $this->referenceDatabase]); + return $this; + } + public function logger($param, $level = Logger::NOTICE, $file = null) { if ($file === null) { @@ -778,7 +791,10 @@ class MTProto extends AsyncConstruct implements TLCallback 'callback' => 'get_updates_update_handler', // Update callback 'run_callback' => true, - ], 'secret_chats' => ['accept_chats' => true], 'serialization' => ['serialization_interval' => 30], 'threading' => [ + ], 'secret_chats' => ['accept_chats' => true], 'serialization' => [ + 'serialization_interval' => 30, + 'cleanup_before_serialization' => false, + ], 'threading' => [ 'allow_threading' => false, // Should I use threading, if it is enabled? 'handler_workers' => 10,