diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 99a016aef..730d6e811 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -20,8 +20,9 @@ assignees: '' * PocketMine-MP: * PHP: +* Using JIT: yes/no (delete as appropriate) * Server OS: -* Game version: PE/Win10 (delete as appropriate) +* Game version: Android/iOS/Win10/Xbox/PS4/Switch (delete as appropriate) ### Plugins diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d4ad6b106..177ba8f6d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: image: [ubuntu-20.04] - php: [7.4.20] + php: [7.4.20, 8.0.7] steps: - uses: actions/checkout@v2 #needed for build.sh @@ -36,8 +36,13 @@ jobs: strategy: fail-fast: false matrix: - image: [ubuntu-20.04] - php: [7.4.20] + include: + - php: 8.0.7 + config: phpstan.php8.neon + image: ubuntu-20.04 + - php: 7.4.20 + config: phpstan.neon.dist + image: ubuntu-20.04 steps: - uses: actions/checkout@v2 @@ -77,7 +82,7 @@ jobs: run: php composer.phar install --prefer-dist --no-interaction - name: Run PHPStan - run: ./vendor/bin/phpstan analyze --no-progress --memory-limit=2G + run: ./vendor/bin/phpstan analyze --no-progress --memory-limit=2G -c ${{ matrix.config }} phpunit: name: PHPUnit tests @@ -87,7 +92,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [7.4.20] + php: [7.4.20, 8.0.7] steps: - uses: actions/checkout@v2 @@ -139,7 +144,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [7.4.20] + php: [7.4.20, 8.0.7] steps: - uses: actions/checkout@v2 @@ -191,7 +196,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [7.4.20] + php: [7.4.20, 8.0.7] steps: - uses: actions/checkout@v2 @@ -276,7 +281,7 @@ jobs: - name: Setup PHP and tools uses: shivammathur/setup-php@2.9.0 with: - php-version: 7.4 + php-version: 8.0 tools: php-cs-fixer - name: Run PHP-CS-Fixer diff --git a/changelogs/3.22.md b/changelogs/3.22.md index 31e7c4c25..7d83b5a0d 100644 --- a/changelogs/3.22.md +++ b/changelogs/3.22.md @@ -9,3 +9,12 @@ Plugin developers should **only** update their required API to this version if y # 3.22.0 - Added support for Minecraft: Bedrock Edition 1.17.10. - Removed compatibility with earlier versions. + +# 3.22.1 +- Added a giant yellow startup warning if using OPcache JIT on PHP 8.0. JIT is currently considered highly unstable and not recommended for production use. +- When using a bad PHP binary, the bootstrap will now report the used `php.ini` path. This can be useful for debugging issues with extension loading when the wrong `php.ini` file is loaded for some reason. +- Fixed `start.cmd` causing the wrong `php.ini` to be loaded on Windows when a global PHP installation is used. +- A debug message is now logged containing expected vs. actual XUID of players when an XUID mismatch is detected. +- Improved the documentation for `Player->getUniqueId()`. +- Fixed a mistake in the documentation of `PlayerAuthInputFlags`. +- Fixed incorrect encoding of `NpcDialoguePacket`. diff --git a/composer.lock b/composer.lock index e33951329..eaada0c98 100644 --- a/composer.lock +++ b/composer.lock @@ -2400,16 +2400,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.6", + "version": "9.5.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb" + "reference": "d0dc8b6999c937616df4fb046792004b33fd31c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb", - "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0dc8b6999c937616df4fb046792004b33fd31c5", + "reference": "d0dc8b6999c937616df4fb046792004b33fd31c5", "shasum": "" }, "require": { @@ -2487,7 +2487,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.6" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.7" }, "funding": [ { @@ -2499,7 +2499,7 @@ "type": "github" } ], - "time": "2021-06-23T05:14:38+00:00" + "time": "2021-07-19T06:14:47+00:00" }, { "name": "sebastian/cli-parser", diff --git a/phpstan.php8.neon b/phpstan.php8.neon new file mode 100644 index 000000000..2d5932c02 --- /dev/null +++ b/phpstan.php8.neon @@ -0,0 +1,4 @@ +includes: + - phpstan.neon.dist + - tests/phpstan/configs/php8.neon + diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 650d72d6c..ca3179265 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -605,6 +605,7 @@ class NetworkSession{ $myXUID = $this->info instanceof XboxLivePlayerInfo ? $this->info->getXuid() : ""; $kickForXUIDMismatch = function(string $xuid) use ($checkXUID, $myXUID) : bool{ if($checkXUID && $myXUID !== $xuid){ + $this->logger->debug("XUID mismatch: expected '$xuid', but got '$myXUID'"); //TODO: Longer term, we should be identifying playerdata using something more reliable, like XUID or UUID. //However, that would be a very disruptive change, so this will serve as a stopgap for now. //Side note: this will also prevent offline players hijacking XBL playerdata on online servers, since their diff --git a/src/player/Player.php b/src/player/Player.php index ddc418a78..177116140 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -376,19 +376,11 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ } /** - * Returns the player's UUID. This should be preferred over their Xbox user ID (XUID) because UUID is a standard - * format which will never change, and all players will have one regardless of whether they are logged into Xbox - * Live. + * Returns the player's UUID. This should be the preferred method to identify a player. + * It does not change if the player changes their username. * - * The UUID is comprised of: - * - when logged into XBL: a hash of their XUID (and as such will not change for the lifetime of the XBL account) - * - when NOT logged into XBL: a hash of their name + clientID + secret device ID. - * - * WARNING: UUIDs of players **not logged into Xbox Live** CAN BE FAKED and SHOULD NOT be trusted! - * - * (In the olden days this method used to return a fake UUID computed by the server, which was used by plugins such - * as SimpleAuth for authentication. This is NOT SAFE anymore as this UUID is now what was given by the client, NOT - * a server-computed UUID.) + * All players will have a UUID, regardless of whether they are logged into Xbox Live or not. However, note that + * non-XBL players can fake their UUIDs. */ public function getUniqueId() : UuidInterface{ return parent::getUniqueId(); diff --git a/tests/phpstan/configs/php8.neon b/tests/phpstan/configs/php8.neon new file mode 100644 index 000000000..6314d1777 --- /dev/null +++ b/tests/phpstan/configs/php8.neon @@ -0,0 +1,182 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$stream of function fclose expects resource, resource\\|false given\\.$#" + count: 1 + path: ../../../src/MemoryManager.php + + - + message: "#^Parameter \\#1 \\$stream of function fwrite expects resource, resource\\|false given\\.$#" + count: 1 + path: ../../../src/MemoryManager.php + + - + message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#" + count: 1 + path: ../../../src/ServerConfigGroup.php + + - + message: "#^Parameter \\#1 \\$stream of function fclose expects resource, resource\\|false given\\.$#" + count: 2 + path: ../../../src/command/defaults/TimingsCommand.php + + - + message: "#^Parameter \\#1 \\$stream of function fseek expects resource, resource\\|false given\\.$#" + count: 1 + path: ../../../src/command/defaults/TimingsCommand.php + + - + message: "#^Parameter \\#1 \\$stream of function fwrite expects resource, resource\\|false given\\.$#" + count: 1 + path: ../../../src/command/defaults/TimingsCommand.php + + - + message: "#^Parameter \\#1 \\$stream of function stream_get_contents expects resource, resource\\|false given\\.$#" + count: 1 + path: ../../../src/command/defaults/TimingsCommand.php + + - + message: "#^Parameter \\#1 \\$objectOrClass of class ReflectionClass constructor expects class\\-string\\\\|T of object, string given\\.$#" + count: 1 + path: ../../../src/event/HandlerListManager.php + + - + message: "#^Parameter \\#2 \\$array of function array_map expects array, array\\|false given\\.$#" + count: 1 + path: ../../../src/lang/Language.php + + - + message: "#^Method pocketmine\\\\network\\\\mcpe\\\\JwtUtils\\:\\:parseDerPublicKey\\(\\) should return resource but returns OpenSSLAsymmetricKey\\.$#" + count: 1 + path: ../../../src/network/mcpe/JwtUtils.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_pkey_get_details expects OpenSSLAsymmetricKey, resource given\\.$#" + count: 1 + path: ../../../src/network/mcpe/JwtUtils.php + + - + message: "#^Parameter \\#3 \\$private_key of function openssl_sign expects array\\|OpenSSLAsymmetricKey\\|OpenSSLCertificate\\|string, resource given\\.$#" + count: 1 + path: ../../../src/network/mcpe/JwtUtils.php + + - + message: "#^Parameter \\#3 \\$public_key of function openssl_verify expects array\\|OpenSSLAsymmetricKey\\|OpenSSLCertificate\\|string, resource given\\.$#" + count: 1 + path: ../../../src/network/mcpe/JwtUtils.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_free_key expects OpenSSLAsymmetricKey, resource given\\.$#" + count: 1 + path: ../../../src/network/mcpe/auth/ProcessLoginTask.php + + - + message: "#^Parameter \\#1 \\$public_key of function openssl_pkey_derive expects array\\|OpenSSLAsymmetricKey\\|OpenSSLCertificate\\|string, resource given\\.$#" + count: 1 + path: ../../../src/network/mcpe/encryption/EncryptionUtils.php + + - + message: "#^Parameter \\#2 \\$private_key of function openssl_pkey_derive expects array\\|OpenSSLAsymmetricKey\\|OpenSSLCertificate\\|string, resource given\\.$#" + count: 1 + path: ../../../src/network/mcpe/encryption/EncryptionUtils.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_free_key expects OpenSSLAsymmetricKey, resource given\\.$#" + count: 1 + path: ../../../src/network/mcpe/encryption/PrepareEncryptionTask.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_pkey_get_details expects OpenSSLAsymmetricKey, OpenSSLAsymmetricKey\\|resource given\\.$#" + count: 1 + path: ../../../src/network/mcpe/encryption/PrepareEncryptionTask.php + + - + message: "#^Parameter \\#1 \\$localPriv of static method pocketmine\\\\network\\\\mcpe\\\\encryption\\\\EncryptionUtils\\:\\:generateSharedSecret\\(\\) expects resource, OpenSSLAsymmetricKey given\\.$#" + count: 1 + path: ../../../src/network/mcpe/encryption/PrepareEncryptionTask.php + + - + message: "#^Parameter \\#1 \\$serverPriv of static method pocketmine\\\\network\\\\mcpe\\\\encryption\\\\EncryptionUtils\\:\\:generateServerHandshakeJwt\\(\\) expects resource, OpenSSLAsymmetricKey given\\.$#" + count: 1 + path: ../../../src/network/mcpe/encryption/PrepareEncryptionTask.php + + - + message: "#^Static property pocketmine\\\\network\\\\mcpe\\\\encryption\\\\PrepareEncryptionTask\\:\\:\\$SERVER_PRIVATE_KEY \\(resource\\|null\\) does not accept OpenSSLAsymmetricKey\\.$#" + count: 1 + path: ../../../src/network/mcpe/encryption/PrepareEncryptionTask.php + + - + message: "#^Parameter \\#1 \\$socket of function socket_bind expects Socket, resource given\\.$#" + count: 1 + path: ../../../src/network/query/DedicatedQueryNetworkInterface.php + + - + message: "#^Parameter \\#1 \\$socket of function socket_close expects Socket, resource given\\.$#" + count: 1 + path: ../../../src/network/query/DedicatedQueryNetworkInterface.php + + - + message: "#^Parameter \\#1 \\$socket of function socket_last_error expects Socket\\|null, resource given\\.$#" + count: 3 + path: ../../../src/network/query/DedicatedQueryNetworkInterface.php + + - + message: "#^Parameter \\#1 \\$socket of function socket_recvfrom expects Socket, resource given\\.$#" + count: 1 + path: ../../../src/network/query/DedicatedQueryNetworkInterface.php + + - + message: "#^Parameter \\#1 \\$socket of function socket_sendto expects Socket, resource given\\.$#" + count: 1 + path: ../../../src/network/query/DedicatedQueryNetworkInterface.php + + - + message: "#^Parameter \\#1 \\$socket of function socket_set_nonblock expects Socket, resource given\\.$#" + count: 1 + path: ../../../src/network/query/DedicatedQueryNetworkInterface.php + + - + message: "#^Property pocketmine\\\\network\\\\query\\\\DedicatedQueryNetworkInterface\\:\\:\\$socket \\(resource\\) does not accept Socket\\.$#" + count: 1 + path: ../../../src/network/query/DedicatedQueryNetworkInterface.php + + - + message: "#^Parameter \\#1 \\$ of closure expects resource, CurlHandle given\\.$#" + count: 1 + path: ../../../src/utils/Internet.php + + - + message: "#^Parameter \\#2 \\$offset of function substr expects int, mixed given\\.$#" + count: 1 + path: ../../../src/utils/Internet.php + + - + message: "#^Parameter \\#3 \\$length of function substr expects int\\|null, mixed given\\.$#" + count: 1 + path: ../../../src/utils/Internet.php + + - + message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|false given\\.$#" + count: 1 + path: ../../../src/utils/Timezone.php + + - + message: "#^Parameter \\#1 \\$timezoneId of function date_default_timezone_set expects string, string\\|false given\\.$#" + count: 1 + path: ../../../src/utils/Timezone.php + + - + message: "#^Strict comparison using \\=\\=\\= between array\\ and false will always evaluate to false\\.$#" + count: 1 + path: ../../../src/utils/Timezone.php + + - + message: "#^Parameter \\#2 \\$array of function array_map expects array, mixed given\\.$#" + count: 1 + path: ../../../src/utils/Utils.php + + - + message: "#^Strict comparison using \\=\\=\\= between array and false will always evaluate to false\\.$#" + count: 1 + path: ../../../src/utils/Utils.php +