MediaWiki REL1_30
makeTestEdits.php
Go to the documentation of this file.
1<?php
23require_once __DIR__ . '/Maintenance.php';
24
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 );
38 }
39
40 public function execute() {
41 $user = User::newFromName( $this->getOption( 'user' ) );
42 if ( !$user->getId() ) {
43 $this->error( "No such user exists.", 1 );
44 }
45
46 $count = $this->getOption( 'count' );
47 $namespace = (int)$this->getOption( 'namespace', 0 );
48
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 );
54
55 $page->doEditContent( $content, $summary, 0, false, $user );
56
57 $this->output( "Edited $title\n" );
58 if ( $i && ( $i % $this->mBatchSize ) == 0 ) {
60 }
61 }
62
63 $this->output( "Done\n" );
64 }
65}
66
67$maintClass = "MakeTestEdits";
68require_once RUN_MAINTENANCE_IF_MAIN;
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
wfRandomString( $length=32)
Get a random string containing a number of pseudo-random hex characters.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
setBatchSize( $s=0)
Set the batch size.
Make test edits for a user to populate a test wiki.
execute()
Do the actual work.
__construct()
Default constructor.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition WikiPage.php:121
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
Definition hooks.txt:2581
require_once RUN_MAINTENANCE_IF_MAIN
$maintClass