From febb31d01de085c081c59618b4446618a29ffdb7 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 9 Jun 2018 21:00:57 +0200 Subject: [PATCH 1/6] Delete launch.json --- .vscode/launch.json | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 60c627f8e..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Listen for XDebug", - "type": "php", - "request": "launch", - "port": 9002 - }, - { - "name": "Launch currently open script", - "type": "php", - "request": "launch", - "program": "${workspaceRoot}/testing.php", - "cwd": "${fileDirname}", - "port": 9000 - } - ] -} \ No newline at end of file From abe952bcc0670a5dd0c5b1a8d4886f8106bc663b Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 14 Jun 2018 15:04:10 +0200 Subject: [PATCH 2/6] Logger bugfix --- src/danog/MadelineProto/Logger.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/danog/MadelineProto/Logger.php b/src/danog/MadelineProto/Logger.php index e24383a84..183a54335 100644 --- a/src/danog/MadelineProto/Logger.php +++ b/src/danog/MadelineProto/Logger.php @@ -70,18 +70,6 @@ class Logger $this->colors[self::WARNING] = implode(';', [self::foreground['white'], self::set['dim'], self::background['red']]); $this->colors[self::ERROR] = implode(';', [self::foreground['white'], self::set['bold'], self::background['red']]); $this->colors[self::FATAL_ERROR] = implode(';', [self::foreground['red'], self::set['bold'], self::background['light_gray']]); - - if (!self::$printed) { - $this->colors[self::NOTICE] = implode(';', [self::foreground['light_gray'], self::set['bold'], self::background['blue']]); - - $this->logger('MadelineProto'); - $this->logger('Copyright (C) 2016-2018 Daniil Gentili'); - $this->logger('Licensed under AGPLv3'); - $this->logger('https://github.com/danog/MadelineProto'); - - $this->colors[self::NOTICE] = implode(';', [self::foreground['yellow'], self::set['bold']]); - self::$printed = true; - } } public static function log($param, $level = self::NOTICE) @@ -96,6 +84,17 @@ class Logger if ($level > $this->level || $this->mode === 0) { return false; } + if (!self::$printed) { + $this->colors[self::NOTICE] = implode(';', [self::foreground['light_gray'], self::set['bold'], self::background['blue']]); + + $this->logger('MadelineProto'); + $this->logger('Copyright (C) 2016-2018 Daniil Gentili'); + $this->logger('Licensed under AGPLv3'); + $this->logger('https://github.com/danog/MadelineProto'); + + $this->colors[self::NOTICE] = implode(';', [self::foreground['yellow'], self::set['bold']]); + self::$printed = true; + } if ($this->mode === 4) { return call_user_func_array($this->optional, [$param, $level]); } From ed2666f8087d84152be648d560a606c0d4cc3b95 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 14 Jun 2018 17:22:42 +0200 Subject: [PATCH 3/6] Delete .gitkeep --- fuzz/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 fuzz/.gitkeep diff --git a/fuzz/.gitkeep b/fuzz/.gitkeep deleted file mode 100644 index e69de29bb..000000000 From 96f943f78e0f6b6fa019d426ef4eba429ed50133 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 14 Jun 2018 19:46:38 +0200 Subject: [PATCH 4/6] Bugfix --- src/danog/MadelineProto/Logger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/danog/MadelineProto/Logger.php b/src/danog/MadelineProto/Logger.php index 183a54335..482d9d868 100644 --- a/src/danog/MadelineProto/Logger.php +++ b/src/danog/MadelineProto/Logger.php @@ -85,6 +85,7 @@ class Logger return false; } if (!self::$printed) { + self::$printed = true; $this->colors[self::NOTICE] = implode(';', [self::foreground['light_gray'], self::set['bold'], self::background['blue']]); $this->logger('MadelineProto'); @@ -93,7 +94,6 @@ class Logger $this->logger('https://github.com/danog/MadelineProto'); $this->colors[self::NOTICE] = implode(';', [self::foreground['yellow'], self::set['bold']]); - self::$printed = true; } if ($this->mode === 4) { return call_user_func_array($this->optional, [$param, $level]); From 092cc44d75b1b2bf6b36336ab4d2ea942304b604 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 22 Jun 2018 13:28:33 +0200 Subject: [PATCH 5/6] HHVM fixes --- src/BigIntegor.php | 11 ++++++++++- src/danog/MadelineProto/TL/Exception.php | 2 +- src/danog/MadelineProto/TL/TL.php | 2 +- tests/makephar.sh | 1 + tests/makephardebug.sh | 1 + 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/BigIntegor.php b/src/BigIntegor.php index f539af6b8..1ddf371cc 100644 --- a/src/BigIntegor.php +++ b/src/BigIntegor.php @@ -2,9 +2,18 @@ namespace phpseclib\Math; -if (PHP_MAJOR_VERSION < 7 && !(class_exists('\Phar') && \Phar::running())) { +if (PHP_MAJOR_VERSION < 7 && !(class_exists('\\Phar') && \Phar::running())) { throw new \Exception('MadelineProto requires php 7 to run'); } +if (defined('HHVM_VERSION')) { + $engines = [['PHP64', ['OpenSSL']], ['BCMath', ['OpenSSL']], ['PHP32', ['OpenSSL']]]; + foreach ($engines as $engine) { + try { + \phpseclib\Math\BigInteger::setEngine($engine[0], isset($engine[1]) ? $engine[1] : []); + break; + } catch (\Exception $e) {} + } +} class BigIntegor { diff --git a/src/danog/MadelineProto/TL/Exception.php b/src/danog/MadelineProto/TL/Exception.php index dce65211d..e42cca4d6 100644 --- a/src/danog/MadelineProto/TL/Exception.php +++ b/src/danog/MadelineProto/TL/Exception.php @@ -19,7 +19,7 @@ class Exception extends \Exception public function __toString() { - return get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.@file_get_contents(__DIR__.'/../../../.git/refs/heads/master').PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL; + return get_class($this). ($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.@file_get_contents(__DIR__.'/../../../.git/refs/heads/master').PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL; } public function __construct($message, $file = '') diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index 8ef480460..13b72bfe3 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -597,7 +597,7 @@ trait TL stream_get_contents($stream, $resto); } } else { - $x = stream_get_contents($stream, $l); + $x = $l ? stream_get_contents($stream, $l) : ''; $resto = $this->posmod(-($l + 1), 4); if ($resto > 0) { stream_get_contents($stream, $resto); diff --git a/tests/makephar.sh b/tests/makephar.sh index 1bf15bb2c..4e6216cff 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -32,6 +32,7 @@ composer update cd .. $php7to5 convert --copy-all phar7 phar5 >/dev/null +find phar5 -type f -exec sed 's/\w* \.\.\./.../' -i {} + [ "$TRAVIS_BRANCH" != "master" ] && branch="-$TRAVIS_BRANCH" || branch="" diff --git a/tests/makephardebug.sh b/tests/makephardebug.sh index 3fb0d60a8..6b566823d 100755 --- a/tests/makephardebug.sh +++ b/tests/makephardebug.sh @@ -32,6 +32,7 @@ cp -a ../src vendor/danog/madelineproto cd .. $php7to5 convert --copy-all phar7 phar5 >/dev/null +find phar5 -type f -exec sed 's/\w* \.\.\./.../' -i {} + php makephar.php phar5 madeline.phar $(cat .git/refs/heads/master) From 4520635d278fa103e04953b5d05c1fd3bd709225 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 22 Jun 2018 11:35:08 +0000 Subject: [PATCH 6/6] Apply fixes from StyleCI --- src/BigIntegor.php | 7 ++++--- src/danog/MadelineProto/TL/Exception.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/BigIntegor.php b/src/BigIntegor.php index 1ddf371cc..2e1272686 100644 --- a/src/BigIntegor.php +++ b/src/BigIntegor.php @@ -9,9 +9,10 @@ if (defined('HHVM_VERSION')) { $engines = [['PHP64', ['OpenSSL']], ['BCMath', ['OpenSSL']], ['PHP32', ['OpenSSL']]]; foreach ($engines as $engine) { try { - \phpseclib\Math\BigInteger::setEngine($engine[0], isset($engine[1]) ? $engine[1] : []); - break; - } catch (\Exception $e) {} + \phpseclib\Math\BigInteger::setEngine($engine[0], isset($engine[1]) ? $engine[1] : []); + break; + } catch (\Exception $e) { + } } } diff --git a/src/danog/MadelineProto/TL/Exception.php b/src/danog/MadelineProto/TL/Exception.php index e42cca4d6..dce65211d 100644 --- a/src/danog/MadelineProto/TL/Exception.php +++ b/src/danog/MadelineProto/TL/Exception.php @@ -19,7 +19,7 @@ class Exception extends \Exception public function __toString() { - return get_class($this). ($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.@file_get_contents(__DIR__.'/../../../.git/refs/heads/master').PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL; + return get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.@file_get_contents(__DIR__.'/../../../.git/refs/heads/master').PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL; } public function __construct($message, $file = '')