Page MenuHomePhabricator

User.php: Cannot create a user with no name, no ID, and no actor ID
Closed, ResolvedPublic

Description

Error

Request URL: https://id.wiktionary.org/w/api.php?format=json&action=query&list=recentchanges&rctoken=patrol
Request ID: INSERT_ID

message
/w/api.php?format=json&action=query&list=recentchanges&rctoken=patrol
trace
#0 /srv/mediawiki/php-1.34.0-wmf.14/includes/changes/RecentChange.php(1066): User::newFromAnyId(NULL, NULL, NULL)
#1 /srv/mediawiki/php-1.34.0-wmf.14/includes/changes/RecentChange.php(137): RecentChange->loadFromRow(stdClass)
#2 /srv/mediawiki/php-1.34.0-wmf.14/includes/api/ApiQueryRecentChanges.php(623): RecentChange::newFromRow(stdClass)
#3 /srv/mediawiki/php-1.34.0-wmf.14/includes/api/ApiQueryRecentChanges.php(438): ApiQueryRecentChanges->extractRowInfo(stdClass)
#4 /srv/mediawiki/php-1.34.0-wmf.14/includes/api/ApiQueryRecentChanges.php(133): ApiQueryRecentChanges->run()
#5 /srv/mediawiki/php-1.34.0-wmf.14/includes/api/ApiQuery.php(250): ApiQueryRecentChanges->execute()
#6 /srv/mediawiki/php-1.34.0-wmf.14/includes/api/ApiMain.php(1583): ApiQuery->execute()
#7 /srv/mediawiki/php-1.34.0-wmf.14/includes/api/ApiMain.php(531): ApiMain->executeAction()
#8 /srv/mediawiki/php-1.34.0-wmf.14/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()
#9 /srv/mediawiki/php-1.34.0-wmf.14/api.php(86): ApiMain->execute()
#10 /srv/mediawiki/w/api.php(3): include(string)
#11 {main}

Impact

TBD

Notes

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 18 2019, 2:06 PM
LarsWirzenius triaged this task as Unbreak Now! priority.Jul 18 2019, 2:06 PM
Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptJul 18 2019, 2:06 PM
hashar updated the task description. (Show Details)Jul 18 2019, 2:26 PM

I don't know what's happening here but the rctoken parameter is deprecated.

It behaves the same on wmf.13 and wmf.14 so maybe not a train blocker.

hashar lowered the priority of this task from Unbreak Now! to Medium.Jul 18 2019, 2:30 PM
hashar added a project: MediaWiki-API.
hashar added a subscriber: hashar.

Can be reproduced using logged in or not with:

https://id.wiktionary.org/w/api.php?format=json&action=query&list=recentchanges&rctoken=patrol

If one removes rctoken=patrol the query works just fine (logged in or not).

Additional note, there is a warning stating:

"The parameter \"rctoken\" has been deprecated."

I am assuming it is a user or bot that inject some extra parameter, though surely that should not cause an exception but the rctoken should just be dismissed?

Thanks, @SBisson. I'll downgrade and remove as blocker.

Same on enwiki https://en.wikipedia.org/w/api.php?format=json&action=query&list=recentchanges&rctoken=patrol

So after all, maybe the exception is reported because the parameter has been deprecated.

So after all, maybe the exception is reported because the parameter has been deprecated.

It's been deprecated 5 years ago ;) Maybe it's time to followup and remove it?

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/153110

Krinkle added a subscriber: Krinkle.

The fatal is because the code that handles rctoken (any rctoken value, including rctoken=patrol) uses RecentChange::newFromRow( $row ) which expects to be given a complete recentchanges table row. Specifically, RecentChange::newFromRow calls RecentChange::loadFromRow when then calls:

RecentChange::loadFromRow
User::newFromAnyId(
	$this->mAttribs['rc_user'] ?? null,
	$this->mAttribs['rc_user_text'] ?? null,
	$this->mAttribs['rc_actor'] ?? null
);

But, ApiQueryRecentChanges does not select any of these three fields from the database by default. It only selects them if the API asks for them to be in the JSON response, by adding rcprop=user to the request URL.

This urls fatals: https://id.wiktionary.org/w/api.php?format=json&action=query&list=recentchanges&rctoken=patrol.

But this one does not: https://id.wiktionary.org/w/api.php?format=json&action=query&list=recentchanges&rctoken=patrol&rcprop=user.

Restricted Application added a project: Growth-Team. · View Herald TranscriptJul 18 2019, 4:02 PM

Change 524257 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] API: Always select rc_user from database (regardless of rcprop=user)

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

Anomie moved this task from Unsorted to Needs Review on the MediaWiki-API board.Jul 18 2019, 4:17 PM
Anomie added a subscriber: Anomie.

So after all, maybe the exception is reported because the parameter has been deprecated.

It's been deprecated 5 years ago ;) Maybe it's time to followup and remove it?

https://logstash.wikimedia.org/goto/e356f3a96fd7e3b41472e762598ec734 shows half a million uses in the last 24 hours. The pattern of user agents hints at user scripts rather than bots, and almost all of the hits are on zhwiki. If someone will track down the script(s) there and update them, then it should be safe to do so.

Alternatively, we could just fix the code as in @Krinkle's patch.

Change 524257 merged by jenkins-bot:
[mediawiki/core@master] API: Always select rc_user from database (regardless of rcprop=user)

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

Anomie closed this task as Resolved.Aug 15 2019, 5:45 PM
Anomie assigned this task to Krinkle.
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:06 PM