MediaWiki's import functionality often leaves the edit counter in a wrong state. There is a core maintenance script (initEditCount) to fix the local counter, but that still leaves CA's global counter out of sync. In these situations it'd be useful to have a script in CA to re-calculate the global edit count for all users with a local account in a specific wiki.
Description
Details
| Subject | Repo | Branch | Lines +/- | |
|---|---|---|---|---|
| Add script to reset edit count for all users in a specific wiki | mediawiki/extensions/CentralAuth | master | +95 -0 |
Related Objects
- Mentioned In
- T413390: Renaming a user still doubles their edit count (December 2025)
- Mentioned Here
- T404573: Import tokwiki from Wikipesija.org
Event Timeline
There are two kinda similar maint scripts in CentralAuth that you could adapt:
- https://gerrit.wikimedia.org/g/mediawiki/extensions/CentralAuth/+/4ade9e707b569770b57e31fe26c36a57d8c7ae96/maintenance/populateGlobalEditCount.php
- https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/CentralAuth/+/4ade9e707b569770b57e31fe26c36a57d8c7ae96/maintenance/FixRenamedUserGlobalEditCount.php
The second one would probably be easier to start from.
Basically just need to call CentralAuthEditCounter::recalculate(). Could add a maint script around it, but it's straightforward enough that you can just do something like echo 'MW::srv()->get( 'CentralAuth.CentralAuthEditCounter' )->recalculate( MWCA::user( 'Foo' ) )' | run.php shell instead.
Maybe there should be a "reset editcount" hook or domain event in core that CA can listen to, but I'm not sure it's worth the effort.
Change #1216562 had a related patch set uploaded (by Majavah; author: Majavah):
[mediawiki/extensions/CentralAuth@master] Add script to reset edit count for all users in a specific wiki
Change #1216562 merged by jenkins-bot:
[mediawiki/extensions/CentralAuth@master] Add script to reset edit count for all users in a specific wiki
(For future reference, this was motivated by T404573: Import tokwiki from Wikipesija.org, and the script was ran on tokwiki on 2025-12-09)