Lucas_Werkmeister_WMDE added a subscriber: Daimona.
Lucas_Werkmeister_WMDE added a comment.


  The tests mostly work in secondary CI, and I think I managed to fix all of 
them, but one of the fixes is in core. `SpecialSetSiteLinkTest` has two tests 
that end up creating temporary users, and it also has a `addDBDataOnce()` 
method that makes some test edits, which involves creating (non-temporary) test 
users. This means that the `user` table ends up in `$dbDataOnceTables`, and is 
not cleared between tests, whereas `user_autocreate_serial` is cleared between 
tests; as a result, the second test tries to create a temporary user with the 
same name as the first test, and fails because the user already exists in the 
non-cleared `user` table. Suggested fix:
  
    diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php 
b/tests/phpunit/MediaWikiIntegrationTestCase.php
    index 4448f3ebc8..71b15fca92 100644
    --- a/tests/phpunit/MediaWikiIntegrationTestCase.php
    +++ b/tests/phpunit/MediaWikiIntegrationTestCase.php
    @@ -689,6 +689,15 @@ private function maybeSetupDB(): void {
                        $this->addDBDataOnce();
                        static::$dbDataOnceTables = 
ChangedTablesTracker::getTables( $this->db->getDomainID() );
                        ChangedTablesTracker::stopTracking();
    +                   if (
    +                           in_array( 'user', static::$dbDataOnceTables, 
true )
    +                           && !in_array( 'user_autocreate_serial', 
static::$dbDataOnceTables, true )
    +                   ) {
    +                           // if the user table will not be cleared 
between tests,
    +                           // also preserve the temp user counter between 
tests,
    +                           // otherwise later tests will try to recreate 
temp users that already exist and fail
    +                           static::$dbDataOnceTables[] = 
'user_autocreate_serial';
    +                   }
                }
     
                ChangedTablesTracker::startTracking();
  
  Which is a bit of a shame, because @Daimona removed a bunch of inter-table 
dependencies like this when introducing ChangedTablesTracker 
<https://gerrit.wikimedia.org/r/c/mediawiki/core/+/946538> (it used to be 
something like “if `slot_roles` is cleared then also clear `ip_changes`”, 
yuck), and now we’d be reintroducing something similar again and go behind 
`ChangedTablesTracker`’s back, so to speak :/ but I can’t really think of a 
better solution. Any thoughts?

TASK DETAIL
  https://phabricator.wikimedia.org/T353961

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Lucas_Werkmeister_WMDE
Cc: Daimona, kostajh, Lucas_Werkmeister_WMDE, Aklapper, Michael, 
Danny_Benjafield_WMDE, Astuthiodit_1, karapayneWMDE, Invadibot, maantietaja, 
ItamarWMDE, Akuckartz, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, 
KimKelting, LawExplorer, JJMC89, _jensen, rosalieper, Scott_WUaS, 
Wikidata-bugs, aude, Mbch331, Ltrlg
_______________________________________________
Wikidata-bugs mailing list -- wikidata-bugs@lists.wikimedia.org
To unsubscribe send an email to wikidata-bugs-le...@lists.wikimedia.org

Reply via email to