Throw if action codes in getAllBlockActions aren't unique

Duplicate action codes (eg. extensions assign colliding action ids)
will caused unexpected partial blocking behavior. This lets someone
know that there's a duplicate by throwing before that happens.

Bug: T281915
Change-Id: I34cab4360d40805a9259cf6f2b4cbf05cee6184c
This commit is contained in:
STran 2021-05-04 12:12:17 -07:00
parent da771ce005
commit 4d9d73819a

View file

@ -22,6 +22,7 @@ namespace MediaWiki\Block;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MWException;
/**
* Defines the actions that can be blocked by a partial block. They are
@ -92,6 +93,9 @@ class BlockActionInfo {
$this->allBlockActions = self::CORE_BLOCK_ACTIONS;
$this->hookRunner->onGetAllBlockActions( $this->allBlockActions );
}
if ( count( $this->allBlockActions ) !== count( array_unique( $this->allBlockActions ) ) ) {
throw new MWException( 'Blockable action IDs not unique' );
}
return $this->allBlockActions;
}