MassMessage uses the UserGetRights hook to add a temporary user right. This is fragile (user rights might be cached by that point) and we now have a helper to do that, PermissionManager::addTemporaryUserRights(), so the usage should be replaced.
Customize query in gerrit
|mediawiki/extensions/MassMessage||master||+9 -18||Use new PermissionManager::addTemporaryUserRights instead of hook|
Seems pretty straightforward to me:
$guard = $permissionManager->addTemporaryUserRights( $user, 'some-right' ); // do stuff that requires the rights ScopedCallback::consume( $guard );
Maybe there should be some generic documentation about the scoped callback pattern that can be linked from methods returning a scoped callback; there's a ScopedCallback wiki page but it's not super informative.