Page MenuHomePhabricator

CannotCreateActorException when renaming the currently-logged-in user
Open, Needs TriagePublic

Description

[exception] [55ef3d6d2b5a9078e582824f] /wiki/index.php/Special:%E9%87%8D%E5%91%BD%E5%90%8D%E7%94%A8%E6%88%B7   CannotCreateActorException from line 312 of C:\xampp\apps\mediawiki\htdocs\includes\ActorMigration.php: Failed to create actor ID for user_id=1 user_name="User670"
#0 C:\xampp\apps\mediawiki\htdocs\includes\ActorMigration.php(351): ActorMigration->getNewActorId(Wikimedia\Rdbms\MaintainableDBConnRef, User)
#1 C:\xampp\apps\mediawiki\htdocs\includes\logging\ManualLogEntry.php(295): ActorMigration->getInsertValues(Wikimedia\Rdbms\MaintainableDBConnRef, string, User)
#2 C:\xampp\apps\mediawiki\htdocs\extensions\Renameuser\includes\RenameuserSQL.php(346): ManualLogEntry->insert()
#3 C:\xampp\apps\mediawiki\htdocs\extensions\Renameuser\includes\SpecialRenameuser.php(310): RenameuserSQL->rename()
#4 C:\xampp\apps\mediawiki\htdocs\includes\specialpage\SpecialPage.php(600): SpecialRenameuser->execute(NULL)
#5 C:\xampp\apps\mediawiki\htdocs\includes\specialpage\SpecialPageFactory.php(635): SpecialPage->run(NULL)
#6 C:\xampp\apps\mediawiki\htdocs\includes\MediaWiki.php(307): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#7 C:\xampp\apps\mediawiki\htdocs\includes\MediaWiki.php(940): MediaWiki->performRequest()
#8 C:\xampp\apps\mediawiki\htdocs\includes\MediaWiki.php(543): MediaWiki->main()
#9 C:\xampp\apps\mediawiki\htdocs\index.php(53): MediaWiki->run()
#10 C:\xampp\apps\mediawiki\htdocs\index.php(46): wfIndexMain()
#11 {main}

Installation: Bitnami MediaWiki installer, XAMPP, on Windows 10. Mediawiki version 1.35.0, PHP version 7.4.11.
I installed the extension by adding wfLoadExtension("Renameuser"); to LocalSettings.php; I didn't touch any other files.

Steps to reproduce:

  • Go to Special:RenameUser
  • Fill out the currently-logged-in user's username as the old username, and a new username (*)
  • Submit
  • And an error page shows up.

(*) The wiki only has two users, MediaWiki Default (no special usergroups) and User670 (bureaucrat, interface administrator, administrator). I am logged in as User670, and I tried to rename User670 (i.e. myself) using that page.

Additional testing:
I created a new user, Test, and used User670 to rename Test to Test1. Success.
I gave Test1 permissions, then used Test1 to rename User670 to User671. Success.
I used Test1 to rename Test1 to Test2. Fail with the same error.

Event Timeline

I don't think you're supposed to be able to rename yourself...

I don't think you're supposed to be able to rename yourself...

Yeah, probably, but if that's the case I suppose it's better to have a message "You can't rename yourself" rather than throw an exception that no one understands.

You are supposed to be able to rename yourself, as shown by this in the extension source code:

// If this user is renaming his/herself, make sure that MovePage::move()
// doesn't make a bunch of null move edits under the old name!
if ( $user->getId() === $uid ) {
    $user->setName( $newusername->getText() );
}

However, looking around in the SQL debug log and the code, it seems that a bug was added that prevents this, with the actor migration changes:

  1. The user's name is updated
  2. The actor record is updated
  3. Later in the process, a ManualLogEntry is created, passing the unmodified $this->renamer User as the performer
  4. The log insertion tries to find/create an actor record to use for the log entry
  5. This fails, because the actor record has been updated but the renamer/performer object has not

The above code that patches up the username in the in-memory object for the current user either needs to be duplicated or happen earlier, so that the new name is the one passed to ManualLogEntry as performer.

For the record, it works properly when trying to rename the same user globally (returns an error saying that "you cannot rename yourself"). The problem is only local.

I can confirm that I am having the same issue on MediaWiki version 1.36.1 on Debian.