Page MenuHomePhabricator
Paste P7479

Allow NameTabelStores to be reset in sync with their associated database tables in unit tests.

Authored by daniel on Aug 23 2018, 4:14 PM.
The purpose of NameTabelStores is to provide aggressive caching for certain database tables. These caches need to be reset when the corresponding table is reset between unit tests. NameTableStore has a reloadMap() method for that purpose, but there is no easy way to get hold of all the NameTabelStore instances. In particular, RevisionStoreFactory presently constructs NameTableStores for content_models and slot_roles that are untracked, it does not use the instances provided MediaWikiServices::getContentModelStore() and MediaWikiServices::getSlotRoleStore(), in order to be able to cosntruct NameTabelStore for an arbitrary target database.
We needs to either:
* reset ALL services between tests
* or track all NameTabelStore and reset them when the tables get reset
* or at least make RevisionStoreFactory use the same instances we return from getContentModelStore, getSlotRoleStore, etc. A NameTabelStoreFactory may be used to achieve this.
Note: there are several mechanisms that may trigger a table to be re-set:
# MediaWikiTestCase::tablesUsed
# MediaWikiTestCase::truncateTable
# MediaWikiTestCase::getSchemaOverrides

Event Timeline

daniel created this paste.Aug 23 2018, 4:14 PM

uh, this was supposed to be a ticket :) See T202641.