Page MenuHomePhabricator

Upload by URL regression: file size limited by PHP memory limit ($wgAllowCopyUploads)
Closed, ResolvedPublic

Description

Upload-by-URL originally used CURL directly and I think wrote directly to a temporary file, making it suitable for files of any size (unless too big for a 32-bit version of CURL to handle!)

Since r65152 it was switched to use the MWHttpRequest class, which buffers file content into memory.

Uploading a ~64mb webm file while testing TimedMediaHandler, I got this gem:

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 66634174 bytes) in /var/www/trunk/includes/upload/UploadFromUrl.php on line 118, referer: http://stormcloud.local/trunk/index.php/Special:Upload

That's:

file_put_contents( $this->mTempPath, $req->getContent()

D'oh!

Needs to use read callbacks to save directly to the temporary file. Looks like this can be done fairly straightforwardly by calling $req->setCallback() and passing it a method to append a chunk to the temp file.


Version: 1.20.x
Severity: normal

Details

Reference
bz29174

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 21 2014, 11:32 PM
bzimport set Reference to bz29174.

Since I'm sitting in front of it, I'll do the fix. :)

Gilles triaged this task as Unbreak Now! priority.Dec 4 2014, 10:10 AM
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to Needs Triage.Dec 4 2014, 11:22 AM