Page MenuHomePhabricator

Write to afl_ip_hex in AbuseFilter
Closed, ResolvedPublic1 Estimated Story Points

Description

Summary

The abuse_filter_log table has an afl_ip_hex column. We should write to it to migrate from using afl_ip.

Background & Technical details

  • T391322: Special:AbuseLog: Support search by IP and IP range when temporary accounts are enabled requests that it be possible to search AbuseFilter log entries performed by temporary accounts by the IP address used to perform the action
  • To achieve this we need to be able to search by the IP address column in the abuse_filter_log table
    • This involves writing to the new afl_ip_hex column for new entries, which will be the focus of this task. Existing entries will be migrated in another task
    • Additionally, we will need to expire the value from afl_ip_hex in the same way as afl_ip to avoid storing the IPs for too long.

Acceptance criteria

  • The afl_ip_hex column is written to when creating new abuse_filter_log rows
  • The afl_ip_hex column is purged in the same way as afl_ip

Event Timeline

Change #1164249 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/AbuseFilter@master] Write to afl_ip_hex

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

Change #1164249 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Write to afl_ip_hex

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

I see values being written to afl_ip_hex and I briefly checked that they matched the IP in afl_ip. When I run the PurgeOldLogData.php maintenance script it removes values from afl_ip_hex.

@Dreamy_Jazz One thing I notice is that when $wgAbuseFilterLogIP = false, we always write 0 to the afl_ip_hex. This will then get updated to an empty string when running PurgeOldLogData.php. Would it be more efficient to write an empty string in the first place, just to save having to do an update later?

Test environment: local docker Abuse Filter – (a8a00df) 14:26, 7 July 2025.

@Dreamy_Jazz One thing I notice is that when $wgAbuseFilterLogIP = false, we always write 0 to the afl_ip_hex. This will then get updated to an empty string when running PurgeOldLogData.php. Would it be more efficient to write an empty string in the first place, just to save having to do an update later?

We should be writing an empty string in this case. Let me look into this.

Change #1167246 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/AbuseFilter@master] Write empty string to afl_ip_hex when wgAbuseFilterLogIP is false

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

Change #1167246 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Write empty string to afl_ip_hex when wgAbuseFilterLogIP is false

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

Dreamy_Jazz closed this task as Resolved.EditedJul 16 2025, 12:20 PM

This change did get some QA already, so moving to done.