From f9c43d4c322e7162fe7dc7ba20ee695c811167c0 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Sat, 9 Jan 2010 20:17:54 +0000 Subject: [PATCH] Fix use of an array for no apparent reason. SpecialUpload::getExistsWarning now no longer encapsulates its results in
  • Further minor cleanup --- includes/specials/SpecialUpload.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index bbaa2c7088..2df3cea53c 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -315,7 +315,7 @@ class SpecialUpload extends SpecialPage { foreach( $warnings as $warning => $args ) { $msg = ''; if( $warning == 'exists' ) { - $msg = self::getExistsWarning( $args ); + $msg = "\t
  • " . self::getExistsWarning( $args ) . "
  • \n"; } elseif( $warning == 'duplicate' ) { $msg = self::getDupeWarning( $args ); } elseif( $warning == 'duplicate-archive' ) { @@ -323,7 +323,7 @@ class SpecialUpload extends SpecialPage { array( Title::makeTitle( NS_FILE, $args )->getPrefixedText() ) ) . "\n"; } else { - if ( is_bool( $args ) ) + if ( $args === true ) $args = array(); elseif ( !is_array( $args ) ) $args = array( $args ); @@ -569,7 +569,6 @@ class SpecialUpload extends SpecialPage { * * @param array $exists The result of UploadBase::getExistsWarning * @return string Empty string if there is no warning or an HTML fragment - * consisting of one or more
  • elements if there is a warning. */ public static function getExistsWarning( $exists ) { global $wgUser, $wgContLang; @@ -579,30 +578,30 @@ class SpecialUpload extends SpecialPage { $file = $exists['file']; $filename = $file->getTitle()->getPrefixedText(); - $warning = array(); + $warning = ''; $sk = $wgUser->getSkin(); if( $exists['warning'] == 'exists' ) { // Exact match - $warning[] = '
  • ' . wfMsgExt( 'fileexists', 'parseinline', $filename ) . '
  • '; + $warning = wfMsgExt( 'fileexists', 'parseinline', $filename ); } elseif( $exists['warning'] == 'page-exists' ) { // Page exists but file does not - $warning[] = '
  • ' . wfMsgExt( 'filepageexists', 'parseinline', $filename ) . '
  • '; + $warning = wfMsgExt( 'filepageexists', 'parseinline', $filename ); } elseif ( $exists['warning'] == 'exists-normalized' ) { - $warning[] = '
  • ' . wfMsgExt( 'fileexists-extension', 'parseinline', $filename, - $exists['normalizedFile']->getTitle()->getPrefixedText() ) . '
  • '; + $warning = wfMsgExt( 'fileexists-extension', 'parseinline', $filename, + $exists['normalizedFile']->getTitle()->getPrefixedText() ); } elseif ( $exists['warning'] == 'thumb' ) { // Swapped argument order compared with other messages for backwards compatibility - $warning[] = '
  • ' . wfMsgExt( 'fileexists-thumbnail-yes', 'parseinline', - $exists['thumbFile']->getTitle()->getPrefixedText(), $filename ) . '
  • '; + $warning = wfMsgExt( 'fileexists-thumbnail-yes', 'parseinline', + $exists['thumbFile']->getTitle()->getPrefixedText(), $filename ); } elseif ( $exists['warning'] == 'thumb-name' ) { // Image w/o '180px-' does not exists, but we do not like these filenames $name = $file->getName(); $badPart = substr( $name, 0, strpos( $name, '-' ) + 1 ); - $warning[] = '
  • ' . wfMsgExt( 'file-thumbnail-no', 'parseinline', $badPart ) . '
  • '; + $warning = wfMsgExt( 'file-thumbnail-no', 'parseinline', $badPart ); } elseif ( $exists['warning'] == 'bad-prefix' ) { - $warning[] = '
  • ' . wfMsgExt( 'filename-bad-prefix', 'parseinline', $exists['prefix'] ) . '
  • '; + $warning = wfMsgExt( 'filename-bad-prefix', 'parseinline', $exists['prefix'] ); } elseif ( $exists['warning'] == 'was-deleted' ) { # If the file existed before and was deleted, warn the user of this $ltitle = SpecialPage::getTitleFor( 'Log' ); @@ -615,10 +614,10 @@ class SpecialUpload extends SpecialPage { 'page' => $filename ) ); - $warning[] = '
  • ' . wfMsgWikiHtml( 'filewasdeleted', $llink ) . '
  • '; + $warning = wfMsgWikiHtml( 'filewasdeleted', $llink ); } - return implode( "\n", $warning ); + return $warning; } /** @@ -639,7 +638,7 @@ class SpecialUpload extends SpecialPage { $exists = UploadBase::getExistsWarning( $file ); $warning = self::getExistsWarning( $exists ); if ( $warning !== '' ) { - $s = ""; + $s = "
    $warning
    "; } } return $s; -- 2.20.1