Merge branch 'stable'

This commit is contained in:
Dylan K. Taylor 2021-02-02 13:46:29 +00:00
commit 3e1ac66abf
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
8 changed files with 52 additions and 25 deletions

16
.github/support.yml vendored
View File

@ -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

22
.github/workflows/support.yml vendored Normal file
View File

@ -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

View File

@ -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"

14
composer.lock generated
View File

@ -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",

View File

@ -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;

View File

@ -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);
}
/**

View File

@ -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{

View File

@ -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));
}
}