Last modified: 2014-02-12 23:32:46 UTC
I want to be able to automatically add bot users with maintenance/createAndPromote.php There are flags for sysop and bureaucrat but there's no --bot. Ideally however, it would be possible to add any kind of group to a new user. E.g. --groups=bot,sysop,bureaucrat,editor
Here's a quick patch for the --bot flag: --- maintenance/createAndPromote.php +++ maintenance/createAndPromote.php @@ -35,6 +35,7 @@ class CreateAndPromote extends Maintenance { parent::__construct(); $this->mDescription = "Create a new user account"; $this->addOption( "sysop", "Grant the account sysop rights" ); + $this->addOption( "bot", "Add the bot flag to the account" ); $this->addOption( "bureaucrat", "Grant the account bureaucrat rights" ); $this->addArg( "username", "Username of new user" ); $this->addArg( "password", "Password to set" ); @@ -71,6 +72,9 @@ class CreateAndPromote extends Maintenance { if ( $this->hasOption( 'bureaucrat' ) ) { $user->addGroup( 'bureaucrat' ); } + if ( $this->hasOption( 'bot' ) ) { + $user->addGroup( 'bot' ); + } # Increment site_stats.ss_users $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
Hi Kasper! Thanks for your patch! You are welcome to use Developer access https://www.mediawiki.org/wiki/Developer_access to submit this as a Git branch directly into Gerrit: https://www.mediawiki.org/wiki/Git/Tutorial Putting your branch in Git makes it easier to review it quickly. Thanks again! We appreciate your contribution.
Related URL: https://gerrit.wikimedia.org/r/65872 (Gerrit Change I61348e2d45b90b65a117efcce65d7c581105e612)
I've added the bot group using a different patch. I tried to use $permitGroups as array_diff( array_keys( $wgGroupPermissions ), $wgImplicitGroups ), but I got an error (and just to add, my PHP isn't that good ... yet).
I imagine this script is used for emergency cases eg. the only sysop/bcrat removed their own admin flag accidentally so no one can recover it on web UI. Do we want to add more groups to it?
By the looks of the request, people use it for other purposes as well, but I understand what you're saying.
Change 65872 merged by jenkins-bot: Add bot to createAndPromote.php groups https://gerrit.wikimedia.org/r/65872
Merged, I see no reason not to do it. I updated the docs at [[mw:Manual:createAndPromote.php]].