Makes sure wgAdditionalMailParams is null in safe mode
authorAntoine Musso <hashar@users.mediawiki.org>
Wed, 18 May 2011 20:28:44 +0000 (20:28 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Wed, 18 May 2011 20:28:44 +0000 (20:28 +0000)
The global is used for a call to PHP mail() function as a way to add
additional parameters.  This will cause mail() to send E_NOTICE when
using safe mode.

Since we could use the global at different places, it makes sens to
ensure it has a sane value through Setup.php

Follow up r75557

includes/Setup.php
includes/UserMailer.php

index 3ff6eba..2cd6b0a 100644 (file)
@@ -447,6 +447,12 @@ $wgArticle = null;
 
 $wgDeferredUpdateList = array();
 
+// We need to check for safe_mode, because mail() willl throws an E_NOTICE
+// on additional parameters
+if( !is_null($wgAdditionalMailParams) && wgIniGetBool('safe_mode') ) {
+       $wgAdditionalMailParams = null;
+}
+
 wfProfileOut( $fname . '-globals' );
 wfProfileIn( $fname . '-extensions' );
 
index 0798c32..fd91d5b 100644 (file)
@@ -221,19 +221,11 @@ class UserMailer {
                        ini_set( 'html_errors', '0' );
                        set_error_handler( array( 'UserMailer', 'errorHandler' ) );
 
-                       // We need to check for safe_mode, because mail() throws an E_NOTICE
-                       // on the 5th parameter when it's turned on
-                       $sm = wfIniGetBool( 'safe_mode' );
-
                        if ( !is_array( $to ) ) {
                                $to = array( $to );
                        }
                        foreach ( $to as $recip ) {
-                               if( $sm ) {
-                                       $sent = mail( $recip->toString(), self::quotedPrintable( $subject ), $body, $headers );
-                               } else {
-                                       $sent = mail( $recip->toString(), self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
-                               }
+                               $sent = mail( $recip->toString(), self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
                        }
 
                        restore_error_handler();