Kaldari 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:
Kaldari: Verified; Looks good to me, approved
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 5aba23c..3f7e497 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/59876
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: wmf/1.22wmf2
Gerrit-Owner: Kaldari <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits