Page MenuHomePhabricator

[Mediawiki History] Fix missing event_user_is_created_by values
Open, Needs TriagePublic

Description

In theory, a user account on a wiki can either be created by themselves (standard account creation), the system (you log in to a new wiki for the first time), or a peer (see documentation). Currently a large number of accounts (contributing 15% of edits on English Wikipedia) have neither of these values set to true though in Mediawiki History, which should never be the case. There's one small bug fix that would help a bit (see below) but that's not the full story as I found examples of accounts that I think should have been handled fine but weren't (see internal slack thread).

Extent of issue

# example from recent snapshot for english wikipedia (PySpark)
spark.sql("""
SELECT
  event_user_is_created_by_self,
  event_user_is_created_by_system,
  event_user_is_created_by_peer,
  COUNT(1) AS num_times
FROM wmf.mediawiki_history
WHERE
  snapshot = '2026-06'
  AND wiki_db = 'enwiki'
  AND event_entity = "revision"
  AND event_type = "create"
  AND event_user_is_permanent
GROUP BY
  event_user_is_created_by_self,
  event_user_is_created_by_system,
  event_user_is_created_by_peer
ORDER BY
  num_times DESC
""").show(500, False)

+-----------------------------+-------------------------------+-----------------------------+---------+
|event_user_is_created_by_self|event_user_is_created_by_system|event_user_is_created_by_peer|num_times|
+-----------------------------+-------------------------------+-----------------------------+---------+
|true                         |false                          |false                        |756290673|
|false                        |false                          |false                        |172815519|
|false                        |false                          |true                         |121188855|
|false                        |true                           |false                        |65967283 |
+-----------------------------+-------------------------------+-----------------------------+---------+

Simple bug fix

Add the logging table value of forcecreatelocal to the createdBySystem logic (code).

/** relevant code snippet - you can see forcecreatelocal is the one missing */
val createdBySelf = createEvent && ((logAction == "create") || (logAction == "newusers"))
val createdBySystem = createEvent && (logAction == "autocreate")
val createdByPeer = createEvent && ((logAction == "create2") || (logAction == "byemail"))
-- example code run on the enwiki replica (SQL)
SELECT log_action, COUNT(1) FROM logging WHERE log_type = 'newusers' GROUP BY log_action;

+------------------+----------+
| log_action       | count(1) |
+------------------+----------+
| autocreate       | 14670976 |
| byemail          |   178671 |
| create           | 36116927 |
| create2          |   282215 |
| forcecreatelocal |      411 |
| newusers         |   841920 |
+------------------+----------+

Event Timeline

Isaac renamed this task from [Mediawiki History] Capture ... to [Mediawiki History] Fix missing event_user_is_created_by values.Jul 30 2026, 4:22 PM

Thanks @Isaac . This is probably input also to T427817: Epic: MediaWiki User DomainEvents. We should capture these details in the relevant DomainEvents in MW, so we can emit them in events.