From 29caa1fdb72ac4f7e021f0588ccb5e0b8323a4e5 Mon Sep 17 00:00:00 2001 From: Nick Jenkins Date: Wed, 8 Nov 2006 03:28:54 +0000 Subject: [PATCH] (bug 7820) Improve error reporting for uploads via URL. Patch by Simetrical. --- RELEASE-NOTES | 4 +++- includes/SpecialUpload.php | 11 +++++++++-- languages/messages/MessagesEn.php | 12 ++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index bbcad12c1e..8d62530801 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index c91f9101e1..768c14fd7a 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -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; diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index dd11ec5a8a..4a3d8d3ba7 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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 http:// or ftp://.', +'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 +'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 -- 2.20.1