Page MenuHomePhabricator

GlobalBlockLogFormatter does not handle pre-2010 GlobalBlocking logs correctly, causing an InvalidArgumentException and missing log parameter data
Closed, ResolvedPublic2 Estimated Story PointsPRODUCTION ERROR

Description

Error
message
Invalid username: Contributions/67.159.44.24
trace
from /srv/mediawiki/php-1.42.0-wmf.26/extensions/CentralAuth/includes/User/CentralAuthUser.php(254)
#0 /srv/mediawiki/php-1.42.0-wmf.26/extensions/CentralAuth/includes/User/CentralAuthUser.php(231): MediaWiki\Extension\CentralAuth\User\CentralAuthUser::getInstanceByName(string)
#1 /srv/mediawiki/php-1.42.0-wmf.26/extensions/GlobalBlocking/includes/GlobalBlockLogFormatter.php(212): MediaWiki\Extension\CentralAuth\User\CentralAuthUser::getInstance(MediaWiki\User\UserIdentityValue)
#2 /srv/mediawiki/php-1.42.0-wmf.26/extensions/GlobalBlocking/includes/GlobalBlockLogFormatter.php(133): MediaWiki\Extension\GlobalBlocking\GlobalBlockLogFormatter->checkAuthorityCanSeeUser(MediaWiki\User\UserIdentityValue)
#3 /srv/mediawiki/php-1.42.0-wmf.26/includes/logging/LogFormatter.php(562): MediaWiki\Extension\GlobalBlocking\GlobalBlockLogFormatter->getMessageParameters()
#4 /srv/mediawiki/php-1.42.0-wmf.26/includes/logging/LogFormatter.php(537): LogFormatter->getActionMessage()
#5 /srv/mediawiki/php-1.42.0-wmf.26/includes/logging/LogEventsList.php(332): LogFormatter->getActionText()
#6 /srv/mediawiki/php-1.42.0-wmf.26/includes/logging/LogPager.php(452): LogEventsList->logLine(stdClass)
#7 /srv/mediawiki/php-1.42.0-wmf.26/includes/pager/ReverseChronologicalPager.php(134): MediaWiki\Pager\LogPager->formatRow(stdClass)
#8 /srv/mediawiki/php-1.42.0-wmf.26/includes/pager/IndexPager.php(594): MediaWiki\Pager\ReverseChronologicalPager->getRow(stdClass)
#9 /srv/mediawiki/php-1.42.0-wmf.26/includes/specials/SpecialLog.php(313): MediaWiki\Pager\IndexPager->getBody()
#10 /srv/mediawiki/php-1.42.0-wmf.26/includes/specials/SpecialLog.php(192): MediaWiki\Specials\SpecialLog->show(MediaWiki\Html\FormOptions, array)
#11 /srv/mediawiki/php-1.42.0-wmf.26/includes/specialpage/SpecialPage.php(718): MediaWiki\Specials\SpecialLog->execute(NULL)
#12 /srv/mediawiki/php-1.42.0-wmf.26/includes/specialpage/SpecialPageFactory.php(1669): MediaWiki\SpecialPage\SpecialPage->run(NULL)
#13 /srv/mediawiki/php-1.42.0-wmf.26/includes/actions/ActionEntryPoint.php(504): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#14 /srv/mediawiki/php-1.42.0-wmf.26/includes/actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#15 /srv/mediawiki/php-1.42.0-wmf.26/includes/MediaWikiEntryPoint.php(199): MediaWiki\Actions\ActionEntryPoint->execute()
#16 /srv/mediawiki/php-1.42.0-wmf.26/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#17 /srv/mediawiki/w/index.php(3): require(string)
#18 {main}
Impact

Causes Special:Log on commonswiki when filtered for GlobalBlocking log entries to throw an exception.

Notes

Looks to be caused rows such as:

+---------+----------+------------+----------------+---------------+----------------------------+----------------+------------+-------------+-----------+----------+
| log_id  | log_type | log_action | log_timestamp  | log_namespace | log_title                  | log_comment_id | log_params | log_deleted | log_actor | log_page |
+---------+----------+------------+----------------+---------------+----------------------------+----------------+------------+-------------+-----------+----------+
| 5038622 | gblblock | whitelist  | 20080827225222 |            -1 | Contributions/67.159.44.24 |       91105968 |            |           0 |    455357 |     NULL |
+---------+----------+------------+----------------+---------------+----------------------------+----------------+------------+-------------+-----------+----------+

Event Timeline

There are also entries on enwiki and on metawiki. On metawiki there are 755 of these entries.

