diff --git a/.github/support.yml b/.github/support.yml deleted file mode 100644 index fe3493dfb..000000000 --- a/.github/support.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Configuration for support-requests - https://github.com/dessant/support-requests - -# Label used to mark issues as support requests -supportLabel: "Support request" -# Comment to post on issues marked as support requests. Add a link -# to a support page, or set to `false` to disable -supportComment: > - Thanks, but this issue tracker is not intended for support requests. Please read the guidelines on [submitting an issue](https://github.com/pmmp/PocketMine-MP/blob/master/CONTRIBUTING.md#creating-an-issue). - - - [Docs](https://pmmp.rtfd.io) | [Discord](https://discord.gg/bmSAZBG) | [Forums](https://forums.pmmp.io) - -# Whether to close issues marked as support requests -close: true -# Whether to lock issues marked as support requests -lock: false diff --git a/.github/workflows/support.yml b/.github/workflows/support.yml new file mode 100644 index 000000000..07984f128 --- /dev/null +++ b/.github/workflows/support.yml @@ -0,0 +1,22 @@ +name: 'Manage support request issues' + +on: + issues: + types: [labeled, unlabeled, reopened] + +jobs: + support: + runs-on: ubuntu-latest + steps: + - uses: dessant/support-requests@v2 + with: + github-token: ${{ github.token }} + support-label: "Support request" + issue-comment: > + Thanks, but this issue tracker is not intended for support requests. Please read the guidelines on [submitting an issue](https://github.com/pmmp/PocketMine-MP/blob/master/CONTRIBUTING.md#creating-an-issue). + + + [Docs](https://pmmp.rtfd.io) | [Discord](https://discord.gg/bmSAZBG) | [Forums](https://forums.pmmp.io) + + close-issue: true + lock-issue: false diff --git a/composer.json b/composer.json index 82232e53e..5a5ac2a96 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ "composer-runtime-api": "^2.0" }, "require-dev": { - "phpstan/phpstan": "0.12.69", + "phpstan/phpstan": "0.12.71", "phpstan/phpstan-phpunit": "^0.12.6", "phpstan/phpstan-strict-rules": "^0.12.2", "phpunit/phpunit": "^9.2" diff --git a/composer.lock b/composer.lock index 2d9972927..1b56339b8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "516f0ca0b6b64244f81ea8340c48347f", + "content-hash": "4ef66ad9f915fd8a82409bbf2a46c9cf", "packages": [ { "name": "adhocore/json-comment", @@ -1521,16 +1521,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.69", + "version": "0.12.71", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "8f436ea35241da33487fd0d38b4bc3e6dfe30ea8" + "reference": "d508fa3b0ecc5fc91ac70c6c7ac2862f968ba2b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8f436ea35241da33487fd0d38b4bc3e6dfe30ea8", - "reference": "8f436ea35241da33487fd0d38b4bc3e6dfe30ea8", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d508fa3b0ecc5fc91ac70c6c7ac2862f968ba2b5", + "reference": "d508fa3b0ecc5fc91ac70c6c7ac2862f968ba2b5", "shasum": "" }, "require": { @@ -1561,7 +1561,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.69" + "source": "https://github.com/phpstan/phpstan/tree/0.12.71" }, "funding": [ { @@ -1577,7 +1577,7 @@ "type": "tidelift" } ], - "time": "2021-01-24T14:55:37+00:00" + "time": "2021-02-01T18:24:00+00:00" }, { "name": "phpstan/phpstan-phpunit", diff --git a/src/event/block/BlockBreakEvent.php b/src/event/block/BlockBreakEvent.php index ca28352c3..2540ecec4 100644 --- a/src/event/block/BlockBreakEvent.php +++ b/src/event/block/BlockBreakEvent.php @@ -51,7 +51,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{ /** * @param Item[] $drops */ - public function __construct(Player $player, Block $block, Item $item, bool $instaBreak = false, array $drops, int $xpDrops = 0){ + public function __construct(Player $player, Block $block, Item $item, bool $instaBreak = false, array $drops = [], int $xpDrops = 0){ parent::__construct($block); $this->item = $item; $this->player = $player; diff --git a/src/inventory/transaction/InventoryTransaction.php b/src/inventory/transaction/InventoryTransaction.php index 2ab20eee6..9b089126b 100644 --- a/src/inventory/transaction/InventoryTransaction.php +++ b/src/inventory/transaction/InventoryTransaction.php @@ -30,6 +30,7 @@ use pocketmine\inventory\transaction\action\SlotChangeAction; use pocketmine\item\Item; use pocketmine\player\Player; use function array_keys; +use function array_values; use function assert; use function count; use function get_class; @@ -171,6 +172,8 @@ class InventoryTransaction{ } } } + $needItems = array_values($needItems); + $haveItems = array_values($haveItems); } /** diff --git a/src/world/format/io/region/RegionLoader.php b/src/world/format/io/region/RegionLoader.php index 61787308b..b2aa71c5a 100644 --- a/src/world/format/io/region/RegionLoader.php +++ b/src/world/format/io/region/RegionLoader.php @@ -32,6 +32,7 @@ use pocketmine\world\format\io\exception\CorruptedChunkException; use function assert; use function ceil; use function chr; +use function clearstatcache; use function fclose; use function feof; use function file_exists; @@ -91,6 +92,7 @@ class RegionLoader{ * @throws CorruptedRegionException */ public function open() : void{ + clearstatcache(false, $this->filePath); $exists = file_exists($this->filePath); if(!$exists){ touch($this->filePath); @@ -370,6 +372,7 @@ class RegionLoader{ fwrite($this->filePointer, Binary::writeInt($entry !== null ? ($entry->getFirstSector() << 8) | $entry->getSectorCount() : 0), 4); fseek($this->filePointer, 4096 + ($index << 2)); fwrite($this->filePointer, Binary::writeInt($entry !== null ? $entry->getTimestamp() : 0), 4); + clearstatcache(false, $this->filePath); } protected function createBlank() : void{ diff --git a/tests/phpunit/world/format/io/region/RegionLoaderTest.php b/tests/phpunit/world/format/io/region/RegionLoaderTest.php index 2d2c303b5..c46791875 100644 --- a/tests/phpunit/world/format/io/region/RegionLoaderTest.php +++ b/tests/phpunit/world/format/io/region/RegionLoaderTest.php @@ -115,4 +115,19 @@ class RegionLoaderTest extends TestCase{ $this->expectException(\InvalidArgumentException::class); $this->region->readChunk($x, $z); } + + /** + * Test that cached filesize() values don't break validation of region headers + */ + public function testRegionHeaderCachedFilesizeRegression() : void{ + $this->region->close(); + $region = new RegionLoader($this->regionPath, 0, 0); //now we have a region, so the header will be verified, triggering two filesize() calls + $region->open(); + $data = str_repeat("hello", 2000); + $region->writeChunk(0, 0, $data); //add some data to the end of the file, to make the cached filesize invalid + $region->close(); + $region = new RegionLoader($this->regionPath, 0, 0); + $region->open(); + self::assertSame($data, $region->readChunk(0, 0)); + } }