From: Reedy Date: Sun, 3 Apr 2016 11:28:48 +0000 (+0100) Subject: Don't allow createAndPromote.php to add users to invalid groups X-Git-Tag: 1.31.0-rc.0~7384 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=16fc39d17ce45630161a9ec17bf1f9f918608e71;p=lhc%2Fweb%2Fwiklou.git Don't allow createAndPromote.php to add users to invalid groups Bug: T131704 Change-Id: Ibe8839e62af8db002adea68ffa87b3adf2b505ea --- 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" ); + } } } }