Dreamy_Jazz renamed this task from Invalid username: Contributions/67.159.44.24 to Target of old GlobalBlocking log entries is the contributions page of the IP target, causing a InvalidArgumentException when CentralAuth is installed.Tue, Apr 16, 5:12 PM

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

[mediawiki/extensions/GlobalBlocking@master] Handle gblblock with their target as Special:Contributions

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

Furthermore, some log entries pre-2010 have flags for the gblock type. For example:

+--------+----------+------------+----------------+---------------+---------------------------------+----------------+---------------------------+-------------+-----------+----------+
| log_id | log_type | log_action | log_timestamp  | log_namespace | log_title                       | log_comment_id | log_params                | log_deleted | log_actor | log_page |
+--------+----------+------------+----------------+---------------+---------------------------------+----------------+---------------------------+-------------+-----------+----------+
| 183748 | gblblock | gblock     | 20080821202044 |            -1 | Contributions/151.9.110.20      |        3593591 | 10 minutes
anon-only      |           0 |       696 |     NULL |
+--------+----------+------------+----------------+---------------+---------------------------------+----------------+---------------------------+-------------+-----------+----------+

The code currently does not handle this correctly.

Dreamy_Jazz renamed this task from Target of old GlobalBlocking log entries is the contributions page of the IP target, causing a InvalidArgumentException when CentralAuth is installed to Target of old GlobalBlocking log entries is the contributions page of the IP target and have flags defined, causing InvalidArgumentException and missing log parameter data.Tue, Apr 16, 5:43 PM
Dreamy_Jazz renamed this task from Target of old GlobalBlocking log entries is the contributions page of the IP target and have flags defined, causing InvalidArgumentException and missing log parameter data to GlobalBlockLogFormatter does not handle pre-2010 GlobalBlocking logs correctly, causing an InvalidArgumentException and missing log parameter data.Tue, Apr 16, 6:12 PM

Testing notes

I tested this by modifying an existing row with log_action gblock to contain similar data to the rows above:

UPDATE logging SET log_title = 'Contributions/1.2.3.4' WHERE log_id = 3854;
UPDATE logging SET log_params = '10 minutes\nanonymous only' WHERE log_id = 3854;

Then confirmed that there was no error, and that the log line substituted the correct message for the anon-only param.

Change #1020297 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] Handle pre-2010 gblblock log entries

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

I would suggest following @Tchanders testing steps for QA but also set the log_namespace to -1 using UPDATE logging SET log_namespace = -1 WHERE log_id = 3854;

This means that this ticket can only be QA'd on a local wiki. I've checked the betawikis and it seems that no log was made for the GlobalBlocking extension before 2012, so betawikis cannot be used to test this.

@Dreamy_Jazz a log_title of Contributions/71.107.128.0/18 leads to a log entry of ...globally blocked 18... where "18" is a link to "Special:Contributions/18".

@Dreamy_Jazz a log_title of Contributions/71.107.128.0/18 leads to a log entry of ...globally blocked 18... where "18" is a link to "Special:Contributions/18".

Thanks for noticing this.

That is not ideal. Better than exception, but still not fixed. I will move this out of QA while I work on a fix.

On metawiki:

wikiadmin2023@10.64.136.13(metawiki)> select count(*) from logging where log_type = 'gblblock' and log_namespace = -1 and log_title LIKE 'Contributions/%';
+----------+
| count(*) |
+----------+
|      755 |
+----------+
1 row in set (0.010 sec)

wikiadmin2023@10.64.136.13(metawiki)> select count(*) from logging where log_type = 'gblblock' and log_namespace = -1;
+----------+
| count(*) |
+----------+
|      755 |
+----------+
1 row in set (15.514 sec)

This suggests that the fix for this can be to simply remove Contributions/ from the start of the title to get the IP.

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

[mediawiki/extensions/GlobalBlocking@master] Handle pre-2010 logs for IP ranges

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

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

[mediawiki/extensions/GlobalBlocking@REL1_42] Handle pre-2010 gblblock log entries

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

Change #1020936 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@REL1_42] Handle pre-2010 gblblock log entries

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

Change #1021511 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] Handle pre-2010 logs for IP ranges

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

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

[mediawiki/extensions/GlobalBlocking@REL1_42] Handle pre-2010 logs for IP ranges

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

Thanks again @dom_walden for finding that issue. The fix for that has now been merged, so QA should be able to continue again.

Change #1020937 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@REL1_42] Handle pre-2010 logs for IP ranges

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

I have taken a sample of global blocking logs from the production metawiki database from different years and put them in my local database. I don't see any exceptions in the logs. The log lines in Special:Log look OK to me and the links work.

Test environment: local docker GlobalBlocking – (95ca8f1) 07:28, 22 April 2024.

Thanks for the thorough QA testing.