Fix composite block start time
Fix the start time for composite block in the block error message Bug: T323105 Change-Id: I29b9f4ba84ee760425cc9ba3a1c58ed22e889d86
This commit is contained in:
parent
4251445825
commit
58c9abee47
2 changed files with 35 additions and 0 deletions
|
|
@ -108,6 +108,20 @@ class CompositeBlock extends AbstractBlock {
|
|||
return $this->originalBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTimestamp(): string {
|
||||
$minStart = null;
|
||||
foreach ( $this->originalBlocks as $block ) {
|
||||
$startTime = $block->getTimestamp();
|
||||
if ( $minStart === null || $startTime === '' || $startTime < $minStart ) {
|
||||
$minStart = $startTime;
|
||||
}
|
||||
}
|
||||
return $minStart ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -246,6 +246,27 @@ class CompositeBlockTest extends MediaWikiLangTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
public function testTimestamp() {
|
||||
$timestamp = 20000101000000;
|
||||
|
||||
$firstBlock = $this->createMock( DatabaseBlock::class );
|
||||
$firstBlock->method( 'getTimestamp' )
|
||||
->willReturn( (string)$timestamp );
|
||||
|
||||
$secondBlock = $this->createMock( DatabaseBlock::class );
|
||||
$secondBlock->method( 'getTimestamp' )
|
||||
->willReturn( (string)( $timestamp + 10 ) );
|
||||
|
||||
$thirdBlock = $this->createMock( DatabaseBlock::class );
|
||||
$thirdBlock->method( 'getTimestamp' )
|
||||
->willReturn( (string)( $timestamp + 100 ) );
|
||||
|
||||
$block = new CompositeBlock( [
|
||||
'originalBlocks' => [ $thirdBlock, $firstBlock, $secondBlock ],
|
||||
] );
|
||||
$this->assertSame( (string)$timestamp, $block->getTimestamp() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of BlockRestrictionStore
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue