MarkAHershberger has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/376070 )
Change subject: Note whether a category was added in a machine readable way
......................................................................
Note whether a category was added in a machine readable way
CategoryMembershipChange is great, but it doesn't have a
machine-readable way to see if the category has been added or removed
from the page. We could parse the comments, but that would rely on
reading the comments and matching the message against the translated
strings.
This patch adds a couple of parameters and notes whether the change
was an addition or removal in rc_params.
Also, puts the evaluation of the AbortEmailNotification hook before
the check of rc_type in the hopes that the extension CatWatch can send
out emails at the right time.
Change-Id: I3e2ac0cc148b9d618e2f8b7853b14bff827ee443
---
M includes/changes/CategoryMembershipChange.php
M includes/changes/RecentChange.php
2 files changed, 14 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/70/376070/1
diff --git a/includes/changes/CategoryMembershipChange.php
b/includes/changes/CategoryMembershipChange.php
index 5d19961..6fa6907 100644
--- a/includes/changes/CategoryMembershipChange.php
+++ b/includes/changes/CategoryMembershipChange.php
@@ -134,7 +134,8 @@
),
$this->pageTitle,
$this->getPreviousRevisionTimestamp(),
- $this->revision
+ $this->revision,
+ $type === self::CATEGORY_ADDITION
);
}
@@ -146,6 +147,7 @@
* @param Title $pageTitle Title of the page that is being added or
removed
* @param string $lastTimestamp Parent revision timestamp of this
change in TS_MW format
* @param Revision|null $revision
+ * @param bool $added true, if the category was added, false for removed
*
* @throws MWException
*/
@@ -156,7 +158,8 @@
$comment,
Title $pageTitle,
$lastTimestamp,
- $revision
+ $revision,
+ $added
) {
$deleted = $revision ? $revision->getVisibility() &
Revision::SUPPRESSED_USER : 0;
$newRevId = $revision ? $revision->getId() : 0;
@@ -197,7 +200,8 @@
$lastTimestamp,
$bot,
$ip,
- $deleted
+ $deleted,
+ $added
]
);
$rc->save();
diff --git a/includes/changes/RecentChange.php
b/includes/changes/RecentChange.php
index cd11070..e72f588 100644
--- a/includes/changes/RecentChange.php
+++ b/includes/changes/RecentChange.php
@@ -364,8 +364,8 @@
// Never send an RC notification email about
categorization changes
if (
- $this->mAttribs['rc_type'] != RC_CATEGORIZE &&
- Hooks::run( 'AbortEmailNotification', [
$editor, $title, $this ] )
+ Hooks::run( 'AbortEmailNotification', [
$editor, $title, $this ] ) &&
+ $this->mAttribs['rc_type'] != RC_CATEGORIZE
) {
// @FIXME: This would be better as an extension
hook
// Send emails or email jobs once this row is
safely committed
@@ -853,6 +853,7 @@
* @param bool $bot true, if the change was made by a bot
* @param string $ip IP address of the user, if the change was made
anonymously
* @param int $deleted Indicates whether the change has been deleted
+ * @param bool $added true, if the category was added, false for removed
*
* @return RecentChange
*/
@@ -867,7 +868,8 @@
$lastTimestamp,
$bot,
$ip = '',
- $deleted = 0
+ $deleted = 0,
+ $added
) {
$rc = new RecentChange;
$rc->mTitle = $categoryTitle;
@@ -898,7 +900,8 @@
'rc_log_type' => null,
'rc_log_action' => '',
'rc_params' => serialize( [
- 'hidden-cat' => WikiCategoryPage::factory(
$categoryTitle )->isHidden()
+ 'hidden-cat' => WikiCategoryPage::factory(
$categoryTitle )->isHidden(),
+ 'added' => $added
] )
];
--
To view, visit https://gerrit.wikimedia.org/r/376070
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e2ac0cc148b9d618e2f8b7853b14bff827ee443
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MarkAHershberger <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits