jenkins-bot has submitted this change and it was merged.

Change subject: Modifying ArticleEditUpdateNewTalk hook so that it passes the 
recipient
......................................................................


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
---
M docs/hooks.txt
M includes/WikiPage.php
2 files changed, 16 insertions(+), 12 deletions(-)

Approvals:
  Bsitu: Looks good to me, but someone else must approve
  Matthias Mullie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/docs/hooks.txt b/docs/hooks.txt
index c266dcc..e896a72 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -482,7 +482,8 @@
 
 '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 228f295..cb75cf5 100644
--- a/includes/WikiPage.php
+++ b/includes/WikiPage.php
@@ -2121,17 +2121,20 @@
                        && $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" );
+                                       }
                                }
                        }
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/59086
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifc8fbaf8fdc96f9c18c2a889d2e854e49b3a7010
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Lwelling <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to