r72867 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72866‎ | r72867 | r72868 >
Date:15:39, 12 September 2010
Author:ialex
Status:ok
Tags:
Comment:
Whitespaces fixes:
* use tabs for indentation
* removed trailing whitespaces
Modified paths:
  • /trunk/phase3/maintenance/importImages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/importImages.php
@@ -61,10 +61,10 @@
6262 $checkUserBlock = false;
6363 }
6464
65 - # Get --from
 65+ # Get --from
6666 $from = @$options['from'];
6767
68 - # Get sleep time.
 68+ # Get sleep time.
6969 $sleep = @$options['sleep'];
7070 if ( $sleep ) $sleep = (int)$sleep;
7171
@@ -92,17 +92,17 @@
9393
9494 # Batch "upload" operation
9595 if ( ( $count = count( $files ) ) > 0 ) {
96 -
 96+
9797 foreach ( $files as $file ) {
9898 $base = wfBaseName( $file );
99 -
 99+
100100 # Validate a title
101101 $title = Title::makeTitleSafe( NS_FILE, $base );
102102 if ( !is_object( $title ) ) {
103103 echo( "{$base} could not be imported; a valid title cannot be produced\n" );
104104 continue;
105105 }
106 -
 106+
107107 if ( $from ) {
108108 if ( $from == $title->getDBkey() ) {
109109 $from = NULL;
@@ -149,49 +149,49 @@
150150 $svar = 'added';
151151 }
152152
153 - if ( isset( $options['source-wiki-url'] ) ) {
154 - /* find comment text directly from source wiki, through MW's API */
155 - $real_comment = getFileCommentFromSourceWiki( $options['source-wiki-url'], $base );
156 - if ( $real_comment === false )
157 - $commentText = $comment;
158 - else
159 - $commentText = $real_comment;
 153+ if ( isset( $options['source-wiki-url'] ) ) {
 154+ /* find comment text directly from source wiki, through MW's API */
 155+ $real_comment = getFileCommentFromSourceWiki( $options['source-wiki-url'], $base );
 156+ if ( $real_comment === false )
 157+ $commentText = $comment;
 158+ else
 159+ $commentText = $real_comment;
160160
161 - /* find user directly from source wiki, through MW's API */
162 - $real_user = getFileUserFromSourceWiki( $options['source-wiki-url'], $base );
163 - if ( $real_user === false ) {
164 - $wgUser = $user;
165 - } else {
166 - $wgUser = User::newFromName( $real_user );
167 - if ( $wgUser === false ) {
168 - # user does not exist in target wiki
169 - echo ( "failed: user '$real_user' does not exist in target wiki." );
170 - continue;
171 - }
172 - }
173 - } else {
174 - # Find comment text
175 - $commentText = false;
 161+ /* find user directly from source wiki, through MW's API */
 162+ $real_user = getFileUserFromSourceWiki( $options['source-wiki-url'], $base );
 163+ if ( $real_user === false ) {
 164+ $wgUser = $user;
 165+ } else {
 166+ $wgUser = User::newFromName( $real_user );
 167+ if ( $wgUser === false ) {
 168+ # user does not exist in target wiki
 169+ echo ( "failed: user '$real_user' does not exist in target wiki." );
 170+ continue;
 171+ }
 172+ }
 173+ } else {
 174+ # Find comment text
 175+ $commentText = false;
176176
177 - if ( $commentExt ) {
178 - $f = findAuxFile( $file, $commentExt );
179 - if ( !$f ) {
180 - echo( " No comment file with extension {$commentExt} found for {$file}, using default comment. " );
181 - } else {
182 - $commentText = file_get_contents( $f );
183 - if ( !$f ) {
184 - echo( " Failed to load comment file {$f}, using default comment. " );
185 - }
186 - }
187 - }
 177+ if ( $commentExt ) {
 178+ $f = findAuxFile( $file, $commentExt );
 179+ if ( !$f ) {
 180+ echo( " No comment file with extension {$commentExt} found for {$file}, using default comment. " );
 181+ } else {
 182+ $commentText = file_get_contents( $f );
 183+ if ( !$f ) {
 184+ echo( " Failed to load comment file {$f}, using default comment. " );
 185+ }
 186+ }
 187+ }
188188
189 - if ( !$commentText ) {
190 - $commentText = $comment;
191 - }
192 - }
 189+ if ( !$commentText ) {
 190+ $commentText = $comment;
 191+ }
 192+ }
193193
194194
195 - # Import the file
 195+ # Import the file
196196 if ( isset( $options['dry'] ) ) {
197197 echo( " publishing {$file} by '" . $wgUser->getName() . "', comment '$commentText'... " );
198198 } else {
@@ -202,14 +202,14 @@
203203 continue;
204204 }
205205 }
206 -
 206+
207207 $doProtect = false;
208208 $restrictions = array();
209 -
 209+
210210 global $wgRestrictionLevels;
211 -
 211+
212212 $protectLevel = isset( $options['protect'] ) ? $options['protect'] : null;
213 -
 213+
214214 if ( $protectLevel && in_array( $protectLevel, $wgRestrictionLevels ) ) {
215215 $restrictions['move'] = $protectLevel;
216216 $restrictions['edit'] = $protectLevel;
@@ -234,19 +234,19 @@
235235 // Wait for slaves.
236236 sleep( 2.0 );
237237 wfWaitForSlaves( 1.0 );
238 -
 238+
239239 echo( "\nSetting image restrictions ... " );
240240 if ( $article->updateRestrictions( $restrictions ) )
241 - echo( "done.\n" );
 241+ echo( "done.\n" );
242242 else
243 - echo( "failed.\n" );
 243+ echo( "failed.\n" );
244244 }
245245
246246 } else {
247247 echo( "failed.\n" );
248248 $svar = 'failed';
249249 }
250 -
 250+
251251 $$svar++;
252252 $processed++;
253253
@@ -256,7 +256,7 @@
257257 if ( $sleep )
258258 sleep( $sleep );
259259 }
260 -
 260+
261261 # Print out some statistics
262262 echo( "\n" );
263263 foreach ( array( 'count' => 'Found', 'limit' => 'Limit', 'ignored' => 'Ignored',
@@ -265,7 +265,7 @@
266266 if ( $$var > 0 )
267267 echo( "{$desc}: {$$var}\n" );
268268 }
269 -
 269+
270270 } else {
271271 echo( "No suitable files could be found for import.\n" );
272272 }

Status & tagging log