Following up from T245280, it'd be useful if we could try and prevent some of these with PHPCS rules
The simplest case, is the existence of things like {host}, {type}, {ip} in logging strings points to this being wrong
From LogstashFormatter:
/** @var array Keys which should not be used in log context */ protected $reservedKeys = [ // from LogstashFormatter 'message', 'channel', 'level', 'type', // from WebProcessor 'url', 'ip', 'http_method', 'server', 'referrer', // from WikiProcessor 'host', 'wiki', 'reqId', 'mwversion', // from config magic 'normalized_message', ];
For example from MediaWiki-extensions-LoginNotify
$this->log->info( 'Sending a {type} notification to {user}', [ 'function' => __METHOD__, 'type' => $type, 'user' => $user->getName(), ] );
It's obvious from the string (based on the list above) that {type} is wrong, and should be easier to detect
In a case like the below (made up, but there are cases where log params are in the array, but not in the string), it's harder... But if we were looking for functions named info, debug etc
$this->log->info( 'Sending a notification to {user}', [ 'function' => __METHOD__, 'type' => $type, 'user' => $user->getName(), ] );
Based on the reserved word list, as of writing, a regex catching \{(message|channel|level|type|url|ip|http_method|server|referrer|host|wiki|reqId|mwversion|normalized_message)\} in a string would probably help
I note this isn't probably auto fixable, but should be trivially doable by a human...