Return normalized file name on warning "exists-normalized"
authorrillke <rainerrillke@hotmail.com>
Sat, 10 Aug 2013 12:14:03 +0000 (14:14 +0200)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 6 Sep 2013 14:47:45 +0000 (10:47 -0400)
Make API action=upload return normalized file name on warning
"exists-normalized" instead of filename to be uploaded to.

This enables humans to see which file the current upload conflicts
with.
There is no point in returning the filename the upload should go to
because the client that makes the request is usually aware of this.

Bug: 52699
Change-Id: I898b7f234d43eb1e524952f6de80e401a8c96671

RELEASE-NOTES-1.22
includes/api/ApiUpload.php

index 8cdb985..e503e30 100644 (file)
@@ -345,6 +345,8 @@ production.
 * Support for the 'gettoken' parameter to action=block and action=unblock,
   deprecated since 1.20, has been removed.
 * (bug 49090) Token-getting functions will fail when using jsonp callbacks.
+* (bug 52699) action=upload returns normalized file name on warning
+  "exists-normalized" instead of filename to be uploaded to.
 
 === Languages updated in 1.22===
 
index b903a62..6f6b080 100644 (file)
@@ -565,7 +565,8 @@ class ApiUpload extends ApiBase {
                        if ( isset( $warnings['exists'] ) ) {
                                $warning = $warnings['exists'];
                                unset( $warnings['exists'] );
-                               $warnings[$warning['warning']] = $warning['file']->getName();
+                               $localFile = isset( $warning['normalizedFile'] ) ? $warning['normalizedFile'] : $warning['file'];
+                               $warnings[$warning['warning']] = $localFile->getName();
                        }
                }
                return $warnings;