* (bug 29174) Fix regression in upload-by-URL: files larger than PHP memory limit...
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 27 May 2011 22:31:48 +0000 (22:31 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 27 May 2011 22:31:48 +0000 (22:31 +0000)
commitc07ed424914ad7ab5500657687347d2bcf4225ce
treeaf3b90f7d5a4775909fc62ee9244e2132327e03f
parent7c81ffa5a1ac994c83c812aa194223396a022155
* (bug 29174) Fix regression in upload-by-URL: files larger than PHP memory limit work again

r65152 switched upload-by-URL ($wgAllowCopyUploads) to use Http / MwHttpRequest class instead of CURL directly.
While this is mostly nice, it switched from saving large files directly to a temp file to buffering them in memory, causing large files to fail when they hit the PHP memory limit.

Fix uses MwHttpRequest's callback capability to override the read handler; now appending it to the temporary file as we go, and can confirm that largish files work again; was able to upload a 64mb .ogv that previously didn't work for me: http://prototype.wikimedia.org/tmh/images/b/b2/File-Arborophila_brunneopectus_pair_feeding_-_Kaeng_Krachan.ogv

Also expanded the documentation on MwHttpRequest::setCallback to clarify the function parameters and return value for the callback (which currently matches the low-level CURL handler's callback directly).
Note that the non-CURL implementation doesn't abort the read if the callback doesn't return the expected number of bytes, but this is an immediate fatal end of request on the Curl backend. May want further cleanup.
includes/HttpFunctions.php
includes/upload/UploadFromUrl.php