SpecialNuke: Display username next to pages for temp accounts

Why:

- When deleting pages created by temporary accounts via inputting an IP
  address, it's useful to see which temporary accounts were involved in
  creating the pages. This is currently not displayed because
  $row->rc_user_text is not set

What:

- Fetch the actor_name field unconditionally
- Display the page using the actor_name field
- Update tests for the change

Bug: T342785
Change-Id: Ic4112985874343ede78c4571bdfccc58977c5345
This commit is contained in:
Kosta Harlan 2024-10-17 14:50:48 +02:00
parent 00729bdd58
commit f1d53c8244
No known key found for this signature in database
GPG key ID: BC3D8915606A5ED9
2 changed files with 9 additions and 14 deletions

View file

@ -451,13 +451,10 @@ class SpecialNuke extends SpecialPage {
->orderBy( 'rc_timestamp', SelectQueryBuilder::SORT_DESC ) ->orderBy( 'rc_timestamp', SelectQueryBuilder::SORT_DESC )
->limit( $limit ); ->limit( $limit );
if ( $username === '' ) { $queryBuilder->field( 'actor_name', 'rc_user_text' );
$queryBuilder->field( 'actor_name', 'rc_user_text' ); $actornames = array_filter( [ $username, ...$tempnames ] );
} else { if ( $actornames ) {
$actornames = array_filter( [ $username, ...$tempnames ] ); $queryBuilder->andWhere( [ 'actor_name' => $actornames ] );
if ( $actornames ) {
$queryBuilder->andWhere( [ 'actor_name' => $actornames ] );
}
} }
if ( $namespace !== null ) { if ( $namespace !== null ) {
@ -559,7 +556,7 @@ class SpecialNuke extends SpecialPage {
foreach ( $result as $row ) { foreach ( $result as $row ) {
$pages[] = [ $pages[] = [
Title::makeTitle( $row->page_namespace, $row->page_title ), Title::makeTitle( $row->page_namespace, $row->page_title ),
$username === '' ? $row->rc_user_text : false $row->rc_user_text
]; ];
} }

View file

@ -251,8 +251,7 @@ class SpecialNukeTest extends SpecialPageTestBase {
$this->assertStringContainsString( 'Target1', $html ); $this->assertStringContainsString( 'Target1', $html );
$this->assertStringContainsString( 'Target2', $html ); $this->assertStringContainsString( 'Target2', $html );
$usernameCount = substr_count( $html, $ip ); $this->assertEquals( 2, substr_count( $html, '(nuke-editby: 127.0.0.1)' ) );
$this->assertStringContainsString( 5, $usernameCount );
} }
/** /**
@ -285,8 +284,7 @@ class SpecialNukeTest extends SpecialPageTestBase {
$adminPerformer = new UltimateAuthority( $adminUser ); $adminPerformer = new UltimateAuthority( $adminUser );
[ $html ] = $this->executeSpecialPage( '', $request, 'qqx', $adminPerformer ); [ $html ] = $this->executeSpecialPage( '', $request, 'qqx', $adminPerformer );
$usernameCount = substr_count( $html, $ip ); $this->assertEquals( 2, substr_count( $html, '(nuke-editby: ~2024-1)' ) );
$this->assertStringContainsString( 1, $usernameCount );
$this->assertStringContainsString( '(nuke-list-tempaccount:', $html ); $this->assertStringContainsString( '(nuke-list-tempaccount:', $html );
$this->assertStringContainsString( 'Target1', $html ); $this->assertStringContainsString( 'Target1', $html );
@ -332,8 +330,8 @@ class SpecialNukeTest extends SpecialPageTestBase {
$adminPerformer = new UltimateAuthority( $adminUser ); $adminPerformer = new UltimateAuthority( $adminUser );
[ $html ] = $this->executeSpecialPage( '', $request, 'qqx', $adminPerformer ); [ $html ] = $this->executeSpecialPage( '', $request, 'qqx', $adminPerformer );
$usernameCount = substr_count( $html, $ip ); $this->assertSame( 1, substr_count( $html, ' (nuke-editby: ~2024-1)' ) );
$this->assertStringContainsString( 1, $usernameCount ); $this->assertSame( 1, substr_count( $html, ' (nuke-editby: 1.2.3.4)' ) );
// They should all show up together // They should all show up together
$this->assertStringContainsString( '(nuke-list-tempaccount:', $html ); $this->assertStringContainsString( '(nuke-list-tempaccount:', $html );