Go to the documentation of this file.
26 require_once __DIR__ .
'/Maintenance.php';
35 parent::__construct();
36 $this->
addDescription(
'Edit an article from the command line, text is from stdin' );
37 $this->
addOption(
'user',
'Username',
false,
true,
'u' );
38 $this->
addOption(
'summary',
'Edit summary',
false,
true,
's' );
39 $this->
addOption(
'remove',
'Remove a slot (requires --slot).',
false,
false );
40 $this->
addOption(
'minor',
'Minor edit',
false,
false,
'm' );
41 $this->
addOption(
'bot',
'Bot edit',
false,
false,
'b' );
42 $this->
addOption(
'autosummary',
'Enable autosummary',
false,
false,
'a' );
43 $this->
addOption(
'no-rc',
'Do not show the change in recent changes',
false,
false,
'r' );
44 $this->
addOption(
'nocreate',
'Don\'t create new pages',
false,
false );
45 $this->
addOption(
'createonly',
'Only create new pages',
false,
false );
46 $this->
addOption(
'slot',
'Slot role name',
false,
true );
47 $this->
addArg(
'title',
'Title of article to edit' );
53 $userName = $this->
getOption(
'user',
false );
54 $summary = $this->
getOption(
'summary',
'' );
58 $autoSummary = $this->
hasOption(
'autosummary' );
60 $slot = $this->
getOption(
'slot', SlotRecord::MAIN );
62 if ( $userName ===
false ) {
70 if ( $wgUser->isAnon() ) {
71 $wgUser->addToDatabase();
88 if ( $slot === SlotRecord::MAIN ) {
89 $this->
fatalError(
"Cannot remove main slot! Use --slot to specify." );
100 $this->
output(
"Saving... " );
101 $updater = $page->newPageUpdater( $wgUser );
109 $updater->removeSlot( $slot );
111 $updater->setContent( $slot,
$content );
115 $status = $updater->getStatus();
117 if ( $status->isOK() ) {
118 $this->
output(
"done\n" );
121 $this->
output(
"failed\n" );
124 if ( !$status->isGood() ) {
125 $this->
output( $status->getMessage(
false,
false,
'en' )->text() .
"\n" );
const RUN_MAINTENANCE_IF_MAIN
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
getStdin( $len=null)
Return input from stdin.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addDescription( $text)
Set the description text.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
__construct()
Default constructor.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Maintenance script to make a page edit.
getOption( $name, $default=null)
Get an option, or return the default.
addArg( $arg, $description, $required=true)
Add some args that are needed.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option exists.
getArg( $argId=0, $default=null)
Get an argument.
execute()
Do the actual work.