Skip to content

BaseInventory: Validate given array to make sure correct items are given.#5391

Merged
dktapps merged 1 commit intopmmp:stablefrom
alvin0319:fix/set-contents
Nov 7, 2022
Merged

BaseInventory: Validate given array to make sure correct items are given.#5391
dktapps merged 1 commit intopmmp:stablefrom
alvin0319:fix/set-contents

Conversation

@alvin0319
Copy link
Contributor

@alvin0319 alvin0319 commented Nov 5, 2022

Introduction

BaseInventory::setContents() does not validate the given array, so when the server crashes due to an invalid array given, developers may hard to find what went wrong.

Relevant issues

N/A

Changes

API changes

Behavioural changes

Backwards compatibility

Follow-up

Tests

@alvin0319 alvin0319 changed the title BaseInventory: Fixed crash when invalid array of items are given BaseInventory: Validate given array to make sure correct items are given. Nov 5, 2022
@dktapps dktapps merged commit 1e9d83f into pmmp:stable Nov 7, 2022
@dktapps dktapps added Category: API Related to the plugin API Type: Contribution labels Nov 7, 2022
@dktapps
Copy link
Member

dktapps commented Nov 7, 2022

For posterity: Validation of array types this way is only necessary if the method in question is exposed to plugins.

Internal-use stuff doesn't require validation since PHPStan will take care of it (and runtime validation hurts performance).

@dktapps dktapps added Type: Enhancement Contributes features or other improvements to PocketMine-MP and removed Type: Contribution labels Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: API Related to the plugin API Type: Enhancement Contributes features or other improvements to PocketMine-MP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments