From f5e4d29db161a4466f739186456820b482533f03 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 28 Sep 2020 11:56:14 +0200 Subject: [PATCH] Fix serialization --- src/danog/MadelineProto/API.php | 4 ++-- src/danog/MadelineProto/APIWrapper.php | 2 +- src/danog/MadelineProto/AbstractAPIFactory.php | 9 +++++++++ src/danog/MadelineProto/Ipc/Runner/entry.php | 2 +- src/danog/MadelineProto/Settings/Ipc.php | 16 +++++++++------- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index 6503d4b0..ebbc6c39 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -187,9 +187,9 @@ class API extends InternalDoc protected function connectToMadelineProto(SettingsAbstract $settings, bool $forceFull = false): \Generator { if ($settings instanceof SettingsIpc) { - $forceFull = $forceFull || $settings->getForceFull(); + $forceFull = $forceFull || $settings->getSlow(); } elseif ($settings instanceof Settings) { - $forceFull = $forceFull || $settings->getIpc()->getForceFull(); + $forceFull = $forceFull || $settings->getIpc()->getSlow(); } [$unserialized, $this->unlock] = yield Tools::timeoutWithDefault( diff --git a/src/danog/MadelineProto/APIWrapper.php b/src/danog/MadelineProto/APIWrapper.php index 681a0c00..0a780625 100644 --- a/src/danog/MadelineProto/APIWrapper.php +++ b/src/danog/MadelineProto/APIWrapper.php @@ -125,7 +125,7 @@ final class APIWrapper */ public static function __sleep(): array { - return ['API', 'webApiTemplate', 'gettingApiId', 'myTelegramOrgWrapper', 'storage', 'lua']; //, 'async']; + return ['API', 'webApiTemplate', 'gettingApiId', 'myTelegramOrgWrapper', 'storage', 'lua']; } /** diff --git a/src/danog/MadelineProto/AbstractAPIFactory.php b/src/danog/MadelineProto/AbstractAPIFactory.php index ba8e5e99..7b075375 100644 --- a/src/danog/MadelineProto/AbstractAPIFactory.php +++ b/src/danog/MadelineProto/AbstractAPIFactory.php @@ -159,6 +159,15 @@ abstract class AbstractAPIFactory extends AsyncConstruct } return $res; } + /** + * Sleep function. + * + * @return array + */ + public function __sleep() + { + return []; + } /** * Call async wrapper function. * diff --git a/src/danog/MadelineProto/Ipc/Runner/entry.php b/src/danog/MadelineProto/Ipc/Runner/entry.php index 3aaae70d..d45bc661 100644 --- a/src/danog/MadelineProto/Ipc/Runner/entry.php +++ b/src/danog/MadelineProto/Ipc/Runner/entry.php @@ -97,7 +97,7 @@ use danog\MadelineProto\Tools; Magic::classExists(); Magic::$script_cwd = $_GET['cwd'] ?? Magic::getcwd(); - $API = new API($ipcPath, (new Ipc)->setForceFull(true)); + $API = new API($ipcPath, (new Ipc)->setSlow(true)); $API->init(); $API->initSelfRestart(); diff --git a/src/danog/MadelineProto/Settings/Ipc.php b/src/danog/MadelineProto/Settings/Ipc.php index 19dcafa1..a2b825ee 100644 --- a/src/danog/MadelineProto/Settings/Ipc.php +++ b/src/danog/MadelineProto/Settings/Ipc.php @@ -11,7 +11,7 @@ class Ipc extends SettingsAbstract * * WARNING: this will cause slow startup if enabled. */ - protected bool $forceFull = false; + protected bool $slow = false; public function mergeArray(array $settings): void { @@ -22,21 +22,23 @@ class Ipc extends SettingsAbstract * * @return bool */ - public function getForceFull(): bool + public function getSlow(): bool { - return $this->forceFull; + return $this->slow; } /** - * Set WARNING: this will cause slow startup if enabled. + * Whether to force full deserialization of instance, without using the IPC server/client. + * + * WARNING: this will cause slow startup if enabled. * - * @param bool $forceFull WARNING: this will cause slow startup if enabled. + * @param bool $slow WARNING: this will cause slow startup if enabled. * * @return self */ - public function setForceFull(bool $forceFull): self + public function setSlow(bool $slow): self { - $this->forceFull = $forceFull; + $this->slow = $slow; return $this; }