r17478 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17477‎ | r17478 | r17479 >
Date:03:28, 8 November 2006
Author:nickj
Status:old
Tags:
Comment:
(bug 7820) Improve error reporting for uploads via URL. Patch by Simetrical.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialUpload.php
@@ -126,7 +126,7 @@
127127 * Returns true if there was an error, false otherwise
128128 */
129129 private function curlCopy( $url, $dest ) {
130 - global $wgMaxUploadSize, $wgUser;
 130+ global $wgMaxUploadSize, $wgUser, $wgOut;
131131
132132 if( !$wgUser->isAllowed( 'upload_by_url' ) ) {
133133 $wgOut->permissionRequired( 'upload_by_url' );
@@ -137,6 +137,7 @@
138138 $url = trim( $url );
139139 if( stripos($url, 'http://') !== 0 && stripos($url, 'ftp://') !== 0 ) {
140140 # Only HTTP or FTP URLs
 141+ $wgOut->errorPage( 'upload-proto-error', 'upload-proto-error-text' );
141142 return true;
142143 }
143144
@@ -144,6 +145,7 @@
145146 $this->mUploadTempFile = @fopen( $this->mUploadTempName, "wb" );
146147 if( $this->mUploadTempFile === false ) {
147148 # Could not open temporary file to write in
 149+ $wgOut->errorPage( 'upload-file-error', 'upload-file-error-text');
148150 return true;
149151 }
150152
@@ -155,13 +157,18 @@
156158 curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'uploadCurlCallback' ) );
157159 curl_exec( $ch );
158160 $error = curl_errno( $ch ) ? true : false;
159 -# if ( $error ) print curl_error ( $ch ) ; # Debugging output
 161+ $errornum = curl_errno( $ch );
 162+ // if ( $error ) print curl_error ( $ch ) ; # Debugging output
160163 curl_close( $ch );
161164
162165 fclose( $this->mUploadTempFile );
163166 unset( $this->mUploadTempFile );
164167 if( $error ) {
165168 unlink( $dest );
 169+ if( wfEmptyMsg( "upload-curl-error$errornum", wfMsg("upload-curl-error$errornum") ) )
 170+ $wgOut->errorPage( 'upload-misc-error', 'upload-misc-error-text' );
 171+ else
 172+ $wgOut->errorPage( "upload-curl-error$errornum", "upload-curl-error$errornum-text" );
166173 }
167174
168175 return $error;
Index: trunk/phase3/RELEASE-NOTES
@@ -125,7 +125,7 @@
126126 * Remove entries from redirect table on article deletion
127127 * (bug 7788) Force section headers in new section links for users who have
128128 'prompt for blank edit summaries' on.
129 -* (bug 1133) Special:Emailuser: add an option to send yourself a copy your mail.
 129+* (bug 1133) Special:Emailuser: add an option to send yourself a copy of your mail.
130130 * (bug 461) Allow "Categories:" link at bottom of pages to be customized via
131131 pagecategorieslink message.
132132 * Sort the list of skins in "My Preferences" -> Skins by alphabetical order.
@@ -152,7 +152,9 @@
153153 * (bug 5365) Stop users being prompted to enter an edit summary for null edits,
154154 if they have selected that option in preferences.
155155 * (bug 5936) Show an 'm' to the left of the edit summary on diff pages for minor edits.
 156+* (bug 7820) Improve error reporting for uploads via URL.
156157
 158+
157159 == Languages updated ==
158160
159161 * Bishnupriya Manipuri (bpy)
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1283,6 +1283,18 @@
12841284 'watchthisupload' => 'Watch this page',
12851285 'filewasdeleted' => 'A file of this name has been previously uploaded and subsequently deleted. You should check the $1 before proceeding to upload it again.',
12861286
 1287+'upload-proto-error' => 'Incorrect protocol',
 1288+'upload-proto-error-text' => 'Remote upload requires URLs beginning with <code>http://</code> or <code>ftp://</code>.',
 1289+'upload-file-error' => 'Internal error',
 1290+'upload-file-error-text' => 'An internal error occurred when attempting to create a temporary file on the server. Please contact a system administrator.',
 1291+'upload-misc-error' => 'Unknown upload error',
 1292+'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.',
 1293+# Some likely curl errors. More could be added from <http://curl.haxx.se/libcurl/c/libcurl-errors.html>
 1294+'upload-curl-error6' => "Couldn't reach URL",
 1295+'upload-curl-error6-text' => 'The URL provided could not be reached. Please double-check that the URL is correct and the site is up.',
 1296+'upload-curl-error28' => 'Upload timeout',
 1297+'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.',
 1298+
12871299 'license' => 'Licensing',
12881300 'nolicense' => 'None selected',
12891301 'licenses' => '-', # Don't duplicate this in translations