Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -280,7 +280,7 @@ |
281 | 281 | * @return array Array of warnings |
282 | 282 | */ |
283 | 283 | public function checkWarnings() { |
284 | | - $warning = array(); |
| 284 | + $warnings = array(); |
285 | 285 | |
286 | 286 | $localFile = $this->getLocalFile(); |
287 | 287 | $filename = $localFile->getName(); |
— | — | @@ -297,33 +297,33 @@ |
298 | 298 | $comparableName = $wgContLang->ucfirst( $comparableName ); |
299 | 299 | } |
300 | 300 | if( $this->mDesiredDestName != $filename && $comparableName != $filename ) |
301 | | - $warning['badfilename'] = $filename; |
| 301 | + $warnings['badfilename'] = $filename; |
302 | 302 | |
303 | 303 | // Check whether the file extension is on the unwanted list |
304 | 304 | global $wgCheckFileExtensions, $wgFileExtensions; |
305 | 305 | if ( $wgCheckFileExtensions ) { |
306 | 306 | if ( !$this->checkFileExtension( $this->mFinalExtension, $wgFileExtensions ) ) |
307 | | - $warning['filetype-unwanted-type'] = $this->mFinalExtension; |
| 307 | + $warnings['filetype-unwanted-type'] = $this->mFinalExtension; |
308 | 308 | } |
309 | 309 | |
310 | 310 | global $wgUploadSizeWarning; |
311 | 311 | if ( $wgUploadSizeWarning && ( $this->mFileSize > $wgUploadSizeWarning ) ) |
312 | | - $warning['large-file'] = $wgUploadSizeWarning; |
| 312 | + $warnings['large-file'] = $wgUploadSizeWarning; |
313 | 313 | |
314 | 314 | if ( $this->mFileSize == 0 ) |
315 | | - $warning['emptyfile'] = true; |
| 315 | + $warnings['emptyfile'] = true; |
316 | 316 | |
317 | 317 | |
318 | 318 | $exists = self::getExistsWarning( $localFile ); |
319 | 319 | if( $exists !== false ) |
320 | | - $warning['exists'] = $exists; |
| 320 | + $warnings['exists'] = $exists; |
321 | 321 | |
322 | 322 | // Check whether this may be a thumbnail |
323 | 323 | if( $exists !== false && $exists[0] != 'thumb' |
324 | 324 | && self::isThumbName( $filename ) ){ |
325 | 325 | // Make the title |
326 | 326 | $nt = $this->getTitle(); |
327 | | - $warning['file-thumbnail-no'] = substr( $filename, 0, |
| 327 | + $warnings['file-thumbnail-no'] = substr( $filename, 0, |
328 | 328 | strpos( $nt->getText() , '-' ) +1 ); |
329 | 329 | } |
330 | 330 | |
— | — | @@ -337,17 +337,17 @@ |
338 | 338 | unset( $dupes[$key] ); |
339 | 339 | } |
340 | 340 | if( $dupes ) |
341 | | - $warning['duplicate'] = $dupes; |
| 341 | + $warnings['duplicate'] = $dupes; |
342 | 342 | |
343 | 343 | // Check dupes against archives |
344 | 344 | $archivedImage = new ArchivedFile( null, 0, "{$hash}.{$this->mFinalExtension}" ); |
345 | 345 | if ( $archivedImage->getID() > 0 ) |
346 | | - $warning['duplicate-archive'] = $archivedImage->getName(); |
| 346 | + $warnings['duplicate-archive'] = $archivedImage->getName(); |
347 | 347 | |
348 | 348 | $filenamePrefixBlacklist = self::getFilenamePrefixBlacklist(); |
349 | 349 | foreach( $filenamePrefixBlacklist as $prefix ) { |
350 | 350 | if ( substr( $partname, 0, strlen( $prefix ) ) == $prefix ) { |
351 | | - $warning['filename-bad-prefix'] = $prefix; |
| 351 | + $warnings['filename-bad-prefix'] = $prefix; |
352 | 352 | break; |
353 | 353 | } |
354 | 354 | } |
— | — | @@ -355,9 +355,9 @@ |
356 | 356 | # If the file existed before and was deleted, warn the user of this |
357 | 357 | # Don't bother doing so if the file exists now, however |
358 | 358 | if( $localFile->wasDeleted() && !$localFile->exists() ) |
359 | | - $warning['filewasdeleted'] = $localFile->getTitle(); |
| 359 | + $warnings['filewasdeleted'] = $localFile->getTitle(); |
360 | 360 | |
361 | | - return $warning; |
| 361 | + return $warnings; |
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -242,14 +242,23 @@ |
243 | 243 | // Add indices |
244 | 244 | $this->getResult()->setIndexedTagName( $warnings, 'warning' ); |
245 | 245 | |
246 | | - if( isset( $warnings['duplicate'] ) ) |
247 | | - $this->getResult()->setIndexedTagName( $warnings['duplicate'], 'duplicate'); |
| 246 | + if( isset( $warnings['duplicate'] ) ) { |
| 247 | + $dupes = array(); |
| 248 | + foreach( $warnings['duplicate'] as $key => $dupe ) |
| 249 | + $dupes[] = $dupe->getName(); |
| 250 | + $this->getResult()->setIndexedTagName( $dupes, 'duplicate'); |
| 251 | + $warnings['duplicate'] = $dupes; |
| 252 | + } |
248 | 253 | |
249 | | - if( isset( $warnings['exists'] ) ) |
250 | | - $this->getResult()->setIndexedTagName( $warnings['exists'], 'exists' ); |
| 254 | + |
| 255 | + if( isset( $warnings['exists'] ) ) { |
| 256 | + $warning = $warnings['exists']; |
| 257 | + unset( $warnings['exists'] ); |
| 258 | + $warnings[$warning[0]] = $warning[1]->getName(); |
| 259 | + } |
251 | 260 | |
252 | 261 | if( isset( $warnings['filewasdeleted'] ) ) |
253 | | - $warnings['filewasdeleted'] = $warnings['filewasdeleted']->getDBkey(); |
| 262 | + $warnings['filewasdeleted'] = $warnings['filewasdeleted']->getName(); |
254 | 263 | |
255 | 264 | $result['result'] = 'Warning'; |
256 | 265 | $result['warnings'] = $warnings; |