diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
commit | c9aa36da061816dee256a979c2ff8d2ee41824d9 (patch) | |
tree | 29f7002b80ee984b488bd047dbbd80b36bf892e9 /maintenance/edit.php | |
parent | b4274e0e33eafb5e9ead9d949ebf031a9fb8363b (diff) | |
parent | d1ba966140d7a60cd5ae4e8667ceb27c1a138592 (diff) |
Merge branch 'archwiki'
# Conflicts:
# skins/ArchLinux.php
# skins/ArchLinux/archlogo.gif
Diffstat (limited to 'maintenance/edit.php')
-rw-r--r-- | maintenance/edit.php | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/maintenance/edit.php b/maintenance/edit.php index 7c24f0fa..75ec12bf 100644 --- a/maintenance/edit.php +++ b/maintenance/edit.php @@ -38,11 +38,13 @@ class EditCLI extends Maintenance { $this->addOption( 'bot', 'Bot edit', false, false, 'b' ); $this->addOption( 'autosummary', 'Enable autosummary', false, false, 'a' ); $this->addOption( 'no-rc', 'Do not show the change in recent changes', false, false, 'r' ); + $this->addOption( 'nocreate', 'Don\'t create new pages', false, false ); + $this->addOption( 'createonly', 'Only create new pages', false, false ); $this->addArg( 'title', 'Title of article to edit' ); } public function execute() { - global $wgUser, $wgTitle; + global $wgUser; $userName = $this->getOption( 'user', 'Maintenance script' ); $summary = $this->getOption( 'summary', '' ); @@ -52,8 +54,6 @@ class EditCLI extends Maintenance { $noRC = $this->hasOption( 'no-rc' ); $wgUser = User::newFromName( $userName ); - $context = RequestContext::getMain(); - $context->setUser( $wgUser ); if ( !$wgUser ) { $this->error( "Invalid username", true ); } @@ -61,17 +61,22 @@ class EditCLI extends Maintenance { $wgUser->addToDatabase(); } - $wgTitle = Title::newFromText( $this->getArg() ); - if ( !$wgTitle ) { + $title = Title::newFromText( $this->getArg() ); + if ( !$title ) { $this->error( "Invalid title", true ); } - $context->setTitle( $wgTitle ); - $page = WikiPage::factory( $wgTitle ); + if ( $this->hasOption( 'nocreate' ) && !$title->exists() ) { + $this->error( "Page does not exist", true ); + } elseif ( $this->hasOption( 'createonly' ) && $title->exists() ) { + $this->error( "Page already exists", true ); + } + + $page = WikiPage::factory( $title ); # Read the text $text = $this->getStdin( Maintenance::STDIN_ALL ); - $content = ContentHandler::makeContent( $text, $wgTitle ); + $content = ContentHandler::makeContent( $text, $title ); # Do the edit $this->output( "Saving... " ); |