From f8b1bd270d0b5b4b39b6d7b21e4d36659050118a Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 25 Dec 2019 23:48:42 +0100 Subject: [PATCH 1/3] fixes --- src/danog/MadelineProto/MyTelegramOrgWrapper.php | 2 +- tests/makephar.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/danog/MadelineProto/MyTelegramOrgWrapper.php b/src/danog/MadelineProto/MyTelegramOrgWrapper.php index f345c593..96d3d016 100644 --- a/src/danog/MadelineProto/MyTelegramOrgWrapper.php +++ b/src/danog/MadelineProto/MyTelegramOrgWrapper.php @@ -53,7 +53,7 @@ class MyTelegramOrgWrapper if ($this->settings === null) { $this->settings = []; } - if (!$this->jar) { + if (!$this->jar || !($this->jar instanceof InMemoryCookieJar)) { $this->jar = new InMemoryCookieJar; } $this->settings = MTProto::getSettings($this->settings); diff --git a/tests/makephar.sh b/tests/makephar.sh index be32a0b4..a0426041 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -55,7 +55,8 @@ cd .. [ -f $HOME/.composer/vendor/bin/php7to5 ] && php7to5=$HOME/.composer/vendor/bin/php7to5 [ -f $HOME/.config/composer/vendor/bin/php7to5 ] && php7to5=$HOME/.config/composer/vendor/bin/php7to5 - php7.3 $php7to5 convert --copy-all phar7 phar5 >/dev/null + php7.3 $php7to5 convert --copy-all phar7 phar5t >/dev/null + php7.3 $php7to5 convert --copy-all phar5t phar5 >/dev/null sed 's/^Loop::set.*;//g' -i phar5/vendor/amphp/amp/lib/Loop.php echo 'Loop::set((new DriverFactory())->create());' >> phar5/vendor/amphp/amp/lib/Loop.php @@ -64,7 +65,7 @@ cd .. sed 's/namespace danog\\MadelineProto;/namespace Amp;/g' -i phar5/vendor/amphp/amp/lib/Coroutine.php sed 's/public static function echo/public static function echo_/g' -i phar5/vendor/danog/madelineproto/src/danog/MadelineProto/Tools.php - find phar5/vendor/amphp -type f -name '*.php' -exec sed "s/extension_loaded[(]'zlib'[)]/false/g" -i {} + + find phar5/vendor/amphp -type f -name '*.php' -exec sed "s/extension_loaded[(]'zlib'[)]/false/g;s/new[(]/new_(/g;s/clone[(]/clone_(/g" -i {} + find phar5/vendor/danog/madelineproto -type f -name '*.php' -exec sed 's/: EncryptableSocket/: \\Amp\\Socket\\Socket/g' -i {} + From 89fed994ad5aadad3f250d29fc84ff8d5b7a181a Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 26 Dec 2019 00:08:20 +0100 Subject: [PATCH 2/3] Backwards compatibility --- tests/makephar.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/makephar.sh b/tests/makephar.sh index a0426041..dba1d6a1 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -66,6 +66,8 @@ cd .. sed 's/public static function echo/public static function echo_/g' -i phar5/vendor/danog/madelineproto/src/danog/MadelineProto/Tools.php find phar5/vendor/amphp -type f -name '*.php' -exec sed "s/extension_loaded[(]'zlib'[)]/false/g;s/new[(]/new_(/g;s/clone[(]/clone_(/g" -i {} + + + find phar5/vendor/league/uri -type f -name '*.php' -exec sed 's/withScheme[(]\$scheme[)]: UriInterface/withScheme(?string $scheme): UriInterface/g' -i {} + find phar5/vendor/danog/madelineproto -type f -name '*.php' -exec sed 's/: EncryptableSocket/: \\Amp\\Socket\\Socket/g' -i {} + @@ -80,6 +82,8 @@ cd .. [ -f $HOME/.config/composer/vendor/bin/php7to70 ] && php7to70=$HOME/.config/composer/vendor/bin/php7to70 $php7to70 convert --copy-all phar7 phar5 >/dev/null + find phar5/vendor/league/uri -type f -name '*.php' -exec sed 's/withScheme[(]\$scheme[)]: UriInterface/withScheme(?string $scheme): UriInterface/g' -i {} + + find phar5/vendor/danog/madelineproto -type f -name '*.php' -exec sed 's/: EncryptableSocket/: \\Amp\\Socket\\Socket/g' -i {} + php=70 From 6f578c6647496295abbbc938499ce49510d5402a Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 26 Dec 2019 00:20:15 +0100 Subject: [PATCH 3/3] Further improvements --- src/danog/MadelineProto/TON/ADNLConnection.php | 4 +++- tests/makephar.sh | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/danog/MadelineProto/TON/ADNLConnection.php b/src/danog/MadelineProto/TON/ADNLConnection.php index 8c0d585d..f18a3ead 100644 --- a/src/danog/MadelineProto/TON/ADNLConnection.php +++ b/src/danog/MadelineProto/TON/ADNLConnection.php @@ -191,6 +191,8 @@ class ADNLConnection '' ); (yield $this->stream->getWriteBuffer(\strlen($data)))->bufferWrite($data); - return ($this->requests[$id] = new Deferred)->promise(); + $this->requests[$id] = new Deferred; + + return $this->requests[$id]->promise(); } } diff --git a/tests/makephar.sh b/tests/makephar.sh index dba1d6a1..ac222b56 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -54,9 +54,11 @@ cd .. composer global require spatie/7to5 dev-master#0420ad3 [ -f $HOME/.composer/vendor/bin/php7to5 ] && php7to5=$HOME/.composer/vendor/bin/php7to5 [ -f $HOME/.config/composer/vendor/bin/php7to5 ] && php7to5=$HOME/.config/composer/vendor/bin/php7to5 + + find phar7/vendor/league/uri -type f -name '*.php' -exec sed 's/withScheme[(]\$scheme[)]: UriInterface/withScheme(?string $scheme): UriInterface/g' -i {} + - php7.3 $php7to5 convert --copy-all phar7 phar5t >/dev/null - php7.3 $php7to5 convert --copy-all phar5t phar5 >/dev/null + + php7.3 $php7to5 convert --copy-all phar7 phar5 >/dev/null sed 's/^Loop::set.*;//g' -i phar5/vendor/amphp/amp/lib/Loop.php echo 'Loop::set((new DriverFactory())->create());' >> phar5/vendor/amphp/amp/lib/Loop.php @@ -67,8 +69,6 @@ cd .. find phar5/vendor/amphp -type f -name '*.php' -exec sed "s/extension_loaded[(]'zlib'[)]/false/g;s/new[(]/new_(/g;s/clone[(]/clone_(/g" -i {} + - find phar5/vendor/league/uri -type f -name '*.php' -exec sed 's/withScheme[(]\$scheme[)]: UriInterface/withScheme(?string $scheme): UriInterface/g' -i {} + - find phar5/vendor/danog/madelineproto -type f -name '*.php' -exec sed 's/: EncryptableSocket/: \\Amp\\Socket\\Socket/g' -i {} + php -v @@ -80,9 +80,10 @@ cd .. composer global require danog/7to70 [ -f $HOME/.composer/vendor/bin/php7to70 ] && php7to70=$HOME/.composer/vendor/bin/php7to70 [ -f $HOME/.config/composer/vendor/bin/php7to70 ] && php7to70=$HOME/.config/composer/vendor/bin/php7to70 + + find phar7/vendor/league/uri -type f -name '*.php' -exec sed 's/withScheme[(]\$scheme[)]: UriInterface/withScheme(?string $scheme): UriInterface/g' -i {} + $php7to70 convert --copy-all phar7 phar5 >/dev/null - find phar5/vendor/league/uri -type f -name '*.php' -exec sed 's/withScheme[(]\$scheme[)]: UriInterface/withScheme(?string $scheme): UriInterface/g' -i {} + find phar5/vendor/danog/madelineproto -type f -name '*.php' -exec sed 's/: EncryptableSocket/: \\Amp\\Socket\\Socket/g' -i {} +