FunPika has uploaded a new change for review. https://gerrit.wikimedia.org/r/276061
Change subject: Add AntiSpoofAddConflicts hook ...................................................................... Add AntiSpoofAddConflicts hook This is intended to reduce code duplication in CentralAuth's AntiSpoof by allowing it to add conflicts to the array returned by SpoofUser:getConflicts rather than run a copy of AntiSpoofHooks::asAbortNewAccountHook. Once the hook is implemented in CentralAuth, it should allow global conflicts to be detected anywhere in AntiSpoof, including the API module. Bug: T126174 Change-Id: I5372be6aa1160f390ae5c50c841f41b8a597915e --- M SpoofUser.php A hooks.txt 2 files changed, 29 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AntiSpoof refs/changes/61/276061/1 diff --git a/SpoofUser.php b/SpoofUser.php index e39430d..ce833bc 100644 --- a/SpoofUser.php +++ b/SpoofUser.php @@ -57,11 +57,26 @@ } /** - * Does the username pass Unicode legality and script-mixing checks? + * Find conflicting usernames locally and from extensions. * * @return array empty if no conflict, or array containing conflicting usernames */ public function getConflicts() { + $spoofs = array(); + $this->spoofedUsers( $spoofs ); + + Hooks::run( 'AntiSpoofAddConflicts', array( &$spoofs, $this->mName ) ); + array_unique( $spoofs ); // Ensure that extensions don't add duplicate spoofs. + + return $spoofs; + } + + /** + * Populate the array from getConflicts() with conflicting usernames. + * + * @param array $spoofs + */ + public function spoofedUsers( &$spoofs ) { $dbr = $this->getDBSlave(); // Join against the user table to ensure that we skip stray @@ -78,11 +93,9 @@ 'LIMIT' => 5 ) ); - $spoofs = array(); foreach ( $spoofedUsers as $row ) { array_push( $spoofs, $row->su_name ); } - return $spoofs; } /** diff --git a/hooks.txt b/hooks.txt new file mode 100644 index 0000000..9df6eb7 --- /dev/null +++ b/hooks.txt @@ -0,0 +1,13 @@ +This document describes how event hooks work in the AntiSpoof extension. + +For a more comprehensive guide to hooks, navigate to your root MediaWiki +directory and read docs/hooks.txt. + +== Events and parameters == +This is a list of known events and parameters; please add to it if you're going +to add events to the AntiSpoof extension. + +'AntiSpoofAddConflicts': Allows adding to the array of conflicts returned by +SpoofUser::getConflicts. +&$spoofs: Array of spoofed usernames +$name: Username to check -- To view, visit https://gerrit.wikimedia.org/r/276061 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5372be6aa1160f390ae5c50c841f41b8a597915e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/AntiSpoof Gerrit-Branch: master Gerrit-Owner: FunPika <funpikaw...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits