From ef3d06a44c43bff939c130e2890a8a8f45886088 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Sun, 15 May 2011 14:46:13 +0000 Subject: [PATCH] Per CR r75906, reintroduce ApiUpload::transformWarnings() --- includes/api/ApiUpload.php | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index a84f15c6db..46043a738f 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -342,30 +342,34 @@ class ApiUpload extends ApiBase { if ( !$this->mParams['ignorewarnings'] ) { $warnings = $this->mUpload->checkWarnings(); - if ( $warnings ) { - // Add indices - $this->getResult()->setIndexedTagName( $warnings, 'warning' ); - - if ( isset( $warnings['duplicate'] ) ) { - $dupes = array(); - foreach ( $warnings['duplicate'] as $dupe ) { - $dupes[] = $dupe->getName(); - } - $this->getResult()->setIndexedTagName( $dupes, 'duplicate' ); - $warnings['duplicate'] = $dupes; - } + } + return $this->transformWarnings( $warnings ); + } + + protected function transformWarnings( $warnings ) { + if ( $warnings ) { + // Add indices + $this->getResult()->setIndexedTagName( $warnings, 'warning' ); - if ( isset( $warnings['exists'] ) ) { - $warning = $warnings['exists']; - unset( $warnings['exists'] ); - $warnings[$warning['warning']] = $warning['file']->getName(); + if ( isset( $warnings['duplicate'] ) ) { + $dupes = array(); + foreach ( $warnings['duplicate'] as $dupe ) { + $dupes[] = $dupe->getName(); } + $this->getResult()->setIndexedTagName( $dupes, 'duplicate' ); + $warnings['duplicate'] = $dupes; } - } + if ( isset( $warnings['exists'] ) ) { + $warning = $warnings['exists']; + unset( $warnings['exists'] ); + $warnings[$warning['warning']] = $warning['file']->getName(); + } + } return $warnings; } + /** * Perform the actual upload. Returns a suitable result array on success; * dies on failure. -- 2.20.1