Page MenuHomePhabricator

GlobalContributions: Fix database error when accessing Special:GlobalContributions for a user account
Closed, ResolvedPublicPRODUCTION ERROR

Description

Background

We added links to Special:GlobalContributions from other contributions pages in T384010. When clicking this link on some wikis, a database error is encountered:

Error 1146: Table 'loginwiki.ores_classification' doesn't exist
Function: MediaWiki\CheckUser\GlobalContributions\GlobalContributionsPager::reallyDoQuery

Example: https://test.wikipedia.org/wiki/Special:GlobalContributions/~2025-14155

  • This doesn't occur when accessing GlobalContributions for a user account on metawiki
  • This doesn't occur when accessing GlobalContributions for an IP address on testwiki

Technical notes

The problem seems to come from ORES handling ContribsPager__getQueryInfoHook: code

All contributions special pages run that hook (to allow extensions like Flow to add their contributions). Since that handler is documented only to apply to Special:Contributions, the handler should be updated to return early if the pager is not an instance of ContribsPager.

Note that a few other extensions also handle this hook, and should also be audited and updated. E.g. FlaggedRevs (see T385092#10507707).

Acceptance criteria

  • Visiting Special:GlobalContributions/<some user> from affected wikis (e.g. testwiki) should successfully redirect to Special:GlobalContributions/<some user> on metawiki

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Thanks for creating this - I was about to file a production error report after also discovering this on testwiki myself :)

Restricted Application changed the subtype of this task from "Task" to "Production Error". · View Herald TranscriptJan 29 2025, 7:02 PM

In case it's helpful, noting here that - on test2wiki - the database error refers to loginwiki.flaggedrevs rather than loginwiki.ores_classification:

https://test2.wikipedia.org/wiki/Special:GlobalContributions/~2025-14155

[c9ab70e3-3905-45ae-917b-3435da93145c]

Error 1146: Table 'loginwiki.flaggedrevs' doesn't exist
Function: MediaWiki\CheckUser\GlobalContributions\GlobalContributionsPager::reallyDoQuery

Thanks @A_smart_kitten - I've updated the task description to check for other extensions too.

This issue is happening on Special:GlobalContributions becuase GlobalContributionsPager is building a query on the local wiki (running hooks locally, handled by extensions that are loaded locally, potentially adding extension-specific statements to the query), then running that query on external wikis, where the extension may not be loaded.

Several hooks are run from ContributionsPager, which is the parent class of pagers for various contributions pages (Special:Contributions, Special:DeletedContributions, Special:IPContributions, Special:GlobalContributions). The hooks are: onContribsPager__reallyDoQuery, onContributionsLineEnding, onDeletedContribsPager__reallyDoQuery, onDeletedContributionsLineEnding, onSpecialContributions__formatRow__flags and onContribsPager__getQueryInfo. The hooks used to be run from ContribsPager (for Special:Contributions) and DeletedContribsPager (for Special:DeletedContribuitons), before these were refactored to extend a single parent class.

  • Pro of running the hooks from the parent: they potentially allow extra information to show up on all contributions pages, e.g. Flow edits, FlaggedRevs statuses.
  • Con of running the hooks from the parent: new special pages extending the parent may behave in ways that the extension hook handlers didn't predict

Possible approaches to solve this:

  • Only run the above hooks from ContribsPager and DeletedContribsPager as originally intended (but then we lose information from some pages)
  • Adapt all of the extension handler to specify which special pages they should work on (difficult to maintain, and odd for extensions to know about each other, e.g. Flow adding a case for IPContributions)
  • Allow subclasses of ContributionsPager to configure whether to run the various hooks

Change #1115906 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/core@master] ContributionsPager: Allow subclasses to run hooks optionally

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

Change #1115907 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/extensions/CheckUser@master] GlobalContributions: Prevent running hooks from the pager class

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

Thanks @Dreamy_Jazz; I was looking for "DBQueryError", and didn't find anything). Sorry for the duplicate!

Change #1115906 merged by jenkins-bot:

[mediawiki/core@master] ContributionsPager: Allow subclasses to run hooks optionally

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

Change #1115907 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] GlobalContributions: Prevent running hooks from the pager class

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