Fixed severe breakage of non-JS upload, presumably introduced in the 1.16 upload...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 27 May 2010 07:30:34 +0000 (07:30 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 27 May 2010 07:30:34 +0000 (07:30 +0000)
Apologies for the nodata hack, but I want to backport this to 1.16, so I don't want to make any HTMLForm.php changes if I can avoid it.

includes/specials/SpecialUpload.php
includes/upload/UploadFromFile.php

index 33ed9f5..cba2851 100644 (file)
@@ -67,8 +67,8 @@ class SpecialUpload extends SpecialPage {
 
                // Guess the desired name from the filename if not provided
                $this->mDesiredDestName   = $request->getText( 'wpDestFile' );
-               if( !$this->mDesiredDestName ) {
-                       $this->mDesiredDestName = $request->getText( 'wpUploadFile' );
+               if( !$this->mDesiredDestName && $request->getFileName( 'wpUploadFile' ) !== null ) {
+                       $this->mDesiredDestName = $request->getFileName( 'wpUploadFile' );
                }
                $this->mComment           = $request->getText( 'wpUploadDescription' );
                $this->mLicense           = $request->getText( 'wpLicense' );
@@ -226,6 +226,7 @@ class SpecialUpload extends SpecialPage {
 
                        'texttop' => $this->uploadFormTextTop,
                        'textaftersummary' => $this->uploadFormTextAfterSummary,
+                       'destfile' => $this->mDesiredDestName,
                ) );
                $form->setTitle( $this->getTitle() );
 
@@ -718,6 +719,7 @@ class UploadForm extends HTMLForm {
        protected $mSessionKey;
        protected $mHideIgnoreWarning;
        protected $mDestWarningAck;
+       protected $mDestFile;
 
        protected $mTextTop;
        protected $mTextAfterSummary;
@@ -731,6 +733,7 @@ class UploadForm extends HTMLForm {
                                ? $options['sessionkey'] : '';
                $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] );
                $this->mDestWarningAck = !empty( $options['destwarningack'] );
+               $this->mDestFile = isset( $options['destfile'] ) ? $options['destfile'] : '';
 
                $this->mTextTop = isset( $options['texttop'] )
                        ? $options['texttop'] : '';
@@ -903,6 +906,9 @@ class UploadForm extends HTMLForm {
                                'id' => 'wpDestFile',
                                'label-message' => 'destfilename',
                                'size' => 60,
+                               'default' => $this->mDestFile,
+                               # FIXME: hack to work around poor handling of the 'default' option in HTMLForm
+                               'nodata' => strval( $this->mDestFile ) !== '',
                        ),
                        'UploadDescription' => array(
                                'type' => 'textarea',
index 28b514d..73581a6 100644 (file)
@@ -13,7 +13,7 @@ class UploadFromFile extends UploadBase {
        function initializeFromRequest( &$request ) {
                $desiredDestName = $request->getText( 'wpDestFile' );
                if( !$desiredDestName )
-                       $desiredDestName = $request->getText( 'wpUploadFile' );
+                       $desiredDestName = $request->getFileName( 'wpUploadFile' );
                return $this->initializePathInfo(
                        $desiredDestName,
                        $request->getFileTempName( 'wpUploadFile' ),