r40394 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40393‎ | r40394 | r40395 >
Date:21:16, 3 September 2008
Author:nad
Status:old
Tags:
Comment:
create an EmailNotification object to ensure UserMailer class loaded
Modified paths:
  • /trunk/extensions/CategoryWatch/CategoryWatch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryWatch/CategoryWatch.php
@@ -15,7 +15,7 @@
1616
1717 if (!defined('MEDIAWIKI')) die('Not an entry point.');
1818
19 -define('CATEGORYWATCH_VERSION', '0.1.0, 2008-09-03');
 19+define('CATEGORYWATCH_VERSION', '0.1.1, 2008-09-04');
2020
2121 $wgCategoryWatchNotifyEditor = false;
2222
@@ -69,31 +69,34 @@
7070 $sub = array_diff($this->before, $this->after);
7171
7272 # Notify watchers of each cat about the addition or removal of this article
73 - $page = $article->getTitle()->getText();
74 - if (count($add) == 1 && count($sub) == 1) {
75 - $add = array_shift($add);
76 - $sub = array_shift($sub);
 73+ if (count($add) > 0 || count($sub) > 0) {
 74+ $enotif = new EmailNotification(); # ensure UserMailer class is autoloaded
 75+ $page = $article->getTitle()->getText();
 76+ if (count($add) == 1 && count($sub) == 1) {
 77+ $add = array_shift($add);
 78+ $sub = array_shift($sub);
7779
78 - $title = Title::newFromText($add, NS_CATEGORY);
79 - $message = wfMsg('categorywatch-catmovein', $page, $add, $sub);
80 - $this->notifyWatchers($title, $user, $message);
 80+ $title = Title::newFromText($add, NS_CATEGORY);
 81+ $message = wfMsg('categorywatch-catmovein', $page, $add, $sub);
 82+ $this->notifyWatchers($title, $user, $message);
8183
82 - $title = Title::newFromText($sub, NS_CATEGORY);
83 - $message = wfMsg('categorywatch-catmoveout', $page, $sub, $add);
84 - $this->notifyWatchers($title, $user, $message);
85 - }
86 - else {
87 -
88 - foreach ($add as $cat) {
89 - $title = Title::newFromText($cat, NS_CATEGORY);
90 - $message = wfMsg('categorywatch-catadd', $page, $cat);
 84+ $title = Title::newFromText($sub, NS_CATEGORY);
 85+ $message = wfMsg('categorywatch-catmoveout', $page, $sub, $add);
9186 $this->notifyWatchers($title, $user, $message);
9287 }
 88+ else {
9389
94 - foreach ($sub as $cat) {
95 - $title = Title::newFromText($cat, NS_CATEGORY);
96 - $message = wfMsg('categorywatch-catsub', $page, $cat);
97 - $this->notifyWatchers($title, $user, $message);
 90+ foreach ($add as $cat) {
 91+ $title = Title::newFromText($cat, NS_CATEGORY);
 92+ $message = wfMsg('categorywatch-catadd', $page, $cat);
 93+ $this->notifyWatchers($title, $user, $message);
 94+ }
 95+
 96+ foreach ($sub as $cat) {
 97+ $title = Title::newFromText($cat, NS_CATEGORY);
 98+ $message = wfMsg('categorywatch-catsub', $page, $cat);
 99+ $this->notifyWatchers($title, $user, $message);
 100+ }
98101 }
99102 }
100103