Page MenuHomePhabricator

Attempt to undelete page causes error: Fatal exception of type IncompleteRevisionException: user_text field must not be ''!
Closed, ResolvedPublicPRODUCTION ERROR

Description

I was attempting to undelete the page "List of people by name: Johns" on enwiki to make it easier to import an old edit into its history from the Nostalgia Wikipedia. I received this error as a result:
[WwoLcQpAMFIAAD@ZR1YAAAAC] 2018-05-27 01:35:46: Fatal exception of type "MediaWiki\Storage\IncompleteRevisionException"

I found a way around this without having to undelete any of the edits, and the page doesn't need to be restored. However, I'm reporting this problem in case it points to a deeper issue.

exception.class	       	MediaWiki\Storage\IncompleteRevisionException
exception.file	       	/srv/mediawiki/php-1.32.0-wmf.4/includes/Storage/RevisionStore.php:310
exception.message	user_text field must not be ''!
exception.trace
#0 /srv/mediawiki/php-1.32.0-wmf.4/includes/Storage/RevisionStore.php(402): MediaWiki\Storage\RevisionStore->failOnEmpty(string, string)
#1 /srv/mediawiki/php-1.32.0-wmf.4/includes/Revision.php(1091): MediaWiki\Storage\RevisionStore->insertRevisionOn(MediaWiki\Storage\RevisionArchiveRecord, Wikimedia\Rdbms\DatabaseMysqli)
#2 /srv/mediawiki/php-1.32.0-wmf.4/includes/page/PageArchive.php(678): Revision->insertOn(Wikimedia\Rdbms\DatabaseMysqli)
#3 /srv/mediawiki/php-1.32.0-wmf.4/includes/page/PageArchive.php(419): PageArchive->undeleteRevisions(array, boolean, string)
#4 /srv/mediawiki/php-1.32.0-wmf.4/includes/specials/SpecialUndelete.php(1147): PageArchive->undelete(array, string, array, boolean, User)
#5 /srv/mediawiki/php-1.32.0-wmf.4/includes/specials/SpecialUndelete.php(201): SpecialUndelete->undelete()
#6 /srv/mediawiki/php-1.32.0-wmf.4/includes/specialpage/SpecialPage.php(522): SpecialUndelete->execute(NULL)
#7 /srv/mediawiki/php-1.32.0-wmf.4/includes/specialpage/SpecialPageFactory.php(568): SpecialPage->run(NULL)
#8 /srv/mediawiki/php-1.32.0-wmf.4/includes/MediaWiki.php(288): SpecialPageFactory::executePath(Title, RequestContext)
#9 /srv/mediawiki/php-1.32.0-wmf.4/includes/MediaWiki.php(861): MediaWiki->performRequest()
#10 /srv/mediawiki/php-1.32.0-wmf.4/includes/MediaWiki.php(524): MediaWiki->main()
#11 /srv/mediawiki/php-1.32.0-wmf.4/index.php(42): MediaWiki->run()
#12 /srv/mediawiki/w/index.php(3): include(string)
#13 {main}
exception_id	       	WwoLcQpAMFIAAD@ZR1YAAAAC
exception_url	       	/w/index.php?title=Special:Undelete&action=submit

Event Timeline

Aklapper updated the task description. (Show Details)

Thanks for reporting this!
Error might surface "now" because of https://phabricator.wikimedia.org/rMW7eb7f04771a7c246ec67b15b445ba588daa4c92c .
I added the corresponding stacktrace. Might be MCR territory but leaving that to the developers.

Aklapper renamed this task from Attempt to undelete page causes error: Fatal exception of type "MediaWiki\Storage\IncompleteRevisionException to Attempt to undelete page causes error: Fatal exception of type IncompleteRevisionException: user_text field must not be ''!.May 27 2018, 9:09 PM

This would happen if there was a row in the archive table with ar_user_text = ''. The question is then - why is it there, can it be fixed, and how do we handle this siutation more gracefully. The system expects every revision to have a "actor". What do we do if that information was somehow lost?

You'd say wrong. Patches for T174025: Implement MCR revision retrieval legacy version are the cause. The actor table stuff doesn't care if the name is empty.

This would happen if there was a row in the archive table with ar_user_text = ''. The question is then - why is it there, can it be fixed, and how do we handle this siutation more gracefully. The system expects every revision to have a "actor". What do we do if that information was somehow lost?

Sigh. There are indeed such rows, on multiple wikis. There are also rows in revision with rev_user_text = ''. No idea why, best guess is "old bugs". Or possibly someone screwing up the XML file when doing imports, based on the revisions with relatively recent timestamps that I checked all seeming to be on imported revisions.

Probably the most straightforward thing to do is to use the user_id (or actor_id) to get the name if one is set (which is hopefully already happening), and otherwise set it to "Unknown user".

Probably the most straightforward thing to do is to use the user_id (or actor_id) to get the name if one is set (which is hopefully already happening), and otherwise set it to "Unknown user".

This does happen, via User::newFromAnyId(). I'm having a hard time actually reproducing this. With user=0 and user_text='', I get InvalidArgumentException( 'Cannot create a user with no name, no ID, and no actor ID' ) from User::newFromAnyId. With a valid ID, the correct user is loaded and the name is used. With a bad ID, the name is set to "127.0.0.1" by virtue of User::loadDefaults() being called from User::loadFromDatabase() when failing to find a database row.

EDIT: found it. RevisionStore catches the InvalidArgumentException, logs a warning, and then does new UserIdentityValue( 0, '', 0 );

Anyway. We still need to be able to restore revisions that have user=0 and user_text=''. Setting it to "Unknown user" doesn't seem safe, since it is possible to actually create a user with that name, no? Maybe it could be set to "<unknown>" or something like that?

Change 435822 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] Use "<unknown>" as the user name when ar_user_text is empty.

https://gerrit.wikimedia.org/r/435822

@Anomie oh, I didn't know that, thanks! amended.

Vvjjkkii renamed this task from Attempt to undelete page causes error: Fatal exception of type IncompleteRevisionException: user_text field must not be ''! to f7baaaaaaa.Jul 1 2018, 1:07 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed subscribers: gerritbot, Aklapper.
CommunityTechBot renamed this task from f7baaaaaaa to Attempt to undelete page causes error: Fatal exception of type IncompleteRevisionException: user_text field must not be ''!.Jul 2 2018, 3:40 PM
CommunityTechBot raised the priority of this task from High to Needs Triage.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added subscribers: gerritbot, Aklapper.
Krinkle triaged this task as High priority.Jul 11 2018, 2:12 AM
Krinkle subscribed.

Given this would cause a valid user action to fail without recovery or workaround, raising priority.

I just rebased the patch, should be ready to be merged

Change 435822 merged by jenkins-bot:
[mediawiki/core@master] Use "Unknown user" instead of an empty user name.

https://gerrit.wikimedia.org/r/435822

Tgr claimed this task.
Tgr reassigned this task from Tgr to daniel.
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:09 PM