3 $optionsWithArgs = array( 'u', 's' );
5 require_once( 'commandLine.inc' );
7 if ( count( $args ) == 0 ||
isset( $options['help'] ) ) {
9 Edit an article from the command line
11 Usage: php edit.php [options...] <title>
15 -s <summary> Edit summary
19 --no-rc Do not show the change in recent changes
21 If the specified user does not exist, it will be created.
22 The text for the edit will be read from stdin.
28 $userName = isset( $options['u'] ) ?
$options['u'] : 'Maintenance script';
29 $summary = isset( $options['s'] ) ?
$options['s'] : '';
30 $minor = isset( $options['m'] );
31 $bot = isset( $options['b'] );
32 $autoSummary = isset( $options['a'] );
33 $noRC = isset( $options['no-rc'] );
35 $wgUser = User
::newFromName( $userName );
37 print "Invalid username\n";
40 if ( $wgUser->isAnon() ) {
41 $wgUser->addToDatabase();
44 $wgTitle = Title
::newFromText( $args[0] );
46 print "Invalid title\n";
50 $wgArticle = new Article( $wgTitle );
53 $text = file_get_contents( 'php://stdin' );
57 $success = $wgArticle->doEdit( $text, $summary,
58 ( $minor ? EDIT_MINOR
: 0 ) |
59 ( $bot ? EDIT_FORCE_BOT
: 0 ) |
60 ( $autoSummary ? EDIT_AUTOSUMMARY
: 0 ) |
61 ( $noRC ? EDIT_SUPPRESS_RC
: 0 ) );