Page MenuHomePhabricator

Fatal exception of type "TypeError" from TranslatableBundleLogFormatter.php
Closed, ResolvedPublicPRODUCTION ERROR

Description

Steps to replicate the issue (include links if applicable):

What happens?:

A "[f134e61b-48ea-41de-a983-6f70b5a7afcb] 2022-08-19 10:44:46: Fatal exception of type "TypeError"" appears

[{reqId}] {exception_url}   TypeError: Argument 1 passed to MediaWiki\CommentFormatter\CommentFormatter::formatBlock() must be of the type string, boolean given, called in /srv/mediawiki/php-1.39.0-wmf.25/extensions/Translate/src/MessageGroupProcessing/Tr

from /srv/mediawiki/php-1.39.0-wmf.25/includes/CommentFormatter/CommentFormatter.php(71)
#0 /srv/mediawiki/php-1.39.0-wmf.25/extensions/Translate/src/MessageGroupProcessing/TranslatableBundleLogFormatter.php(80): MediaWiki\CommentFormatter\CommentFormatter->formatBlock(boolean)
#1 /srv/mediawiki/php-1.39.0-wmf.25/includes/logging/LogEventsList.php(394): MediaWiki\Extension\Translate\MessageGroupProcessing\TranslatableBundleLogFormatter->getComment()
#2 /srv/mediawiki/php-1.39.0-wmf.25/includes/logging/LogPager.php(450): LogEventsList->logLine(stdClass)
#3 /srv/mediawiki/php-1.39.0-wmf.25/includes/pager/ReverseChronologicalPager.php(115): LogPager->formatRow(stdClass)
#4 /srv/mediawiki/php-1.39.0-wmf.25/includes/pager/IndexPager.php(634): ReverseChronologicalPager->getRow(stdClass)
#5 /srv/mediawiki/php-1.39.0-wmf.25/includes/specials/SpecialLog.php(294): IndexPager->getBody()
#6 /srv/mediawiki/php-1.39.0-wmf.25/includes/specials/SpecialLog.php(176): SpecialLog->show(FormOptions, array)
#7 /srv/mediawiki/php-1.39.0-wmf.25/includes/specialpage/SpecialPage.php(690): SpecialLog->execute(NULL)
#8 /srv/mediawiki/php-1.39.0-wmf.25/includes/specialpage/SpecialPageFactory.php(1426): SpecialPage->run(NULL)
#9 /srv/mediawiki/php-1.39.0-wmf.25/includes/MediaWiki.php(316): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#10 /srv/mediawiki/php-1.39.0-wmf.25/includes/MediaWiki.php(905): MediaWiki->performRequest()
#11 /srv/mediawiki/php-1.39.0-wmf.25/includes/MediaWiki.php(562): MediaWiki->main()
#12 /srv/mediawiki/php-1.39.0-wmf.25/index.php(50): MediaWiki->run()
#13 /srv/mediawiki/php-1.39.0-wmf.25/index.php(46): wfIndexMain()
#14 /srv/mediawiki/w/index.php(3): require(string)
#15 {main}

What should have happened instead?:

