Page MenuHomePhabricator

populateUserTable.php in mediawiki/tools/grabbers is setting `user`.`user_touched`=0, breaking some extensions
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:

Install the https://www.mediawiki.org/wiki/Manual:Grabbers#PHP_scripts and a blank local MW1.31 installation. Run the scripts to grab text, files, logs or other content. Run php maintenance/populateUserTable.php to generate the "stub" user entries reserving any names that belonged to users on the original wiki.

Take a look at the user table ( SELECT * FROM user ) in SQL; the user.user_touched field will contain 0 (which is not a valid date, unless you were born in a manger in Bethlehem).

Any of the related extensions which attempt to update these records will throw errors because of the bogus zero (0) date.

Actual Results:

MWException from line 4158 of ...//includes/user/User.php: CAS update failed on user_touched for user ID '0000' (read from master); the version of the user to be saved is older than the current version.

Backtrace:

#0 [internal function]: User->{closure}(Wikimedia\Rdbms\DatabaseMysqli, string)
#1 ...//includes/libs/rdbms/database/Database.php(3664): call_user_func_array(Closure, array)
#2 ...//includes/user/User.php(4172): Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#3 ...//extensions/StubUserWikiAuth/includes/StubUserWikiPasswordAuthenticationProvider.php(179): User->saveSettings()
#4 ...//includes/auth/AuthManager.php(453): StubUserWikiAuth\StubUserWikiPasswordAuthenticationProvider->beginPrimaryAuthentication(array)
#5 ...//includes/auth/AuthManager.php(383): MediaWiki\Auth\AuthManager->continueAuthentication(array)
#6 ...//includes/specialpage/AuthManagerSpecialPage.php(353): MediaWiki\Auth\AuthManager->beginAuthentication(array, string)
#7 ...//includes/specialpage/AuthManagerSpecialPage.php(482): AuthManagerSpecialPage->performAuthenticationStep(string, array)
#8 ...//includes/htmlform/HTMLForm.php(660): AuthManagerSpecialPage->handleFormSubmit(array, VFormHTMLForm)
#9 ...//includes/specialpage/AuthManagerSpecialPage.php(416): HTMLForm->trySubmit()
#10 ...//includes/specialpage/LoginSignupSpecialPage.php(316): AuthManagerSpecialPage->trySubmit()
#11 ...//includes/specialpage/SpecialPage.php(522): LoginSignupSpecialPage->execute(NULL)
#12 ...//includes/specialpage/SpecialPageFactory.php(568): SpecialPage->run(NULL)
#13 ...//includes/MediaWiki.php(288): SpecialPageFactory::executePath(Title, RequestContext)
#14 ...//includes/MediaWiki.php(861): MediaWiki->performRequest()
#15 ...//includes/MediaWiki.php(524): MediaWiki->main()
#16 ...//index.php(42): MediaWiki->run()
#17 {main}

Expected Results:

To obtain the expected result (the system attempts to log the user in instead of throwing errors once a password is supplied), just update user.user_touched='20000101010101' (or some other valid date suitably far in the past) and try to log in.

Event Timeline

Carlb created this task.Apr 1 2019, 11:12 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 1 2019, 11:12 PM
Peachey88 updated the task description. (Show Details)Apr 2 2019, 10:50 AM
Isarra added a comment.Apr 2 2019, 3:07 PM

Is there any particular reason why we shouldn't just be setting the user_touched to time-of-running-script, since we're basically touching everything everywhere while we're doing all this anyway?

Isarra added a comment.Apr 2 2019, 3:13 PM

Although we haven't been running into anything like this that I know of with MediaWikiAuth on 1.32, and I don't think we modified populateUserTable at all - so it's also possible whatever core issue this is triggering might have been fixed in 1.32? Or maybe the MWA approach is different? (It's not actually merged yet, see https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MediaWikiAuth/+/499671)

Isarra added a comment.Apr 2 2019, 3:15 PM

Eh, okay, looks like master is going to barf all over on an invalid timestamp regardless. Which probably makes sense - why in the world wouldn't you normally have one?

So we definitely need to set it to something here.

Change 500764 had a related patch set uploaded (by Jack Phoenix; owner: Jack Phoenix):
[mediawiki/tools/grabbers@master] Set user_touched to something that is a valid timestamp in the TS_MW format

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

Change 500764 merged by Isarra:
[mediawiki/tools/grabbers@master] Set user_touched to something that is a valid timestamp in the TS_MW format

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

Ciencia_Al_Poder closed this task as Resolved.May 22 2019, 8:01 PM
Ciencia_Al_Poder assigned this task to Isarra.