From: Bryan Tong Minh Date: Sun, 15 May 2011 14:46:13 +0000 (+0000) Subject: Per CR r75906, reintroduce ApiUpload::transformWarnings() X-Git-Tag: 1.31.0-rc.0~30144 X-Git-Url: http://git.cyclocoop.org/data/%24self?a=commitdiff_plain;h=ef3d06a44c43bff939c130e2890a8a8f45886088;p=lhc%2Fweb%2Fwiklou.git Per CR r75906, reintroduce ApiUpload::transformWarnings() --- 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.