-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I am doing the following:
$oldSpace = Space::newFromConstant( $id );
$newSpace = clone $oldSpace;
$newSpace->setName( 'New name Foo' );
$newSpace->setDescription( "Foo Bar Baz" );
$WssNamespaceRepository->updateSpace( $oldSpace, $newSpace, true );
And I (sometimes) get this error:
InvalidArgumentException: UserGroupManager::removeUserFromGroup() needs a positive user ID. Perhaps removeUserFromGroup() was called before the user was added to the database. in /var/www/html/includes/user/UserGroupManager.php:964
Stack trace:
#0 /var/www/html/extensions/WSSpaces/src/NamespaceRepository.php(469): MediaWiki\User\UserGroupManager->removeUserFromGroup()
#1 /var/www/html/extensions/WSSpaces/src/NamespaceRepository.php(371): WSS\NamespaceRepository->removeUserFromUserGroup()
#2 /var/www/html/extensions/WSSpaces/src/NamespaceRepository.php(282): WSS\NamespaceRepository->updateSpaceAdministrators()
Did some debugging, and the problem is the following:
Some user ids in the wss_namespace_admins table do not correspond to users in the user table; These users have probably been deleted in some way.
Preferably, the wss_namespace_admins table has a FOREIGN KEY constraint on user ID with a ON DELETE CASCADE, such that these things do not happen.
As a start, the users should not be updated if they do not exist.
MW version: 1.39.5
PHP version: 8.0.30
Metadata
Metadata
Assignees
Labels
No labels