Take the user_id variable out of the exception message.
To compensate and still allow one to correlate patterns relating
to a specific user (e.g. a bot), add a warning message that
still contains the variable via context. This way that warning
will also be normalised/grouped, but with the extra context.
This is separate because exceptions do not currently support
context placeholders.
Bug: T202149
Change-Id: Ic0c25f66f23fdc65821da12f949c6224bc03f9b3
use MediaWiki\Auth\AuthenticationResponse;
use MediaWiki\Auth\AuthenticationRequest;
use MediaWiki\User\UserIdentity;
use MediaWiki\Auth\AuthenticationResponse;
use MediaWiki\Auth\AuthenticationRequest;
use MediaWiki\User\UserIdentity;
+use MediaWiki\Logger\LoggerFactory;
use Wikimedia\IPSet;
use Wikimedia\ScopedCallback;
use Wikimedia\Rdbms\Database;
use Wikimedia\IPSet;
use Wikimedia\ScopedCallback;
use Wikimedia\Rdbms\Database;
$this->clearSharedCache( 'refresh' );
// User was changed in the meantime or loaded with stale data
$from = ( $this->queryFlagsUsed & self::READ_LATEST ) ? 'master' : 'replica';
$this->clearSharedCache( 'refresh' );
// User was changed in the meantime or loaded with stale data
$from = ( $this->queryFlagsUsed & self::READ_LATEST ) ? 'master' : 'replica';
- throw new MWException(
- "CAS update failed on user_touched for user ID '{$this->mId}' (read from $from);" .
- " the version of the user to be saved is older than the current version."
+ LoggerFactory::getInstance( 'preferences' )->warning(
+ "CAS update failed on user_touched for user ID '{user_id}' ({db_flag} read)",
+ [ 'user_id' => $this->mId, 'db_flag' => $from ]
+ );
+ throw new MWException( "CAS update failed on user_touched. " .
+ "The version of the user to be saved is older than the current version."