r66944 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66943‎ | r66944 | r66945 >
Date:07:30, 27 May 2010
Author:tstarling
Status:ok
Tags:
Comment:
Fixed severe breakage of non-JS upload, presumably introduced in the 1.16 upload rewrite. If the user doesn't enter a destination filename, it's meant to use the name of the source file. Untested code "$wgRequest->getText('wpUploadFile')" did not work, you need to fetch from $_FILES not $_REQUEST. Code to propagate the relevant default to UploadForm was missing, readded here.

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.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialUpload.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadFromFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/upload/UploadFromFile.php
@@ -13,7 +13,7 @@
1414 function initializeFromRequest( &$request ) {
1515 $desiredDestName = $request->getText( 'wpDestFile' );
1616 if( !$desiredDestName )
17 - $desiredDestName = $request->getText( 'wpUploadFile' );
 17+ $desiredDestName = $request->getFileName( 'wpUploadFile' );
1818 return $this->initializePathInfo(
1919 $desiredDestName,
2020 $request->getFileTempName( 'wpUploadFile' ),
Index: trunk/phase3/includes/specials/SpecialUpload.php
@@ -67,8 +67,8 @@
6868
6969 // Guess the desired name from the filename if not provided
7070 $this->mDesiredDestName = $request->getText( 'wpDestFile' );
71 - if( !$this->mDesiredDestName ) {
72 - $this->mDesiredDestName = $request->getText( 'wpUploadFile' );
 71+ if( !$this->mDesiredDestName && $request->getFileName( 'wpUploadFile' ) !== null ) {
 72+ $this->mDesiredDestName = $request->getFileName( 'wpUploadFile' );
7373 }
7474 $this->mComment = $request->getText( 'wpUploadDescription' );
7575 $this->mLicense = $request->getText( 'wpLicense' );
@@ -226,6 +226,7 @@
227227
228228 'texttop' => $this->uploadFormTextTop,
229229 'textaftersummary' => $this->uploadFormTextAfterSummary,
 230+ 'destfile' => $this->mDesiredDestName,
230231 ) );
231232 $form->setTitle( $this->getTitle() );
232233
@@ -718,6 +719,7 @@
719720 protected $mSessionKey;
720721 protected $mHideIgnoreWarning;
721722 protected $mDestWarningAck;
 723+ protected $mDestFile;
722724
723725 protected $mTextTop;
724726 protected $mTextAfterSummary;
@@ -731,6 +733,7 @@
732734 ? $options['sessionkey'] : '';
733735 $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] );
734736 $this->mDestWarningAck = !empty( $options['destwarningack'] );
 737+ $this->mDestFile = isset( $options['destfile'] ) ? $options['destfile'] : '';
735738
736739 $this->mTextTop = isset( $options['texttop'] )
737740 ? $options['texttop'] : '';
@@ -903,6 +906,9 @@
904907 'id' => 'wpDestFile',
905908 'label-message' => 'destfilename',
906909 'size' => 60,
 910+ 'default' => $this->mDestFile,
 911+ # FIXME: hack to work around poor handling of the 'default' option in HTMLForm
 912+ 'nodata' => strval( $this->mDestFile ) !== '',
907913 ),
908914 'UploadDescription' => array(
909915 'type' => 'textarea',

Follow-up revisions

RevisionCommit summaryAuthorDate
r66989MFT r66944: fixed non-JS uploads, were totally broken due to the lack of a de...tstarling04:52, 28 May 2010

Status & tagging log