Page MenuHomePhabricator

Several tests in Wikibase CI failing with “Invalid argument supplied for foreach()” in PermissionManager
Closed, ResolvedPublic

Description

Example change: https://gerrit.wikimedia.org/r/536137
Example log: https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php72-docker/19112/console

13:44:29 Invalid argument supplied for foreach()
13:44:29 
13:44:29 /workspace/src/includes/Permissions/PermissionManager.php:1373
13:44:29 /workspace/src/includes/Permissions/PermissionManager.php:1271
13:44:29 /workspace/src/includes/Permissions/PermissionManager.php:1216
13:44:29 /workspace/src/includes/specialpage/SpecialPage.php:297
13:44:29 /workspace/src/includes/specialpage/SpecialPage.php:316
13:44:29 /workspace/src/includes/specialpage/SpecialPage.php:623
13:44:29 /workspace/src/extensions/WikibaseLexeme/src/MediaWiki/Specials/SpecialNewLexeme.php:94
13:44:29 /workspace/src/tests/phpunit/includes/specials/SpecialPageExecutor.php:108
13:44:29 /workspace/src/tests/phpunit/includes/specials/SpecialPageExecutor.php:36
13:44:29 /workspace/src/tests/phpunit/includes/specials/SpecialPageTestBase.php:70
13:44:29 /workspace/src/extensions/WikibaseLexeme/tests/phpunit/mediawiki/Specials/SpecialNewLexemeTest.php:124
13:44:29 /workspace/src/tests/phpunit/MediaWikiIntegrationTestCase.php:454
13:44:29 /workspace/src/maintenance/doMaintenance.php:99

Happens three times, all in SpecialNewLexemeTest (L104, L113, L124).

I suspect it’s due to I2341e6f1d1 (part of T220191).

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 12 2019, 2:21 PM

Call chain:

PermissionManager.php
$this->usersRights[ $rightsCacheKey ] = $this->getGroupPermissions(
	$user->getEffectiveGroups()
);
PermissionManager.php
public function getGroupPermissions( $groups ) {
	$rights = [];
	// grant every granted permission first
	foreach ( $groups as $group ) {

I guess it’s because this method of SpecialNewLexemeTest doesn’t mock the user’s groups:

	private function getMockBlockedUser( $block ) {
		$user = $this->getMockBuilder( \User::class )
			->disableOriginalConstructor()
			->getMock();
		$user->method( 'getBlock' )
			->willReturn( $block );
		$user->method( 'isAllowed' )
			->willReturn( true );

		return $user;
	}

(I wonder if there’s a reason why this doesn’t use $this->getTestUser()?)

Change 536212 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Fix SpecialNewLexemeTest after permissions update

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

Change 536212 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Fix SpecialNewLexemeTest after permissions update

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

Lucas_Werkmeister_WMDE closed this task as Resolved.Sep 13 2019, 10:04 AM

Some other changes were successfully merged, so it looks like this was fixed successfully :)