X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FcreateAndPromote.php;h=1872716fb5c4eef67624b3e8cbcc9126134f7f76;hb=937e602c2c56f068272f635c5867d69f00f9ef49;hp=9abc297dc3f8cd656fb3cea9c8a6675ae748cacd;hpb=b5906606e1aa1a795231fb813b766818b1dd6c25;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index 9abc297dc3..1872716fb5 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" ); + } } } } @@ -115,7 +120,14 @@ class CreateAndPromote extends Maintenance { if ( $password ) { # Try to set the password try { - $user->setPassword( $password ); + $status = $user->changeAuthenticationData( [ + 'username' => $user->getName(), + 'password' => $password, + 'retype' => $password, + ] ); + if ( !$status->isGood() ) { + throw new PasswordError( $status->getWikiText( null, null, 'en' ) ); + } if ( $exists ) { $this->output( "Password set.\n" ); $user->saveSettings();