Page MenuHomePhabricator

Database calls inside onUserGetRights hook cause tests to fail
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Create an extension
  • Have this extension use the onUserGetRights hook
  • Inside onUserGetRights make any database call

What happens?:

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/GroupWhitelist/+/1033135

Core mediawiki tests fail with:

20:36:07 1) DumpableObjectsTest::testUser
20:36:07 RuntimeException: Database backend disabled
20:36:07 
20:36:07 /workspace/src/includes/libs/rdbms/loadbalancer/LoadBalancerDisabled.php:72
20:36:07 /workspace/src/includes/cache/LinkCache.php:436
20:36:07 /workspace/src/includes/libs/objectcache/wancache/WANObjectCache.php:1726
20:36:07 /workspace/src/includes/libs/objectcache/wancache/WANObjectCache.php:1556
20:36:07 /workspace/src/includes/cache/LinkCache.php:444
20:36:07 /workspace/src/includes/cache/LinkCache.php:493
20:36:07 /workspace/src/includes/page/PageStore.php:190
20:36:07 /workspace/src/includes/page/PageStore.php:156
20:36:07 /workspace/src/includes/page/PageStore.php:328
20:36:07 /workspace/src/includes/title/Title.php:3747
20:36:07 /workspace/src/includes/title/Title.php:2599
20:36:07 /workspace/src/includes/title/Title.php:3147
20:36:07 /workspace/src/extensions/GroupWhitelist/includes/GroupWhitelist.php:86
20:36:07 /workspace/src/extensions/GroupWhitelist/includes/GroupWhitelist.php:131
20:36:07 /workspace/src/extensions/GroupWhitelist/includes/GroupWhitelist.php:61
20:36:07 /workspace/src/extensions/GroupWhitelist/includes/GroupWhitelist.php:42
20:36:07 /workspace/src/extensions/GroupWhitelist/includes/Hooks.php:97
20:36:07 /workspace/src/includes/HookContainer/HookContainer.php:159
20:36:07 /workspace/src/includes/HookContainer/HookRunner.php:4258
20:36:07 /workspace/src/includes/Permissions/PermissionManager.php:1586
20:36:07 /workspace/src/includes/Permissions/PermissionManager.php:1534
20:36:07 /workspace/src/includes/Permissions/UserAuthority.php:285
20:36:07 /workspace/src/includes/Permissions/UserAuthority.php:144
20:36:07 /workspace/src/includes/user/User.php:2190
20:36:07 /workspace/src/tests/phpunit/structure/DumpableObjectsTest.php:29
20:36:07 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:106

What should have happened instead?:

Tests should likely pass

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Whatever WMF Jenkins is running

Other information (browser name/version, screenshots, etc.):

My best guess is that this started failing in 2a0de02aab.

Event Timeline

I think DumpableObjectsTest should be added to the Database group, because hooks can trigger DB access and the test does nothing to prevent it. Alternatively, the test could explicitly mock DB-related services, but it seems hard to do it correctly without making the test more brittle.

Shall I make a PR to return DumpableObjectsTest to the Database group, then?

Change #1082876 had a related patch set uploaded (by Labster; author: Labster):

[mediawiki/core@master] Add DumpableObjectsTest to the database test group

https://gerrit.wikimedia.org/r/1082876

Change #1082876 merged by jenkins-bot:

[mediawiki/core@master] Add DumpableObjectsTest to the database test group

https://gerrit.wikimedia.org/r/1082876

Paladox assigned this task to labster.

Change #1088578 had a related patch set uploaded (by Paladox; author: Labster):

[mediawiki/core@REL1_42] Add DumpableObjectsTest to the database test group

https://gerrit.wikimedia.org/r/1088578

Change #1088579 had a related patch set uploaded (by Paladox; author: Labster):

[mediawiki/core@REL1_43] Add DumpableObjectsTest to the database test group

https://gerrit.wikimedia.org/r/1088579

Change #1088578 merged by jenkins-bot:

[mediawiki/core@REL1_42] Add DumpableObjectsTest to the database test group

https://gerrit.wikimedia.org/r/1088578

Change #1088579 merged by jenkins-bot:

[mediawiki/core@REL1_43] Add DumpableObjectsTest to the database test group

https://gerrit.wikimedia.org/r/1088579