Merge "Made SqlBagOStuff fully avoid transactions when possible"
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index 985de80..0700c49 100644 (file)
@@ -60,7 +60,7 @@ class SpecialUpload extends SpecialPage {
 
        /** User input variables from the root section **/
        public $mIgnoreWarning;
-       public $mWatchThis;
+       public $mWatchthis;
        public $mCopyrightStatus;
        public $mCopyrightSource;
 
@@ -75,8 +75,6 @@ class SpecialUpload extends SpecialPage {
        public $uploadFormTextTop;
        public $uploadFormTextAfterSummary;
 
-       public $mWatchthis;
-
        /**
         * Initialize instance variables from request and create an Upload handler
         */
@@ -221,6 +219,8 @@ class SpecialUpload extends SpecialPage {
         */
        protected function getUploadForm( $message = '', $sessionKey = '', $hideIgnoreWarning = false ) {
                # Initialize form
+               $context = new DerivativeContext( $this->getContext() );
+               $context->setTitle( $this->getTitle() ); // Remove subpage
                $form = new UploadForm( array(
                        'watch' => $this->getWatchCheck(),
                        'forreupload' => $this->mForReUpload,
@@ -232,8 +232,7 @@ class SpecialUpload extends SpecialPage {
                        'texttop' => $this->uploadFormTextTop,
                        'textaftersummary' => $this->uploadFormTextAfterSummary,
                        'destfile' => $this->mDesiredDestName,
-               ), $this->getContext() );
-               $form->setTitle( $this->getTitle() );
+               ), $context );
 
                # Check the token, but only if necessary
                if (
@@ -516,11 +515,17 @@ class SpecialUpload extends SpecialPage {
                        return true;
                }
 
+               $desiredTitleObj = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName );
+               if ( $desiredTitleObj instanceof Title && $this->getUser()->isWatched( $desiredTitleObj ) ) {
+                       // Already watched, don't change that
+                       return true;
+               }
+
                $local = wfLocalFile( $this->mDesiredDestName );
                if ( $local && $local->exists() ) {
                        // We're uploading a new version of an existing file.
                        // No creation, so don't watch it if we're not already.
-                       return $this->getUser()->isWatched( $local->getTitle() );
+                       return false;
                } else {
                        // New page should get watched if that's our option.
                        return $this->getUser()->getOption( 'watchcreations' );
@@ -570,8 +575,9 @@ class SpecialUpload extends SpecialPage {
                                } else {
                                        $msg->params( $details['finalExt'] );
                                }
-                               $msg->params( $this->getLanguage()->commaList( $wgFileExtensions ),
-                                       count( $wgFileExtensions ) );
+                               $extensions = array_unique( $wgFileExtensions );
+                               $msg->params( $this->getLanguage()->commaList( $extensions ),
+                                       count( $extensions ) );
 
                                // Add PLURAL support for the first parameter. This results
                                // in a bit unlogical parameter sequence, but does not break
@@ -810,7 +816,7 @@ class UploadForm extends HTMLForm {
                $this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize( 'file' );
                # Limit to upload_max_filesize unless we are running under HipHop and
                # that setting doesn't exist
-               if ( !wfIsHipHop() ) {
+               if ( !wfIsHHVM() ) {
                        $this->mMaxUploadSize['file'] = min( $this->mMaxUploadSize['file'],
                                wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ),
                                wfShorthandToInteger( ini_get( 'post_max_size' ) )
@@ -877,16 +883,16 @@ class UploadForm extends HTMLForm {
                                # Everything not permitted is banned
                                $extensionsList =
                                        '<div id="mw-upload-permitted">' .
-                                       $this->msg( 'upload-permitted', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) )->parseAsBlock() .
+                                       $this->msg( 'upload-permitted', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) )->parseAsBlock() .
                                        "</div>\n";
                        } else {
                                # We have to list both preferred and prohibited
                                $extensionsList =
                                        '<div id="mw-upload-preferred">' .
-                                               $this->msg( 'upload-preferred', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) )->parseAsBlock() .
+                                               $this->msg( 'upload-preferred', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) )->parseAsBlock() .
                                        "</div>\n" .
                                        '<div id="mw-upload-prohibited">' .
-                                               $this->msg( 'upload-prohibited', $this->getContext()->getLanguage()->commaList( $wgFileBlacklist ) )->parseAsBlock() .
+                                               $this->msg( 'upload-prohibited', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileBlacklist ) ) )->parseAsBlock() .
                                        "</div>\n";
                        }
                } else {
@@ -1009,7 +1015,7 @@ class UploadForm extends HTMLForm {
                                        'id' => 'wpWatchthis',
                                        'label-message' => 'watchthisupload',
                                        'section' => 'options',
-                                       'default' => $user->getOption( 'watchcreations' ),
+                                       'default' => $this->mWatch,
                                )
                        );
                }