r65716 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65715‎ | r65716 | r65717 >
Date:21:57, 30 April 2010
Author:platonides
Status:ok
Tags:
Comment:
No MaxSem, you can't revert r65715 on r65716. Use a class variable instead of a global variable for passing the error from the error handler to user code.
Modified paths:
  • /trunk/phase3/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/UserMailer.php
@@ -75,6 +75,8 @@
7676 * Collection of static functions for sending mail
7777 */
7878 class UserMailer {
 79+ static $mErrorString;
 80+
7981 /**
8082 * Send mail using a PEAR mailer
8183 */
@@ -106,7 +108,7 @@
107109 * @return mixed True on success, a WikiError object on failure.
108110 */
109111 static function send( $to, $from, $subject, $body, $replyto=null, $contentType=null ) {
110 - global $wgSMTP, $wgOutputEncoding, $wgErrorString, $wgEnotifImpersonal;
 112+ global $wgSMTP, $wgOutputEncoding, $wgEnotifImpersonal;
111113 global $wgEnotifMaxRecips;
112114
113115 if ( is_array( $to ) ) {
@@ -190,7 +192,7 @@
191193
192194 wfDebug( "Sending mail via internal mail() function\n" );
193195
194 - $wgErrorString = '';
 196+ self::$mErrorString = '';
195197 $html_errors = ini_get( 'html_errors' );
196198 ini_set( 'html_errors', '0' );
197199 set_error_handler( array( 'UserMailer', 'errorHandler' ) );
@@ -204,19 +206,19 @@
205207 $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers );
206208 }
207209 } else {
208 - $wgErrorString = 'PHP is not configured to send mail';
 210+ self::$mErrorString = 'PHP is not configured to send mail';
209211 }
210212
211213 restore_error_handler();
212214 ini_set( 'html_errors', $html_errors );
213215
214 - if ( $wgErrorString ) {
215 - wfDebug( "Error sending mail: $wgErrorString\n" );
216 - return new WikiError( $wgErrorString );
217 - } elseif (! $sent) {
 216+ if ( self::$mErrorString ) {
 217+ wfDebug( "Error sending mail: " . self::$mErrorString . "\n" );
 218+ return new WikiError( self::$mErrorString );
 219+ } elseif (! $sent ) {
218220 //mail function only tells if there's an error
219221 wfDebug( "Error sending mail\n" );
220 - return new WikiError( 'mailer error' );
 222+ return new WikiError( 'mail() failed' );
221223 } else {
222224 return true;
223225 }
@@ -224,14 +226,13 @@
225227 }
226228
227229 /**
228 - * Get the mail error message in global $wgErrorString
 230+ * Set the mail error message in self::$mErrorString
229231 *
230232 * @param $code Integer: error number
231233 * @param $string String: error message
232234 */
233235 static function errorHandler( $code, $string ) {
234 - global $wgErrorString;
235 - $wgErrorString = preg_replace( '/^mail\(\)(\s*\[.*?\])?: /', '', $string );
 236+ self::$mErrorString = preg_replace( '/^mail\(\)(\s*\[.*?\])?: /', '', $string );
236237 }
237238
238239 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r65715Initial commit of the Selenium frameworklaner20:45, 30 April 2010

Status & tagging log