Why: * Naming conflicts may arise on autocreation. * For example, when generating temporary user names, the config wgAutoCreateTempUser['serialMapping']['type'] determines how the unique, numerical part of the name is generated, and naming conflicts may arise when changing types. * Specifically we encountered the case of changing the $wgAutoCreateTempUser['serialMapping']['type'] from 'scramble' to 'plain-numeric'. * In general conflict could be avoided in 'plain-numeric' mode if the highest number used in an existing username is known, by adding an offset. What: * Handle an 'offset' config option in PlainNumericSerialMapping to allow avoiding conflicts. Bug: T353545 Change-Id: Id2f9a5b5cc808ce859b93b597cf7ea0efcd9e269
21 lines
608 B
PHP
21 lines
608 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\User\TempUser;
|
|
|
|
use MediaWiki\User\TempUser\PlainNumericSerialMapping;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\User\TempUser\PlainNumericSerialMapping
|
|
*/
|
|
class PlainNumericSerialMappingTest extends TestCase {
|
|
public function testGetSerialIdForIndex() {
|
|
$map = new PlainNumericSerialMapping( [] );
|
|
$this->assertSame( '111', $map->getSerialIdForIndex( 111 ) );
|
|
}
|
|
|
|
public function testGetSerialIdForIndexWithOffset() {
|
|
$map = new PlainNumericSerialMapping( [ 'offset' => 111 ] );
|
|
$this->assertSame( '222', $map->getSerialIdForIndex( 111 ) );
|
|
}
|
|
}
|