r93415 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93414‎ | r93415 | r93416 >
Date:19:19, 28 July 2011
Author:mah
Status:resolved (Comments)
Tags:
Comment:
Add hook that could be the solution for Bug #28026 (“Enable e-mail
notifications for watchlist (EnotifWatchlist) on all small wikis”) to
make logging sent emails easier.
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -295,6 +295,15 @@
296296 on &action=edit.
297297 $EditPage: the EditPage object
298298
 299+'AlternateUserMailer': Called before mail is sent so that mail could
 300+be logged (or something else) instead of using PEAR or SMTP
 301+$UserMailer: the EditPage object
 302+$headers: Associative array of headers for the email
 303+$to: MailAddress object or array
 304+$from: From address
 305+$subject: Subject of the email
 306+$body: Body of the message
 307+
299308 'APIAfterExecute': after calling the execute() method of an API module.
300309 Use this to extend core API modules.
301310 &$module: Module object
Index: trunk/phase3/includes/UserMailer.php
@@ -180,6 +180,13 @@
181181 $headers['X-Mailer'] = 'MediaWiki mailer';
182182 $headers['From'] = $from->toString();
183183
 184+ $ret = wfRunHooks( 'AlternateUserMailer', array( $this, $headers, $to, $from, $subject, $body, $replyto, $contentType ) ) ) {
 185+ if ( $ret === false ) {
 186+ return Status::newGood();
 187+ } else if ( $ret != true ) {
 188+ return Status::newFatal( 'php-mail-error', $ret );
 189+ }
 190+
184191 if ( is_array( $wgSMTP ) ) {
185192 if ( function_exists( 'stream_resolve_include_path' ) ) {
186193 $found = stream_resolve_include_path( 'Mail.php' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r93418wtf, who made this typo?mah19:44, 28 July 2011
r93444followup r93415 — there is no “$this” in a static method.mah01:15, 29 July 2011
r93777re: r93415...mah19:35, 2 August 2011

Comments

#Comment by Reedy (talk | contribs)   22:54, 28 July 2011

-rakkaus/#mediawiki-i18n- [28-Jul-2011 22:51:12] PHP Notice: Undefined variable: this in /www/w/includes/UserMailer.php on line 195

$ret = wfRunHooks( 'AlternateUserMailer', array( $this, $headers, $to, $from, $subject, $body, $replyto, $contentType ) );

There is no $this in a static method

#Comment by Catrope (talk | contribs)   13:51, 2 August 2011

Not all of the hook parameters are documented in hooks.txt

#Comment by Catrope (talk | contribs)   13:53, 2 August 2011
+		} else if ( $ret != true ) {

Just use !$ret .

#Comment by Catrope (talk | contribs)   13:53, 2 August 2011

...and document how the hook can interrupt the 'real' mailer, and in which ways.

Status & tagging log