From 323c3a6e712077252e53a5a2ebead5a72f9a00fa Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 26 Aug 2008 20:07:53 +0000 Subject: [PATCH] * In Article::replaceSection(), actually return null when $section is bogus. Used this in my half-complete and now kind of abandoned attempt at rewriting EditPage.php * In UserMailer::send(), allow the caller to override the Content-type header so people can send multipart messages if they really want to. Using this in an extension I'm developing --- includes/Article.php | 3 +++ includes/UserMailer.php | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 560c1d3067..aef565cb0f 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1288,6 +1288,9 @@ class Article { # Replacing an existing section; roll out the big guns global $wgParser; $text = $wgParser->replaceSection( $oldtext, $section, $text ); + # If $section is bogus, replaceSection() will be a no-op + if($text == $oldtext) + return null; } } diff --git a/includes/UserMailer.php b/includes/UserMailer.php index ad550dc3b4..436b1e48b5 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -98,9 +98,10 @@ class UserMailer { * @param $subject String: email's subject. * @param $body String: email's text. * @param $replyto String: optional reply-to email (default: null). + * @param $contentType String: optional custom Content-Type * @return mixed True on success, a WikiError object on failure. */ - static function send( $to, $from, $subject, $body, $replyto=null ) { + static function send( $to, $from, $subject, $body, $replyto=null, $contentType=null ) { global $wgSMTP, $wgOutputEncoding, $wgErrorString, $wgEnotifImpersonal; global $wgEnotifMaxRecips; @@ -139,7 +140,12 @@ class UserMailer { $headers['Subject'] = wfQuotedPrintable( $subject ); $headers['Date'] = date( 'r' ); $headers['MIME-Version'] = '1.0'; - $headers['Content-type'] = 'text/plain; charset='.$wgOutputEncoding; + $headers['Content-type'] = (is_null($contentType) ? + 'text/plain; charset='.$wgOutputEncoding : $contentType); + if(is_null($contentType)) + $headers['Content-type'] = 'text/plain; charset='.$wgOutputEncoding; + else + $headers['Content-type'] = $contentType; $headers['Content-transfer-encoding'] = '8bit'; $headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>'; // FIXME $headers['X-Mailer'] = 'MediaWiki mailer'; @@ -170,9 +176,11 @@ class UserMailer { } else { $endl = "\n"; } + $ctype = (is_null($contentType) ? + 'text/plain; charset='.$wgOutputEncoding : $contentType); $headers = "MIME-Version: 1.0$endl" . - "Content-type: text/plain; charset={$wgOutputEncoding}$endl" . + "Content-type: $ctype$endl" . "Content-Transfer-Encoding: 8bit$endl" . "X-Mailer: MediaWiki mailer$endl". 'From: ' . $from->toString(); -- 2.20.1