From: Timo Tijhof Date: Wed, 12 Sep 2018 17:33:34 +0000 (+0100) Subject: user: Allow "CAS update failed" exceptions to be normalised X-Git-Tag: 1.34.0-rc.0~4037^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22lang_raccourcis%22%2C%22module=%24nom_module%22%29%20.%20%22?a=commitdiff_plain;h=65f714e1e679127c4d38a40e7b23da8cee2195d6;p=lhc%2Fweb%2Fwiklou.git user: Allow "CAS update failed" exceptions to be normalised 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 --- diff --git a/includes/user/User.php b/includes/user/User.php index 7bebe80715..d61c29d6b4 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -27,6 +27,7 @@ use MediaWiki\Auth\AuthManager; 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; @@ -4208,9 +4209,12 @@ class User implements IDBAccessObject, UserIdentity { $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." ); }