diff options
author | daniel <daniel.kinzler@wikimedia.de> | 2016-05-19 14:51:04 +0200 |
---|---|---|
committer | daniel <daniel.kinzler@wikimedia.de> | 2016-05-24 12:58:22 +0200 |
commit | 8f4587b34381926188f3d30a0f981cedd0f69235 (patch) | |
tree | 8de231600c29de95f662694be87cda597632cb90 /tests/phpunit/includes/TestUser.php | |
parent | 87fe1a21bdadec75ef25257c8bd3fcedc024114e (diff) | |
download | mediawikicore-8f4587b34381926188f3d30a0f981cedd0f69235.tar.gz mediawikicore-8f4587b34381926188f3d30a0f981cedd0f69235.zip |
Disable CAS check when saving TestUser data.
During testing, we are not worried about data loss, so we can safely
bypass the CAS check when setting up a test fixture.
This change was added to address sporadic test failures like the following:
18:03:38 1) ApiEchoMarkReadTest::testMarkReadWithList
18:03:38 MWException: CAS update failed on user_touched for user ID '2' (read from slave); the version of the user to be saved is older than the current version.
18:03:38
18:03:38 /mnt/jenkins-workspace/workspace/mediawiki-extensions-hhvm/src/includes/user/User.php:3931
18:03:38 /mnt/jenkins-workspace/workspace/mediawiki-extensions-hhvm/src/tests/phpunit/includes/TestUser.php:83
18:03:38 /mnt/jenkins-workspace/workspace/mediawiki-extensions-hhvm/src/tests/phpunit/includes/api/ApiTestCase.php:30
18:03:38 /mnt/jenkins-workspace/workspace/mediawiki-extensions-hhvm/src/extensions/Echo/tests/phpunit/api/ApiEchoMarkReadTest.php:11
18:03:38 /mnt/jenkins-workspace/workspace/mediawiki-extensions-hhvm/src/tests/phpunit/MediaWikiTestCase.php:370
Bug: T131178
Change-Id: I99b43e0db85bc2c1cd335c82971df4e95520d34b
Diffstat (limited to 'tests/phpunit/includes/TestUser.php')
-rw-r--r-- | tests/phpunit/includes/TestUser.php | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/phpunit/includes/TestUser.php b/tests/phpunit/includes/TestUser.php index 247b6e4461bc..8b8cbcd4d9b6 100644 --- a/tests/phpunit/includes/TestUser.php +++ b/tests/phpunit/includes/TestUser.php @@ -78,6 +78,12 @@ class TestUser { $this->user->removeGroup( $group ); } if ( $change ) { + // Disable CAS check before saving. The User object may have been initialized from cached + // information that may be out of whack with the database during testing. If tests were + // perfectly isolated, this would not happen. But if it does happen, let's just ignore the + // inconsistency, and just write the data we want - during testing, we are not worried + // about data loss. + $this->user->mTouched = ''; $this->user->saveSettings(); } } |