r40042 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40041‎ | r40042 | r40043 >
Date:20:07, 26 August 2008
Author:catrope
Status:old
Tags:
Comment:
* 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
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1288,6 +1288,9 @@
12891289 # Replacing an existing section; roll out the big guns
12901290 global $wgParser;
12911291 $text = $wgParser->replaceSection( $oldtext, $section, $text );
 1292+ # If $section is bogus, replaceSection() will be a no-op
 1293+ if($text == $oldtext)
 1294+ return null;
12921295 }
12931296
12941297 }
Index: trunk/phase3/includes/UserMailer.php
@@ -98,9 +98,10 @@
9999 * @param $subject String: email's subject.
100100 * @param $body String: email's text.
101101 * @param $replyto String: optional reply-to email (default: null).
 102+ * @param $contentType String: optional custom Content-Type
102103 * @return mixed True on success, a WikiError object on failure.
103104 */
104 - static function send( $to, $from, $subject, $body, $replyto=null ) {
 105+ static function send( $to, $from, $subject, $body, $replyto=null, $contentType=null ) {
105106 global $wgSMTP, $wgOutputEncoding, $wgErrorString, $wgEnotifImpersonal;
106107 global $wgEnotifMaxRecips;
107108
@@ -139,7 +140,12 @@
140141 $headers['Subject'] = wfQuotedPrintable( $subject );
141142 $headers['Date'] = date( 'r' );
142143 $headers['MIME-Version'] = '1.0';
143 - $headers['Content-type'] = 'text/plain; charset='.$wgOutputEncoding;
 144+ $headers['Content-type'] = (is_null($contentType) ?
 145+ 'text/plain; charset='.$wgOutputEncoding : $contentType);
 146+ if(is_null($contentType))
 147+ $headers['Content-type'] = 'text/plain; charset='.$wgOutputEncoding;
 148+ else
 149+ $headers['Content-type'] = $contentType;
144150 $headers['Content-transfer-encoding'] = '8bit';
145151 $headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>'; // FIXME
146152 $headers['X-Mailer'] = 'MediaWiki mailer';
@@ -170,9 +176,11 @@
171177 } else {
172178 $endl = "\n";
173179 }
 180+ $ctype = (is_null($contentType) ?
 181+ 'text/plain; charset='.$wgOutputEncoding : $contentType);
174182 $headers =
175183 "MIME-Version: 1.0$endl" .
176 - "Content-type: text/plain; charset={$wgOutputEncoding}$endl" .
 184+ "Content-type: $ctype$endl" .
177185 "Content-Transfer-Encoding: 8bit$endl" .
178186 "X-Mailer: MediaWiki mailer$endl".
179187 'From: ' . $from->toString();

Follow-up revisions

RevisionCommit summaryAuthorDate
r40107Revert r40042 "* In Article::replaceSection(), actually return null when $sec...brion21:12, 27 August 2008
r40108Revert part of r40107 (Revert r40042 because of regressions). The changes to ...catrope21:15, 27 August 2008

Status & tagging log