Remove FileRepoStatus references
[mediawiki.git] / maintenance / makeTestEdits.php
blobca2f7c51c985404f8fcc49586b29efcbe77d76da
1 <?php
2 /**
3 * Make test edits for a user to populate a test wiki
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Maintenance
23 require_once __DIR__ . '/Maintenance.php';
25 /**
26 * Make test edits for a user to populate a test wiki
28 * @ingroup Maintenance
30 class MakeTestEdits extends Maintenance {
31 public function __construct() {
32 parent::__construct();
33 $this->addDescription( 'Make test edits for a user' );
34 $this->addOption( 'user', 'User name', true, true );
35 $this->addOption( 'count', 'Number of edits', true, true );
36 $this->addOption( 'namespace', 'Namespace number', false, true );
37 $this->setBatchSize( 100 );
40 public function execute() {
41 $user = User::newFromName( $this->getOption( 'user' ) );
42 if ( !$user->getId() ) {
43 $this->error( "No such user exists.", 1 );
46 $count = $this->getOption( 'count' );
47 $namespace = (int)$this->getOption( 'namespace', 0 );
49 for ( $i = 0; $i < $count; ++$i ) {
50 $title = Title::makeTitleSafe( $namespace, "Page " . wfRandomString( 2 ) );
51 $page = WikiPage::factory( $title );
52 $content = ContentHandler::makeContent( wfRandomString(), $title );
53 $summary = "Change " . wfRandomString( 6 );
55 $page->doEditContent( $content, $summary, 0, false, $user );
57 $this->output( "Edited $title\n" );
58 if ( $i && ( $i % $this->mBatchSize ) == 0 ) {
59 wfWaitForSlaves();
63 $this->output( "Done\n" );
67 $maintClass = "MakeTestEdits";
68 require_once RUN_MAINTENANCE_IF_MAIN;