r47279 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47278‎ | r47279 | r47280 >
Date:00:20, 15 February 2009
Author:siebrand
Status:resolved (Comments)
Tags:
Comment:
* (bug 17472) use print <<<EOF in maintenance/importTextFile.php. Patch contribute by Jidanni.
* removed trailing whitespace
Modified paths:
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/maintenance/importTextFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/importTextFile.php
@@ -9,7 +9,7 @@
1010 * @author Rob Church <robchur@gmail.com>
1111 */
1212
13 -$options = array( 'help', 'nooverwrite', 'norc' );
 13+$options = array( 'help', 'nooverwrite', 'norc' );
1414 $optionsWithArgs = array( 'title', 'user', 'comment' );
1515 require_once( 'commandLine.inc' );
1616 echo( "Import Text File\n\n" );
@@ -21,43 +21,43 @@
2222 $filename = $args[0];
2323 echo( "Using {$filename}..." );
2424 if( is_file( $filename ) ) {
25 -
 25+
2626 $title = isset( $options['title'] ) ? $options['title'] : titleFromFilename( $filename );
2727 $title = Title::newFromUrl( $title );
28 -
 28+
2929 if( is_object( $title ) ) {
30 -
 30+
3131 echo( "\nUsing title '" . $title->getPrefixedText() . "'..." );
3232 if( !$title->exists() || !isset( $options['nooverwrite'] ) ) {
33 -
 33+
3434 $text = file_get_contents( $filename );
3535 $user = isset( $options['user'] ) ? $options['user'] : 'Maintenance script';
3636 $user = User::newFromName( $user );
37 -
 37+
3838 if( is_object( $user ) ) {
39 -
 39+
4040 echo( "\nUsing username '" . $user->getName() . "'..." );
4141 $wgUser =& $user;
4242 $comment = isset( $options['comment'] ) ? $options['comment'] : 'Importing text file';
4343 $flags = 0 | ( isset( $options['norc'] ) ? EDIT_SUPPRESS_RC : 0 );
44 -
 44+
4545 echo( "\nPerforming edit..." );
4646 $article = new Article( $title );
4747 $article->doEdit( $text, $comment, $flags );
4848 echo( "done.\n" );
49 -
 49+
5050 } else {
5151 echo( "invalid username.\n" );
5252 }
53 -
 53+
5454 } else {
5555 echo( "page exists.\n" );
5656 }
57 -
 57+
5858 } else {
5959 echo( "invalid title.\n" );
6060 }
61 -
 61+
6262 } else {
6363 echo( "does not exist.\n" );
6464 }
@@ -71,16 +71,24 @@
7272 }
7373
7474 function showHelp() {
75 - echo( "Import the contents of a text file into a wiki page.\n" );
76 - echo( "USAGE: php importTextFile.php <options> <filename>\n\n" );
77 - echo( "<filename> : Path to the file containing page content to import\n\n" );
78 - echo( "Options:\n\n" );
79 - echo( "--title <title>\n\tTitle for the new page; default is to use the filename as a base\n" );
80 - echo( "--user <user>\n\tUser to be associated with the edit\n" );
81 - echo( "--comment <comment>\n\tEdit summary\n" );
82 - echo( "--nooverwrite\n\tDon't overwrite existing content\n" );
83 - echo( "--norc\n\tDon't update recent changes\n" );
84 - echo( "--help\n\tShow this information\n" );
85 - echo( "\n" );
 75+print <<<EOF
 76+USAGE: php importTextFile.php <options> <filename>
 77+
 78+<filename> : Path to the file containing page content to import
 79+
 80+Options:
 81+
 82+--title <title>
 83+ Title for the new page; default is to use the filename as a base
 84+--user <user>
 85+ User to be associated with the edit
 86+--comment <comment>
 87+ Edit summary
 88+--nooverwrite
 89+ Don't overwrite existing content
 90+--norc
 91+ Don't update recent changes
 92+--help
 93+ Show this information
 94+EOF;
8695 }
87 -
Index: trunk/phase3/CREDITS
@@ -64,6 +64,7 @@
6565 * FunPika
6666 * Happy-melon
6767 * Jeremy Baron
 68+* Jidanni
6869 * Juliano F. Ravasi
6970 * Lucas Garczewski
7071 * Louperivois
Index: trunk/phase3/RELEASE-NOTES
@@ -170,6 +170,7 @@
171171 * (bug 17478) Fixed a PHP Strict standards error in
172172 maintenance/cleanupWatchlist.php
173173 * (bug 17488) RSS/Atom links in left toolbar are now localized
 174+* (bug 17472) use print <<<EOF in maintenance/importTextFile.php
174175
175176 == API changes in 1.15 ==
176177 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions

Follow-up revisions

RevisionCommit summaryAuthorDate
r47383Tweak to r47279 -- include final newline to keep the terminal clean :)brion22:06, 17 February 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   22:06, 17 February 2009

added final newline in r47383

Status & tagging log