From 1c832552adcfef95b2ef3290aa2f5adf93870bbc Mon Sep 17 00:00:00 2001 From: kaldari Date: Sun, 14 Apr 2013 15:30:24 -0700 Subject: [PATCH] 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 --- docs/hooks.txt | 3 ++- includes/WikiPage.php | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) 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" ); + } } } } -- 2.20.1