Add "nocreate" and "createonly" options to edit.php
authorKunal Mehta <legoktm@gmail.com>
Tue, 10 Dec 2013 22:13:53 +0000 (14:13 -0800)
committerKunal Mehta <legoktm@gmail.com>
Tue, 10 Dec 2013 22:17:50 +0000 (14:17 -0800)
Change-Id: I2101360a934b8b9a92094c44429e3e2314c7fba3

maintenance/edit.php

index 6e69651..6bdb15d 100644 (file)
@@ -38,6 +38,8 @@ 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' );
        }
 
@@ -67,6 +69,12 @@ class EditCLI extends Maintenance {
                }
                $context->setTitle( $title );
 
+               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