X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fblock%2FCompositeBlock.php;h=45a630149ce2dc81b00388ae6c2b4c78948556ef;hb=da5cb173418ae4f27e88ce5c6a3f13ac3bc08bab;hp=8efd7de956d7064b86337e60195bea2de0892842;hpb=20e65a191541681c05d289efaf4edb20429da73d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/block/CompositeBlock.php b/includes/block/CompositeBlock.php index 8efd7de956..45a630149c 100644 --- a/includes/block/CompositeBlock.php +++ b/includes/block/CompositeBlock.php @@ -43,7 +43,7 @@ class CompositeBlock extends AbstractBlock { * @param array $options Parameters of the block: * originalBlocks Block[] Blocks that this block is composed from */ - function __construct( $options = [] ) { + public function __construct( array $options = [] ) { parent::__construct( $options ); $defaults = [ @@ -120,12 +120,40 @@ class CompositeBlock extends AbstractBlock { return $maxExpiry; } + /** + * Get the IDs for the original blocks, ignoring any that are null + * + * @return int[] + */ + protected function getIds() { + $ids = []; + foreach ( $this->originalBlocks as $block ) { + $id = $block->getId(); + if ( $id !== null ) { + $ids[] = $id; + } + } + return $ids; + } + /** * @inheritDoc */ public function getPermissionsError( IContextSource $context ) { $params = $this->getBlockErrorParams( $context ); + $ids = implode( ', ', array_map( function ( $id ) { + return '#' . $id; + }, $this->getIds() ) ); + if ( $ids === '' ) { + $idsMsg = $context->msg( 'blockedtext-composite-no-ids' )->plain(); + } else { + $idsMsg = $context->msg( 'blockedtext-composite-ids', [ $ids ] )->plain(); + } + + // TODO: Clean up error messages params so we don't have to do this (T227174) + $params[ 4 ] = $idsMsg; + $msg = 'blockedtext-composite'; array_unshift( $params, $msg );