From: kaldari Date: Sun, 14 Apr 2013 22:30:24 +0000 (-0700) Subject: Modifying ArticleEditUpdateNewTalk hook so that it passes the recipient X-Git-Tag: 1.31.0-rc.0~19960^2 X-Git-Url: http://git.cyclocoop.org//%27http:/code.google.com/p/ie7-js//%27?a=commitdiff_plain;h=1c832552adcfef95b2ef3290aa2f5adf93870bbc;p=lhc%2Fweb%2Fwiklou.git Modifying ArticleEditUpdateNewTalk hook so that it passes the recipient The recipient is the user who's talk page was edited. Extensions may want to send or not send the notification based on some aspect of the user, for example a preference. Bug: 46550 Change-Id: Ifc8fbaf8fdc96f9c18c2a889d2e854e49b3a7010 --- diff --git a/docs/hooks.txt b/docs/hooks.txt index c266dcc583..e896a724a5 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -482,7 +482,8 @@ $logEntry: the ManualLogEntry used to record the deletion 'ArticleEditUpdateNewTalk': Before updating user_newtalk when a user talk page was changed. -$wikiPage: WikiPage (object) of the user talk page +&$wikiPage: WikiPage (object) of the user talk page +$recipient: User (object) who's talk page was edited 'ArticleEditUpdates': When edit updates (mainly link tracking) are made when an article has been changed. diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 228f295b31..cb75cf54b2 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -2121,17 +2121,20 @@ class WikiPage implements Page, IDBAccessObject { && $shortTitle != $user->getTitleKey() && !( $revision->isMinor() && $user->isAllowed( 'nominornewtalk' ) ) ) { - if ( wfRunHooks( 'ArticleEditUpdateNewTalk', array( &$this ) ) ) { - $other = User::newFromName( $shortTitle, false ); - if ( !$other ) { - wfDebug( __METHOD__ . ": invalid username\n" ); - } elseif ( User::isIP( $shortTitle ) ) { - // An anonymous user - $other->setNewtalk( true, $revision ); - } elseif ( $other->isLoggedIn() ) { - $other->setNewtalk( true, $revision ); - } else { - wfDebug( __METHOD__ . ": don't need to notify a nonexistent user\n" ); + $recipient = User::newFromName( $shortTitle, false ); + if ( !$recipient ) { + wfDebug( __METHOD__ . ": invalid username\n" ); + } else { + // Allow extensions to prevent user notification when a new message is added to their talk page + if ( wfRunHooks( 'ArticleEditUpdateNewTalk', array( &$this, $recipient ) ) ) { + if ( User::isIP( $shortTitle ) ) { + // An anonymous user + $recipient->setNewtalk( true, $revision ); + } elseif ( $recipient->isLoggedIn() ) { + $recipient->setNewtalk( true, $revision ); + } else { + wfDebug( __METHOD__ . ": don't need to notify a nonexistent user\n" ); + } } } }