Use WatchlistManager in auth classes
Change-Id: Ib8d338bc0b167277f36ab6c5d45c98c35e4a9ba9
This commit is contained in:
parent
f8ed11e170
commit
ce6a4ef45e
9 changed files with 36 additions and 13 deletions
|
|
@ -179,7 +179,8 @@ return [
|
|||
$services->getReadOnlyMode(),
|
||||
$services->getUserNameUtils(),
|
||||
$services->getBlockManager(),
|
||||
$services->getBlockErrorFormatter()
|
||||
$services->getBlockErrorFormatter(),
|
||||
$services->getWatchlistManager()
|
||||
);
|
||||
$authManager->setLogger( LoggerFactory::getInstance( 'authentication' ) );
|
||||
return $authManager;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ use MediaWiki\HookContainer\HookRunner;
|
|||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Permissions\PermissionStatus;
|
||||
use MediaWiki\User\UserNameUtils;
|
||||
use MediaWiki\Watchlist\WatchlistManager;
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
|
|
@ -177,6 +178,9 @@ class AuthManager implements LoggerAwareInterface {
|
|||
/** @var BlockErrorFormatter */
|
||||
private $blockErrorFormatter;
|
||||
|
||||
/** @var WatchlistManager */
|
||||
private $watchlistManager;
|
||||
|
||||
/**
|
||||
* Get the global AuthManager
|
||||
* @return AuthManager
|
||||
|
|
@ -197,6 +201,7 @@ class AuthManager implements LoggerAwareInterface {
|
|||
* @param UserNameUtils $userNameUtils
|
||||
* @param BlockManager $blockManager
|
||||
* @param BlockErrorFormatter $blockErrorFormatter
|
||||
* @param WatchlistManager $watchlistManager
|
||||
*/
|
||||
public function __construct(
|
||||
WebRequest $request,
|
||||
|
|
@ -206,7 +211,8 @@ class AuthManager implements LoggerAwareInterface {
|
|||
ReadOnlyMode $readOnlyMode,
|
||||
UserNameUtils $userNameUtils,
|
||||
BlockManager $blockManager,
|
||||
BlockErrorFormatter $blockErrorFormatter
|
||||
BlockErrorFormatter $blockErrorFormatter,
|
||||
WatchlistManager $watchlistManager
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->config = $config;
|
||||
|
|
@ -218,6 +224,7 @@ class AuthManager implements LoggerAwareInterface {
|
|||
$this->userNameUtils = $userNameUtils;
|
||||
$this->blockManager = $blockManager;
|
||||
$this->blockErrorFormatter = $blockErrorFormatter;
|
||||
$this->watchlistManager = $watchlistManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1473,7 +1480,7 @@ class AuthManager implements LoggerAwareInterface {
|
|||
\DeferredUpdates::addUpdate( \SiteStatsUpdate::factory( [ 'users' => 1 ] ) );
|
||||
|
||||
// Watch user's userpage and talk page
|
||||
$user->addWatch( $user->getUserPage(), User::IGNORE_USER_RIGHTS );
|
||||
$this->watchlistManager->addWatchIgnoringRights( $user, $user->getUserPage() );
|
||||
|
||||
// Inform the provider
|
||||
$logSubtype = $provider->finishAccountCreation( $user, $creator, $state['primaryResponse'] );
|
||||
|
|
@ -1792,8 +1799,8 @@ class AuthManager implements LoggerAwareInterface {
|
|||
// Update user count
|
||||
\DeferredUpdates::addUpdate( \SiteStatsUpdate::factory( [ 'users' => 1 ] ) );
|
||||
// Watch user's userpage and talk page
|
||||
\DeferredUpdates::addCallableUpdate( static function () use ( $user ) {
|
||||
$user->addWatch( $user->getUserPage(), User::IGNORE_USER_RIGHTS );
|
||||
\DeferredUpdates::addCallableUpdate( function () use ( $user ) {
|
||||
$this->watchlistManager->addWatchIgnoringRights( $user, $user->getUserPage() );
|
||||
} );
|
||||
|
||||
// Log the creation
|
||||
|
|
|
|||
|
|
@ -132,7 +132,8 @@ class AbstractPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegr
|
|||
$services->getReadOnlyMode(),
|
||||
$services->getUserNameUtils(),
|
||||
$services->getBlockManager(),
|
||||
$services->getBlockErrorFormatter()
|
||||
$services->getBlockErrorFormatter(),
|
||||
$services->getWatchlistManager()
|
||||
);
|
||||
|
||||
$provider = $this->getMockForAbstractClass(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use MediaWiki\MediaWikiServices;
|
|||
use MediaWiki\Session\SessionInfo;
|
||||
use MediaWiki\Session\UserInfo;
|
||||
use MediaWiki\User\UserNameUtils;
|
||||
use MediaWiki\Watchlist\WatchlistManager;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
|
||||
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
|
||||
|
|
@ -70,6 +71,9 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
/** @var BlockErrorFormatter */
|
||||
private $blockErrorFormatter;
|
||||
|
||||
/** @var WatchlistManager */
|
||||
private $watchlistManager;
|
||||
|
||||
/**
|
||||
* Sets a mock on a hook
|
||||
* @param string $hook
|
||||
|
|
@ -189,6 +193,9 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
if ( $regen || !$this->blockErrorFormatter ) {
|
||||
$this->blockErrorFormatter = MediaWikiServices::getInstance()->getBlockErrorFormatter();
|
||||
}
|
||||
if ( $regen || !$this->watchlistManager ) {
|
||||
$this->watchlistManager = MediaWikiServices::getInstance()->getWatchlistManager();
|
||||
}
|
||||
if ( $regen || !$this->hookContainer ) {
|
||||
// Set up a HookContainer similar to the normal one except that it
|
||||
// gets global hooks from $this->authHooks instead of $wgHooks
|
||||
|
|
@ -226,7 +233,8 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->readOnlyMode,
|
||||
$this->userNameUtils,
|
||||
$this->blockManager,
|
||||
$this->blockErrorFormatter
|
||||
$this->blockErrorFormatter,
|
||||
$this->watchlistManager
|
||||
);
|
||||
$this->manager->setLogger( $this->logger );
|
||||
$this->managerPriv = TestingAccessWrapper::newFromObject( $this->manager );
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
$mwServices->getReadOnlyMode(),
|
||||
$this->createNoOpMock( UserNameUtils::class ),
|
||||
$mwServices->getBlockManager(),
|
||||
$mwServices->getBlockErrorFormatter()
|
||||
$mwServices->getBlockErrorFormatter(),
|
||||
$mwServices->getWatchlistManager()
|
||||
] )
|
||||
->getMock();
|
||||
$manager->expects( $this->any() )->method( 'allowsAuthenticationDataChange' )
|
||||
|
|
@ -251,7 +252,8 @@ class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
$readOnlyMode,
|
||||
$userNameUtils,
|
||||
$mwServices->getBlockManager(),
|
||||
$mwServices->getBlockErrorFormatter()
|
||||
$mwServices->getBlockErrorFormatter(),
|
||||
$mwServices->getWatchlistManager()
|
||||
);
|
||||
$provider->setManager( $manager );
|
||||
$provider = TestingAccessWrapper::newFromObject( $provider );
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@ class EmailNotificationSecondaryAuthenticationProviderTest extends \MediaWikiInt
|
|||
$mwServices->getReadOnlyMode(),
|
||||
$userNameUtils,
|
||||
$mwServices->getBlockManager(),
|
||||
$mwServices->getBlockErrorFormatter()
|
||||
$mwServices->getBlockErrorFormatter(),
|
||||
$mwServices->getWatchlistManager()
|
||||
);
|
||||
|
||||
$creator = $this->getMockBuilder( \User::class )->getMock();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
$mwServices->getReadOnlyMode(),
|
||||
$userNameUtils,
|
||||
$mwServices->getBlockManager(),
|
||||
$mwServices->getBlockErrorFormatter()
|
||||
$mwServices->getBlockErrorFormatter(),
|
||||
$mwServices->getWatchlistManager()
|
||||
);
|
||||
}
|
||||
$this->validity = \Status::newGood();
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$mwServices->getReadOnlyMode(),
|
||||
$userNameUtils,
|
||||
$mwServices->getBlockManager(),
|
||||
$mwServices->getBlockErrorFormatter()
|
||||
$mwServices->getBlockErrorFormatter(),
|
||||
$mwServices->getWatchlistManager()
|
||||
);
|
||||
$provider->setManager( $manager );
|
||||
$provider = TestingAccessWrapper::newFromObject( $provider );
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiInteg
|
|||
$mwServices->getReadOnlyMode(),
|
||||
$userNameUtils,
|
||||
$mwServices->getBlockManager(),
|
||||
$mwServices->getBlockErrorFormatter()
|
||||
$mwServices->getBlockErrorFormatter(),
|
||||
$mwServices->getWatchlistManager()
|
||||
);
|
||||
}
|
||||
$this->validity = \Status::newGood();
|
||||
|
|
|
|||
Loading…
Reference in a new issue