From 9f60798508052a90b5c20c35d4af1450c5e7b17e Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 9 Oct 2018 15:41:25 -0400 Subject: [PATCH] ChangeTagsTest: Mark tables as "used" to avoid ID reuse If ChangeTags::updateTags() isn't passed all three of $rc_id, $rev_id, and $log_id, it attempts to look up proper values from the subset that is passed. Some of the tests in ChangeTagsTest blindly use certain IDs, expecting them to either not exist in the relevant tables or at least to be sane (e.g. the same log_id isn't used on multiple rc_id rows). Depending on the exact behavior of previous tests, this expectation may not hold. The simple fix is to just mark the relevant tables as "used" by ChangeTagsTest so MediaWikiTestCase will truncate them. Change-Id: Ie60092b8a6e50f6f8a5cfdaaf4cac8ddb4fc6f53 --- tests/phpunit/includes/changetags/ChangeTagsTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/phpunit/includes/changetags/ChangeTagsTest.php b/tests/phpunit/includes/changetags/ChangeTagsTest.php index 64c3224ff7..f20756425f 100644 --- a/tests/phpunit/includes/changetags/ChangeTagsTest.php +++ b/tests/phpunit/includes/changetags/ChangeTagsTest.php @@ -15,6 +15,14 @@ class ChangeTagsTest extends MediaWikiTestCase { $this->tablesUsed[] = 'change_tag_def'; $this->tablesUsed[] = 'tag_summary'; $this->tablesUsed[] = 'valid_tag'; + + // Truncate these to avoid the supposed-to-be-unused IDs in tests here turning + // out to be used, leading ChangeTags::updateTags() to pick up bogus rc_id, + // log_id, or rev_id values and run into unique constraint violations. + $this->tablesUsed[] = 'recentchanges'; + $this->tablesUsed[] = 'logging'; + $this->tablesUsed[] = 'revision'; + $this->tablesUsed[] = 'archive'; } // TODO only modifyDisplayQuery and getSoftwareTags are tested, nothing else is -- 2.20.1