From 16fc39d17ce45630161a9ec17bf1f9f918608e71 Mon Sep 17 00:00:00 2001 From: Reedy Date: Sun, 3 Apr 2016 12:28:48 +0100 Subject: [PATCH] Don't allow createAndPromote.php to add users to invalid groups Bug: T131704 Change-Id: Ibe8839e62af8db002adea68ffa87b3adf2b505ea --- maintenance/createAndPromote.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index 9abc297dc3..848c2f7eda 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -79,11 +79,16 @@ class CreateAndPromote extends Maintenance { $groups = array_filter( self::$permitRoles, [ $this, 'hasOption' ] ); if ( $this->hasOption( 'custom-groups' ) ) { + $allGroups = array_flip( User::getAllGroups() ); $customGroupsText = $this->getOption( 'custom-groups' ); if ( $customGroupsText !== '' ) { $customGroups = explode( ',', $customGroupsText ); foreach ( $customGroups as $customGroup ) { - $groups[] = trim( $customGroup ); + if ( isset( $allGroups[$customGroup] ) ) { + $groups[] = trim( $customGroup ); + } else { + $this->output( "$customGroup is not a valid group, ignoring!\n" ); + } } } } -- 2.20.1