[MediaWiki-commits] [Gerrit] Add and use CentralAuthUser::getMasterInstance() method - change (mediawiki...CentralAuth)
jenkins-bot has submitted this change and it was merged. Change subject: Add and use CentralAuthUser::getMasterInstance() method .. Add and use CentralAuthUser::getMasterInstance() method * Make onAbortLogin use this method * Converted onAbortNewAccount to using this too * Fix a few IDEA errors too Change-Id: Iac63c577d2dfabb773b5a219185f4a8d90fc9257 --- M includes/CentralAuthHooks.php M includes/CentralAuthUser.php 2 files changed, 32 insertions(+), 8 deletions(-) Approvals: Krinkle: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php index 3c8fcfd..926e84e 100644 --- a/includes/CentralAuthHooks.php +++ b/includes/CentralAuthHooks.php @@ -443,11 +443,11 @@ * @param $abortError * @return bool */ - static function onAbortNewAccount( $user, &$abortError ) { + static function onAbortNewAccount( User $user, &$abortError ) { global $wgCentralAuthPreventUnattached; global $wgCentralAuthEnableGlobalRenameRequest; - $centralUser = new CentralAuthUser( $user->getName(), CentralAuthUser::READ_LATEST ); + $centralUser = CentralAuthUser::getMasterInstance( $user ); if ( $centralUser->exists() || $centralUser->renameInProgressOn( wfWikiID() ) ) { $abortError = wfMessage( 'centralauth-account-exists' )->text(); return false; @@ -498,7 +498,7 @@ * @throws Exception */ static function onAbortLogin( User $user, $pass, &$retval, &$msg ) { - $centralUser = CentralAuthUser::getInstance( $user ); + $centralUser = CentralAuthUser::getMasterInstance( $user ); // Since logins are rare, check the actual DB $rename = $centralUser->renameInProgressOn( wfWikiID() ); @@ -579,8 +579,8 @@ /** * Show a nicer error when the user account does not exist on the local wiki, but * does exist globally -* @param $users Array -* @param $data Array +* @param $users User[] +* @param $data array * @param $abortError String * @return bool */ @@ -608,7 +608,7 @@ * @return bool */ static function onUserLoginComplete( &$user, &$inject_html ) { - global $wgCentralAuthLoginWiki, $wgCentralAuthCookies; + global $wgCentralAuthCookies; global $wgCentralAuthCheckSULMigration; if ( $wgCentralAuthCheckSULMigration && @@ -980,7 +980,7 @@ * @param $userName * @return bool */ - static function onUserLogoutComplete( &$user, &$inject_html, $userName ) { + static function onUserLogoutComplete( User &$user, &$inject_html, $userName ) { global $wgCentralAuthCookies, $wgCentralAuthLoginWiki, $wgCentralAuthAutoLoginWikis; if ( !$wgCentralAuthCookies ) { @@ -1356,9 +1356,10 @@ } /** -* @param $id user_id integer +* @param integer $id User ID * @param User $user * @param SpecialPage $sp +* @return bool */ static function onSpecialContributionsBeforeMainOutput( $id, User $user, SpecialPage $sp ) { if ( $user->isAnon() ) { @@ -1910,6 +1911,7 @@ * @param array &$namesById array of userIds=>names to associate * @param bool|User $audience show hidden names based on this user, or false for public * @param string $wgMWOAuthSharedUserSource the authoritative extension +* @return bool */ public static function onOAuthGetUserNamesFromCentralIds( $wgMWOAuthCentralWiki, &$namesById, $audience, $wgMWOAuthSharedUserSource ) { if ( $wgMWOAuthSharedUserSource !== 'CentralAuth' ) { @@ -1944,6 +1946,8 @@ * @param string $wgMWOAuthCentralWiki * @param User &$user the loca user object * @param string $wgMWOAuthSharedUserSource the authoritative extension +* @return bool +* @throws Exception */ public static function onOAuthGetLocalUserFromCentralId( $userId, $wgMWOAuthCentralWiki, &$user, $wgMWOAuthSharedUserSource ) { if ( $wgMWOAuthSharedUserSource !== 'CentralAuth' ) { @@ -1992,6 +1996,7 @@ * @param string $wgMWOAuthCentralWiki * @param int &$id the user_id of the matching name on the central wiki * @param string $wgMWOAuthSharedUserSource the authoritative extension +* @return bool */ public static function onOAuthGetCentralIdFromLocalUser( $user, $wgMWOAuthCentralWiki, &$id, $wgMWOAuthSharedUserSource ) { if ( $wgMWOAuthSharedUserSource !== 'CentralAuth' ) { @@ -2020,6 +2025,7 @@ * @param string $wgMWOAuthCentralWiki *
[MediaWiki-commits] [Gerrit] Add and use CentralAuthUser::getMasterInstance() method - change (mediawiki...CentralAuth)
Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/255799 Change subject: Add and use CentralAuthUser::getMasterInstance() method .. Add and use CentralAuthUser::getMasterInstance() method * Make onAbortLogin use this method * Converted onAbortNewAccount to using this too * Fix a few IDEA errors too Change-Id: Iac63c577d2dfabb773b5a219185f4a8d90fc9257 --- M includes/CentralAuthHooks.php M includes/CentralAuthUser.php 2 files changed, 32 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth refs/changes/99/255799/1 diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php index 3c8fcfd..926e84e 100644 --- a/includes/CentralAuthHooks.php +++ b/includes/CentralAuthHooks.php @@ -443,11 +443,11 @@ * @param $abortError * @return bool */ - static function onAbortNewAccount( $user, &$abortError ) { + static function onAbortNewAccount( User $user, &$abortError ) { global $wgCentralAuthPreventUnattached; global $wgCentralAuthEnableGlobalRenameRequest; - $centralUser = new CentralAuthUser( $user->getName(), CentralAuthUser::READ_LATEST ); + $centralUser = CentralAuthUser::getMasterInstance( $user ); if ( $centralUser->exists() || $centralUser->renameInProgressOn( wfWikiID() ) ) { $abortError = wfMessage( 'centralauth-account-exists' )->text(); return false; @@ -498,7 +498,7 @@ * @throws Exception */ static function onAbortLogin( User $user, $pass, &$retval, &$msg ) { - $centralUser = CentralAuthUser::getInstance( $user ); + $centralUser = CentralAuthUser::getMasterInstance( $user ); // Since logins are rare, check the actual DB $rename = $centralUser->renameInProgressOn( wfWikiID() ); @@ -579,8 +579,8 @@ /** * Show a nicer error when the user account does not exist on the local wiki, but * does exist globally -* @param $users Array -* @param $data Array +* @param $users User[] +* @param $data array * @param $abortError String * @return bool */ @@ -608,7 +608,7 @@ * @return bool */ static function onUserLoginComplete( &$user, &$inject_html ) { - global $wgCentralAuthLoginWiki, $wgCentralAuthCookies; + global $wgCentralAuthCookies; global $wgCentralAuthCheckSULMigration; if ( $wgCentralAuthCheckSULMigration && @@ -980,7 +980,7 @@ * @param $userName * @return bool */ - static function onUserLogoutComplete( &$user, &$inject_html, $userName ) { + static function onUserLogoutComplete( User &$user, &$inject_html, $userName ) { global $wgCentralAuthCookies, $wgCentralAuthLoginWiki, $wgCentralAuthAutoLoginWikis; if ( !$wgCentralAuthCookies ) { @@ -1356,9 +1356,10 @@ } /** -* @param $id user_id integer +* @param integer $id User ID * @param User $user * @param SpecialPage $sp +* @return bool */ static function onSpecialContributionsBeforeMainOutput( $id, User $user, SpecialPage $sp ) { if ( $user->isAnon() ) { @@ -1910,6 +1911,7 @@ * @param array &$namesById array of userIds=>names to associate * @param bool|User $audience show hidden names based on this user, or false for public * @param string $wgMWOAuthSharedUserSource the authoritative extension +* @return bool */ public static function onOAuthGetUserNamesFromCentralIds( $wgMWOAuthCentralWiki, &$namesById, $audience, $wgMWOAuthSharedUserSource ) { if ( $wgMWOAuthSharedUserSource !== 'CentralAuth' ) { @@ -1944,6 +1946,8 @@ * @param string $wgMWOAuthCentralWiki * @param User &$user the loca user object * @param string $wgMWOAuthSharedUserSource the authoritative extension +* @return bool +* @throws Exception */ public static function onOAuthGetLocalUserFromCentralId( $userId, $wgMWOAuthCentralWiki, &$user, $wgMWOAuthSharedUserSource ) { if ( $wgMWOAuthSharedUserSource !== 'CentralAuth' ) { @@ -1992,6 +1996,7 @@ * @param string $wgMWOAuthCentralWiki * @param int &$id the user_id of the matching name on the central wiki * @param string $wgMWOAuthSharedUserSource the authoritative extension +* @return bool */ public static function onOAuthGetCentralIdFromLocalUser( $user, $wgMWOAuthCentralWiki, &$id, $wgMWOAuthSharedUserSource ) { if ( $wgMWOAuthSharedUserSource !== 'CentralAuth' ) { @@ -2020,6