From 5600052c32807d12d87b3a658eba1bf78a98b031 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 8 Dec 2015 13:35:34 -0800 Subject: [PATCH] Add script to generate random test edits for a user Change-Id: Ieb079196aa8b70c8df52d791cd3a49242ebfb1e7 --- maintenance/makeTestEdits.php | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 maintenance/makeTestEdits.php diff --git a/maintenance/makeTestEdits.php b/maintenance/makeTestEdits.php new file mode 100644 index 0000000000..fdf4eb9daf --- /dev/null +++ b/maintenance/makeTestEdits.php @@ -0,0 +1,68 @@ +mDescription = "Make test edits for a user"; + $this->addOption( 'user', 'User name', true, true ); + $this->addOption( 'count', 'Number of edits', true, true ); + $this->addOption( 'namespace', 'Namespace number', false, true ); + $this->setBatchSize( 100 ); + } + + public function execute() { + $user = User::newFromName( $this->getOption( 'user' ) ); + if ( !$user ) { + $this->error( "No such user exists.", 1 ); + } + + $count = $this->getOption( 'count' ); + $namespace = (int)$this->getOption( 'namespace', 0 ); + + for ( $i = 0; $i < $count; ++$i ) { + $title = Title::makeTitleSafe( $namespace, "Page " . wfRandomString( 2 ) ); + $page = WikiPage::factory( $title ); + $content = ContentHandler::makeContent( wfRandomString(), $title ); + $summary = "Change " . wfRandomString( 6 ); + + $page->doEditContent( $content, $summary, 0, false, $user ); + + $this->output( "Edited $title\n" ); + if ( $i && ( $i % $this->mBatchSize ) == 0 ) { + wfWaitForSlaves(); + } + } + + $this->output( "Done\n" ); + } +} + +$maintClass = "MakeTestEdits"; +require_once RUN_MAINTENANCE_IF_MAIN; -- 2.20.1