Last modified: 2011-09-22 01:15:28 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T31154, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 29154 - Upload by URL doesn't handle HTTP redirects
Upload by URL doesn't handle HTTP redirects
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Uploading (Other open bugs)
1.20.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-26 18:33 UTC by Brion Vibber
Modified: 2011-09-22 01:15 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Brion Vibber 2011-05-26 18:33:34 UTC
While testing bug 29147, I noticed that the upload-by-URL handling doesn't seem to handle HTTP 302 redirects, at least for large files.

A direct link to this Fedora ISO download chugs through for a while before predictably timing out:

  http://fedora.mirror.lstn.net/releases/15/Fedora/x86_64/iso/Fedora-15-x86_64-DVD.iso

  "Error fetching URL: Operation timed out after 25000 milliseconds with 62264250 out of 3596310528 bytes received"


But if I copy this redirect link from Fedora's download page, it immediately gives an 'empty file' error:

  http://download.fedoraproject.org/pub/fedora/linux/releases/15/Fedora/x86_64/iso/Fedora-15-x86_64-DVD.iso

  "The file you uploaded seems to be empty. This might be due to a typo in the file name. Please check whether you really want to upload this file."


Inspecting the MWHttpRequest result shows that it's found the 302 redirect, but doesn't seem to have followed it.

Link found from http://fedoraproject.org/en/get-fedora-all
Comment 1 Derk-Jan Hartman 2011-05-27 11:40:01 UTC
I think this would do the trick ?


Index: upload/UploadFromUrl.php
===================================================================
--- upload/UploadFromUrl.php (revision 88965)
+++ upload/UploadFromUrl.php (working copy)
@@ -128,7 +128,8 @@
   * size and set $mRemoveTempFile to true.
   */
  protected function reallyFetchFile() {
-  $req = MWHttpRequest::factory( $this->mUrl );
+  $options = array( 'followRedirects' => true );
+  $req = MWHttpRequest::factory( $this->mUrl, $options );
   $status = $req->execute();
 
   if ( !$status->isOk() ) {
Comment 2 Bryan Tong Minh 2011-05-27 12:03:01 UTC
I'd think so. We need to set a limit to the maximum number of redirects though.
Comment 3 Derk-Jan Hartman 2011-05-27 12:28:30 UTC
*    - maxRedirects        Maximum number of redirects to follow (defaults to 5)
Comment 4 Bryan Tong Minh 2011-05-27 14:28:55 UTC
5 sounds reasonable.
Comment 5 Bawolff (Brian Wolff) 2011-05-28 02:54:39 UTC
Why doesn't MWHttpRequest follow redirects by default? It seems like it'd be very rare that you would not want it to.
Comment 6 db [inactive,noenotif] 2011-05-28 21:44:58 UTC
(In reply to comment #5)
> Why doesn't MWHttpRequest follow redirects by default? It seems like it'd be
> very rare that you would not want it to.

see r67684
Comment 7 Brion Vibber 2011-09-22 01:15:28 UTC
Done in r97777 roughly as in comment 1 :)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links