Last modified: 2011-04-14 15:12:20 UTC
When testing a transwiki/interwiki import from Wikipedia to my local test wiki, I found i was getting this PHP error spewed out: <b>Warning</b>: file_get_contents(http://www.wikipedia.org/wiki/Special:Export/About?history=1) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.0 411 Length Required in <b>/opt/web/pages/trunk/includes/HttpFunctions.php</b> on line <b>83</b><br /> My local interwiki table was using www.wikipedia.org URLs, which return an HTTP 301 redirect. Note that the local wiki doesn't have CURL set up and is using the file_get_contents() path. A POST request is used for the import, I'm not 100% sure why. Unfortunately at least file_get_contents() doesn't seem to handle redirects properly. It follows the target URL, doing another POST, but apparently without all the headers. The Content-Length header, required for POSTs, is being lost, so the target server returns an HTTP server on the subrequest. Proper behavior would be to use a GET in the first place, or to resubmit at the new URL with the correct headers. HTTP 1.1 spec says a user-agent MUST NOT follow through a POST across a redirect without user confirmation; for this case the system's knowledge of wikis should be enough if we actually do it right though. ;) I'm not sure what happens in the CURL case, haven't tested.
Mass compoment change: <some> -> Export/Import