From 24b92b9a715e6891a0accde87606738cabf1ecfa Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 7 Jun 2019 17:21:43 +0200 Subject: [PATCH] Fix --- README.md | 1 + composer.json | 1 + docs | 2 +- src/danog/MadelineProto/CombinedAPI.php | 13 ++----------- src/danog/MadelineProto/MTProto.php | 6 ++++++ src/danog/MadelineProto/Magic.php | 3 +++ 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 08a0bccbd..87b7b7246 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Tip: if you receive an error (or nothing), [send us](https://t.me/pwrtelegramgro * [Async in callback handler](https://docs.madelineproto.xyz/docs/ASYNC.html#async-in-callback-handler) * [Wrapped async](https://docs.madelineproto.xyz/docs/ASYNC.html#wrapped-async) * [Multiple async](https://docs.madelineproto.xyz/docs/ASYNC.html#multiple-async) + * [ArrayAccess async](https://docs.madelineproto.xyz/docs/ASYNC.html#arrayaccess-async) * [Ignored async](https://docs.madelineproto.xyz/docs/ASYNC.html#ignored-async) * [Blocking async](https://docs.madelineproto.xyz/docs/ASYNC.html#blocking-async) * [MadelineProto and AMPHP async APIs](https://docs.madelineproto.xyz/docs/ASYNC.html#madelineproto-and-amphp-async-apis) diff --git a/composer.json b/composer.json index 50a8c1f66..1ab5fa030 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "ext-mbstring": "*", "ext-json": "*", "ext-xml": "*", + "ext-fileinfo": "*", "amphp/amp": "^2.0", "amphp/socket": "^0.10.11", "amphp/websocket": "dev-master", diff --git a/docs b/docs index dc05dc5ce..dbb560f13 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit dc05dc5cebfcec90ac7851928c522a4d635dbab6 +Subproject commit dbb560f13e9c15c7bfc96c7ae44bb3ae74c75fe7 diff --git a/src/danog/MadelineProto/CombinedAPI.php b/src/danog/MadelineProto/CombinedAPI.php index 94e766764..fb923f25f 100644 --- a/src/danog/MadelineProto/CombinedAPI.php +++ b/src/danog/MadelineProto/CombinedAPI.php @@ -228,20 +228,11 @@ class CombinedAPI if (is_callable($max_forks)) { return $this->wait($max_forks()); } - if (php_sapi_name() !== 'cli') { - try { - set_time_limit(-1); - } catch (\danog\MadelineProto\Exception $e) { - register_shutdown_function(function () { - \danog\MadelineProto\Logger::log(['Restarting script...']); - $a = fsockopen((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'tls' : 'tcp').'://'.$_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']); - fwrite($a, $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' '.$_SERVER['SERVER_PROTOCOL']."\r\n".'Host: '.$_SERVER['SERVER_NAME']."\r\n\r\n"); - }); - } - } $loops = []; foreach ($this->instances as $path => $instance) { + $this->wait($instance->initAsync()); + $this->wait($instance->API->initAsync()); if ($instance->API->authorized !== MTProto::LOGGED_IN) { continue; } diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index ab1c61694..967f53c86 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -169,6 +169,9 @@ class MTProto extends AsyncConstruct implements TLCallback if (!extension_loaded('xml')) { throw new Exception(['extension', 'xml']); } + if (!extension_loaded('fileinfo')) { + throw new Exception(['extension', 'fileinfo']); + } if (!extension_loaded('json')) { throw new Exception(['extension', 'json']); } @@ -279,6 +282,9 @@ class MTProto extends AsyncConstruct implements TLCallback if (!extension_loaded('xml')) { throw new Exception(['extension', 'xml']); } + if (!extension_loaded('fileinfo')) { + throw new Exception(['extension', 'fileinfo']); + } if (!extension_loaded('mbstring')) { throw new Exception(['extension', 'mbstring']); } diff --git a/src/danog/MadelineProto/Magic.php b/src/danog/MadelineProto/Magic.php index 500f58252..d1a10b554 100644 --- a/src/danog/MadelineProto/Magic.php +++ b/src/danog/MadelineProto/Magic.php @@ -130,6 +130,9 @@ class Magic self::$can_getcwd = true; } catch (\danog\MadelineProto\Exception $e) { } + if (function_exists('\pcntl_async_signals')) { + pcntl_async_signals(true); + } self::$inited = true; } }