What is the problem?
If you are looking up IPInfo for a log entry where the performer and target are IPv6 address (e.g. an anonymous user creates a User page User:$ipv6_address), you can get duplicate log entries.
For example, user with IP address 2001:8b0:7acf:5d4e:2e09:4dff:fe00:bd2 created the page User:2001:8b0:7acf:5d4e:2e09:4dff:fe00:bd2. In the logs, I see:
[DBQuery] Wikimedia\Rdbms\Database::selectRow [0.004s] unknown: SELECT * FROM logging WHERE log_type = 'ipinfo' AND log_action = 'view_popup' AND log_actor = 1 AND log_namespace = 2 AND log_title = '2001:8b0:7acf:5d4e:2e09:4dff:fe00:bd2' AND (log_timestamp > '20220412091032') AND (log_params LIKE '%ipinfo-view-full%' ESCAPE '`' ) LIMIT 1
[DBQuery] ManualLogEntry::insert [0s] unknown: INSERT INTO logging (log_type,log_action,log_timestamp,log_actor,log_namespace,log_title,log_page,log_params,log_comment_id) VALUES ('ipinfo','view_popup','20220413091032',1,2,'2001:8b0:7acf:5d4e:2e09:4dff:fe00:bd2',0,'a:1:{s:8:"4::level";s:16:"ipinfo-view-full";}',1)
...
[DBQuery] Wikimedia\Rdbms\Database::selectRow [0s] unknown: SELECT * FROM logging WHERE log_type = 'ipinfo' AND log_action = 'view_popup' AND log_actor = 1 AND log_namespace = 2 AND log_title = '2001:8B0:7ACF:5D4E:2E09:4DFF:FE00:BD2' AND (log_timestamp > '20220412091032') AND (log_params LIKE '%ipinfo-view-full%' ESCAPE '`' ) LIMIT 1
[DBQuery] ManualLogEntry::insert [0s] unknown: INSERT INTO logging (log_type,log_action,log_timestamp,log_actor,log_namespace,log_title,log_page,log_params,log_comment_id) VALUES ('ipinfo','view_popup','20220413091032',1,2,'2001:8B0:7ACF:5D4E:2E09:4DFF:FE00:BD2',0,'a:1:{s:8:"4::level";s:16:"ipinfo-view-full";}',1)Notice that in the first is looking up '2001:8b0:7acf:5d4e:2e09:4dff:fe00:bd2' and the second is looking up '2001:8B0:7ACF:5D4E:2E09:4DFF:FE00:BD2'.
Steps to reproduce problem
- From an IPv6 address, go to Special:MyTalk and create the page
- The IPv6 address you are editing from must be the same as the title of the page.
- You must be creating the page for the first time.
- If you don't have an IPv6 address or your local environment does not support it, you can use this script and run something like python3 edit_from_ip.py -u http://localhost:8080/w/api.php -i 2001:df3:9a80::3 -t 2001:df3:9a80::3
- Login as someone with IPInfo access and go to Special:Log
- There should be an entry for the page you created in step 1
- Open the IPInfo popup for that log entry
- Look at the IPInfo log (Special:Log?type=ipinfo)
Expected behavior: There is just one entry for the IP you edited from in step 1.
Observed behavior: There are two entries.
Environment
Wiki(s): local docker IP Info 0.0.0 (cc08cea) 18:42, 12 April 2022.
Acceptance criteria
We can no longer produce the bug using those steps
Notes
The function IPUtils::sanitizeIP should help here