Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -342,30 +342,34 @@ |
343 | 343 | |
344 | 344 | if ( !$this->mParams['ignorewarnings'] ) { |
345 | 345 | $warnings = $this->mUpload->checkWarnings(); |
346 | | - if ( $warnings ) { |
347 | | - // Add indices |
348 | | - $this->getResult()->setIndexedTagName( $warnings, 'warning' ); |
| 346 | + } |
| 347 | + return $this->transformWarnings( $warnings ); |
| 348 | + } |
| 349 | + |
| 350 | + protected function transformWarnings( $warnings ) { |
| 351 | + if ( $warnings ) { |
| 352 | + // Add indices |
| 353 | + $this->getResult()->setIndexedTagName( $warnings, 'warning' ); |
349 | 354 | |
350 | | - if ( isset( $warnings['duplicate'] ) ) { |
351 | | - $dupes = array(); |
352 | | - foreach ( $warnings['duplicate'] as $dupe ) { |
353 | | - $dupes[] = $dupe->getName(); |
354 | | - } |
355 | | - $this->getResult()->setIndexedTagName( $dupes, 'duplicate' ); |
356 | | - $warnings['duplicate'] = $dupes; |
| 355 | + if ( isset( $warnings['duplicate'] ) ) { |
| 356 | + $dupes = array(); |
| 357 | + foreach ( $warnings['duplicate'] as $dupe ) { |
| 358 | + $dupes[] = $dupe->getName(); |
357 | 359 | } |
| 360 | + $this->getResult()->setIndexedTagName( $dupes, 'duplicate' ); |
| 361 | + $warnings['duplicate'] = $dupes; |
| 362 | + } |
358 | 363 | |
359 | | - if ( isset( $warnings['exists'] ) ) { |
360 | | - $warning = $warnings['exists']; |
361 | | - unset( $warnings['exists'] ); |
362 | | - $warnings[$warning['warning']] = $warning['file']->getName(); |
363 | | - } |
| 364 | + if ( isset( $warnings['exists'] ) ) { |
| 365 | + $warning = $warnings['exists']; |
| 366 | + unset( $warnings['exists'] ); |
| 367 | + $warnings[$warning['warning']] = $warning['file']->getName(); |
364 | 368 | } |
365 | 369 | } |
366 | | - |
367 | 370 | return $warnings; |
368 | 371 | } |
369 | 372 | |
| 373 | + |
370 | 374 | /** |
371 | 375 | * Perform the actual upload. Returns a suitable result array on success; |
372 | 376 | * dies on failure. |