I get a list of logs action I performed.

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Note that this doesn't seem to happen if I check my volunteer account's logs instead (that's just Elitre).

Details

MediaWiki Version
1.39.0-wmf.25
Request URL
https://meta.wikimedia.org/wiki/Special:Log?type=&user=Elitre+%28WMF%29&page=&wpdate=&tagfilter=&wpfilters%5B%5D=newusers

Event Timeline

Urbanecm changed the subtype of this task from "Bug Report" to "Production Error".
Urbanecm set Request URL to https://meta.wikimedia.org/wiki/Special:Log?type=&user=Elitre+%28WMF%29&page=&wpdate=&tagfilter=&wpfilters%5B%5D=newusers.Aug 19 2022, 10:52 AM
Krinkle renamed this task from Fatal exception of type "TypeError" to Fatal exception of type "TypeError" from TranslatableBundleLogFormatter.php.Aug 19 2022, 11:00 AM
Zabe renamed this task from Fatal exception of type "TypeError" from TranslatableBundleLogFormatter.php to TypeError: Argument 1 passed to MediaWiki\CommentFormatter\CommentFormatter::formatBlock() must be of the type string, boolean given.Aug 19 2022, 11:01 AM
Zabe renamed this task from TypeError: Argument 1 passed to MediaWiki\CommentFormatter\CommentFormatter::formatBlock() must be of the type string, boolean given to Fatal exception of type "TypeError" from TranslatableBundleLogFormatter.php.
Zabe set Release Version to 1.39.0-wmf.25.

An example problematic log entry is log_id=37400435: the error can be reproduced with https://meta.wikimedia.org/w/index.php?title=Special%3ALog&logid=37400435 as well. Checking this log ID tells us:

MariaDB [metawiki_p]> select * from logging where log_id=37400435\G
*************************** 1. row ***************************
        log_id: 37400435
      log_type: pagetranslation
    log_action: prioritylanguages
 log_timestamp: 20200722155831
     log_actor: 15390
 log_namespace: 0
     log_title: Universal_Code_of_Conduct/Message_to_small_and_medium_sized_wikis
log_comment_id: 2
    log_params: a:3:{s:9:"languages";b:0;s:5:"force";b:0;s:6:"reason";b:0;}
   log_deleted: 0
      log_page: 11085307
1 row in set (0.003 sec)

MariaDB [metawiki_p]>

Unserialized log_params for this log entry are:

php > var_dump(unserialize('a:3:{s:9:"languages";b:0;s:5:"force";b:0;s:6:"reason";b:0;}'));
array(3) {
  ["languages"]=>
  bool(false)
  ["force"]=>
  bool(false)
  ["reason"]=>
  bool(false)
}
php >

extensions/Translate/src/MessageGroupProcessing/TranslatableBundleLogFormatter.php(80) tries to pass reason from this array to $commentFormatter->formatBlock, but that method can only accept strings, not booleans, hence the fatal. An easy fix would be to add a string cast to that code.

However, it looks like some entries have an empty string in reason field in log_params, while others have a false there. Not sure why. log_id=48885959 is an example of a valid metawiki entry.

Direct cause of this issue seems to be https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Translate/+/816354 (cc @abi_ and @Nikerabbit).

Krinkle moved this task from Untriaged to Aug 2022 on the Wikimedia-production-error board.
Krinkle subscribed.

This should have been discovered and blocked the train, ref T314186. It is a fatal error that makes administrator logs inaccessible on several wikis including Wikidata, Meta-Wiki, mediawiki.org and others (see wmgUseTranslate in wmf-config).

These URLs are direct to the faulty entries, however they can (as per the original task description case) also break random navigations from e.g. a user account or page history whenver one of these would be in the user's or page's history. I imagine this could is affecting community's ability to audit and understand account and page history, e.g. fight abuse or know what is happening at any given moment.

Change 824711 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/Translate@master] TranslatableBundleLogFormatter: Cast reason to string before passing it

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

Direct cause of this issue seems to be https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Translate/+/816354

Tbh, I don't really understand how this patch could make a difference here. Before it, it was calling Linker::formatComment, but that is internally calling CommentFormatter::formatBlock, so it should have fataled before that change.

Direct cause of this issue seems to be https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Translate/+/816354

Tbh, I don't really understand how this patch could make a difference here. Before it, it was calling Linker::formatComment, but that is internally calling CommentFormatter::formatBlock, so it should have fataled before that change.

+ declare( strict_types = 1 );

Direct cause of this issue seems to be https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Translate/+/816354

Tbh, I don't really understand how this patch could make a difference here. Before it, it was calling Linker::formatComment, but that is internally calling CommentFormatter::formatBlock, so it should have fataled before that change.

+ declare( strict_types = 1 );

Thanks, apparently I'm blind.

Change 824711 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] TranslatableBundleLogFormatter: Cast reason to string before passing it

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

Change 824442 had a related patch set uploaded (by Jforrester; author: Urbanecm):

[mediawiki/extensions/Translate@wmf/1.39.0-wmf.25] TranslatableBundleLogFormatter: Cast reason to string before passing it

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

This is fixed and deployed in production (1.39.0-wmf.26), isn’t it?

abi_ assigned this task to Urbanecm.

This is fixed and deployed in production (1.39.0-wmf.26), isn’t it?

Yes, this has been deployed by the train and the URL in question now loads.

Change 824442 abandoned by Jforrester:

[mediawiki/extensions/Translate@wmf/1.39.0-wmf.25] TranslatableBundleLogFormatter: Cast reason to string before passing it

Reason:

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