(bug 7820) Improve error reporting for uploads via URL. Patch by Simetrical.
authorNick Jenkins <nickj@users.mediawiki.org>
Wed, 8 Nov 2006 03:28:54 +0000 (03:28 +0000)
committerNick Jenkins <nickj@users.mediawiki.org>
Wed, 8 Nov 2006 03:28:54 +0000 (03:28 +0000)
RELEASE-NOTES
includes/SpecialUpload.php
languages/messages/MessagesEn.php

index bbcad12..8d62530 100644 (file)
@@ -125,7 +125,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Remove entries from redirect table on article deletion
 * (bug 7788) Force section headers in new section links for users who have
   'prompt for blank edit summaries' on.
-* (bug 1133) Special:Emailuser: add an option to send yourself a copy your mail.
+* (bug 1133) Special:Emailuser: add an option to send yourself a copy of your mail.
 * (bug 461) Allow "Categories:" link at bottom of pages to be customized via
   pagecategorieslink message.
 * Sort the list of skins in "My Preferences" -> Skins by alphabetical order.
@@ -152,6 +152,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 5365) Stop users being prompted to enter an edit summary for null edits,
   if they have selected that option in preferences.
 * (bug 5936) Show an 'm' to the left of the edit summary on diff pages for minor edits.
+* (bug 7820) Improve error reporting for uploads via URL.
+
 
 == Languages updated ==
 
index c91f910..768c14f 100644 (file)
@@ -126,7 +126,7 @@ class UploadForm {
         * Returns true if there was an error, false otherwise
         */
        private function curlCopy( $url, $dest ) {
-               global $wgMaxUploadSize, $wgUser;
+               global $wgMaxUploadSize, $wgUser, $wgOut;
 
                if( !$wgUser->isAllowed( 'upload_by_url' ) ) {
                        $wgOut->permissionRequired( 'upload_by_url' );
@@ -137,6 +137,7 @@ class UploadForm {
                $url =  trim( $url );
                if( stripos($url, 'http://') !== 0 && stripos($url, 'ftp://') !== 0 ) {
                        # Only HTTP or FTP URLs
+                       $wgOut->errorPage( 'upload-proto-error', 'upload-proto-error-text' );
                        return true;
                }
 
@@ -144,6 +145,7 @@ class UploadForm {
                $this->mUploadTempFile = @fopen( $this->mUploadTempName, "wb" );
                if( $this->mUploadTempFile === false ) {
                        # Could not open temporary file to write in
+                       $wgOut->errorPage( 'upload-file-error', 'upload-file-error-text');
                        return true;
                }
                
@@ -155,13 +157,18 @@ class UploadForm {
                curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'uploadCurlCallback' ) );
                curl_exec( $ch );
                $error = curl_errno( $ch ) ? true : false;
-#              if ( $error ) print curl_error ( $ch ) ; # Debugging output
+               $errornum =  curl_errno( $ch );
+               // if ( $error ) print curl_error ( $ch ) ; # Debugging output
                curl_close( $ch );
                
                fclose( $this->mUploadTempFile );
                unset( $this->mUploadTempFile );
                if( $error ) {
                        unlink( $dest );
+                       if( wfEmptyMsg( "upload-curl-error$errornum", wfMsg("upload-curl-error$errornum") ) )
+                               $wgOut->errorPage( 'upload-misc-error', 'upload-misc-error-text' );
+                       else
+                               $wgOut->errorPage( "upload-curl-error$errornum", "upload-curl-error$errornum-text" );
                }
                
                return $error;
index dd11ec5..4a3d8d3 100644 (file)
@@ -1283,6 +1283,18 @@ created and by whom, and anything else you may know about it. If this is an imag
 'watchthisupload'      => 'Watch this page',
 'filewasdeleted' => 'A file of this name has been previously uploaded and subsequently deleted. You should check the $1 before proceeding to upload it again.',
 
+'upload-proto-error' => 'Incorrect protocol',
+'upload-proto-error-text' => 'Remote upload requires URLs beginning with <code>http://</code> or <code>ftp://</code>.',
+'upload-file-error' => 'Internal error',
+'upload-file-error-text' => 'An internal error occurred when attempting to create a temporary file on the server.  Please contact a system administrator.',
+'upload-misc-error' => 'Unknown upload error',
+'upload-misc-error-text' => 'An unknown error occurred during the upload.  Please verify that the URL is valid and accessible and try again.  If the problem persists, contact a system administrator.',
+# Some likely curl errors.  More could be added from <http://curl.haxx.se/libcurl/c/libcurl-errors.html>
+'upload-curl-error6' => "Couldn't reach URL",
+'upload-curl-error6-text' => 'The URL provided could not be reached.  Please double-check that the URL is correct and the site is up.',
+'upload-curl-error28' => 'Upload timeout',
+'upload-curl-error28-text' => 'The site took too long to respond. Please check the site is up, wait a short while and try again. You may want to try at a less busy time.',
+
 'license' => 'Licensing',
 'nolicense' => 'None selected',
 'licenses' => '-', # Don't duplicate this in translations