'gender' => 'unknown',
'hideminor' => 0,
'hidepatrolled' => 0,
+ 'hidecategorization' => 1,
'imagesize' => 2,
'math' => 1,
'minordefault' => 0,
'watchlisthideminor' => 0,
'watchlisthideown' => 0,
'watchlisthidepatrolled' => 0,
+ 'watchlisthidecategorization' => 1,
'watchmoves' => 0,
'watchrollback' => 0,
'wllimit' => 250,
'udp' => 'UDPRCFeedEngine',
);
+/**
+ * Treat category membership changes as a RecentChange
+ * @since 1.27
+ */
+$wgRCWatchCategoryMembership = false;
+
/**
* Use RC Patrolling to check for vandalism
*/
'section' => 'rc/advancedrc',
);
+ if ( $config->get( 'RCWatchCategoryMembership' ) ) {
+ $defaultPreferences['hidecategorization'] = array(
+ 'type' => 'toggle',
+ 'label-message' => 'tog-hidecategorization',
+ 'section' => 'rc/advancedrc',
+ );
+ }
+
if ( $user->useRCPatrol() ) {
$defaultPreferences['hidepatrolled'] = array(
'type' => 'toggle',
'label-message' => 'tog-watchlisthideliu',
);
+ if ( $config->get( 'RCWatchCategoryMembership' ) ) {
+ $defaultPreferences['watchlisthidecategorization'] = array(
+ 'type' => 'toggle',
+ 'section' => 'watchlist/advancedwatchlist',
+ 'label-message' => 'tog-watchlisthidecategorization',
+ );
+ }
+
if ( $user->useRCPatrol() ) {
$defaultPreferences['watchlisthidepatrolled'] = array(
'type' => 'toggle',
'hideliu' => false,
'hidepatrolled' => false,
'hidemyself' => false,
+ 'hidecategorization' => false,
'tagfilter' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
'type' => array(
- ApiBase::PARAM_DFLT => 'edit|new|log',
+ ApiBase::PARAM_DFLT => 'edit|new|log|categorize',
ApiBase::PARAM_ISMULTI => true,
- ApiBase::PARAM_TYPE => array(
- 'edit',
- 'external',
- 'new',
- 'log'
- )
+ ApiBase::PARAM_TYPE => RecentChange::getChangeTypes()
),
'toponly' => false,
'continue' => array(
)
),
'type' => array(
- ApiBase::PARAM_DFLT => 'edit|new|log',
+ ApiBase::PARAM_DFLT => 'edit|new|log|categorize',
ApiBase::PARAM_ISMULTI => true,
- ApiBase::PARAM_TYPE => array(
- 'edit',
- 'external',
- 'new',
- 'log',
- )
+ ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
+ ApiBase::PARAM_TYPE => RecentChange::getChangeTypes()
),
'owner' => array(
ApiBase::PARAM_TYPE => 'user'
"apihelp-feedrecentchanges-param-hideliu": "Hide changes made by registered users.",
"apihelp-feedrecentchanges-param-hidepatrolled": "Hide patrolled changes.",
"apihelp-feedrecentchanges-param-hidemyself": "Hide changes made by the current user.",
+ "apihelp-feedrecentchanges-param-hidecategorization": "Hide category membership changes.",
"apihelp-feedrecentchanges-param-tagfilter": "Filter by tag.",
"apihelp-feedrecentchanges-param-target": "Show only changes on pages linked from this page.",
"apihelp-feedrecentchanges-param-showlinkedto": "Show changes on pages linked to the selected page instead.",
"apihelp-query+watchlist-paramvalue-prop-notificationtimestamp": "Adds timestamp of when the user was last notified about the edit.",
"apihelp-query+watchlist-paramvalue-prop-loginfo": "Adds log information where appropriate.",
"apihelp-query+watchlist-param-show": "Show only items that meet these criteria. For example, to see only minor edits done by logged-in users, set $1show=minor|!anon.",
- "apihelp-query+watchlist-param-type": "Which types of changes to show:\n;edit:Regular page edits.\n;external:External changes.\n;new:Page creations.\n;log:Log entries.",
+ "apihelp-query+watchlist-param-type": "Which types of changes to show:",
+ "apihelp-query+watchlist-paramvalue-type-edit": "Regular page edits.",
+ "apihelp-query+watchlist-paramvalue-type-external": "External changes.",
+ "apihelp-query+watchlist-paramvalue-type-new": "Page creations.",
+ "apihelp-query+watchlist-paramvalue-type-log": "Log entries.",
+ "apihelp-query+watchlist-paramvalue-type-categorize": "Category membership changes.",
"apihelp-query+watchlist-param-owner": "Used along with $1token to access a different user's watchlist.",
"apihelp-query+watchlist-param-token": "A security token (available in the user's [[Special:Preferences#mw-prefsection-watchlist|preferences]]) to allow access to another user's watchlist.",
"apihelp-query+watchlist-example-simple": "List the top revision for recently changed pages on the current user's watchlist.",
"apihelp-feedrecentchanges-param-hideliu": "{{doc-apihelp-param|feedrecentchanges|hideliu}}",
"apihelp-feedrecentchanges-param-hidepatrolled": "{{doc-apihelp-param|feedrecentchanges|hidepatrolled}}",
"apihelp-feedrecentchanges-param-hidemyself": "{{doc-apihelp-param|feedrecentchanges|hidemyself}}",
+ "apihelp-feedrecentchanges-param-hidecategorization": "{{doc-apihelp-param|feedrecentchanges|hidecategorization}}",
"apihelp-feedrecentchanges-param-tagfilter": "{{doc-apihelp-param|feedrecentchanges|tagfilter}}",
"apihelp-feedrecentchanges-param-target": "{{doc-apihelp-param|feedrecentchanges|target}}",
"apihelp-feedrecentchanges-param-showlinkedto": "{{doc-apihelp-param|feedrecentchanges|showlinkedto}}",
"apihelp-query+watchlist-paramvalue-prop-loginfo": "{{doc-apihelp-paramvalue|query+watchlist|prop|loginfo}}",
"apihelp-query+watchlist-param-show": "{{doc-apihelp-param|query+watchlist|show}}",
"apihelp-query+watchlist-param-type": "{{doc-apihelp-param|query+watchlist|type}}",
+ "apihelp-query+watchlist-paramvalue-type-edit": "{{doc-apihelp-paramvalue|query+watchlist|type|edit}}",
+ "apihelp-query+watchlist-paramvalue-type-external": "{{doc-apihelp-paramvalue|query+watchlist|type|external}}",
+ "apihelp-query+watchlist-paramvalue-type-new": "{{doc-apihelp-paramvalue|query+watchlist|type|new}}",
+ "apihelp-query+watchlist-paramvalue-type-log": "{{doc-apihelp-paramvalue|query+watchlist|type|log}}",
+ "apihelp-query+watchlist-paramvalue-type-categorize": "{{doc-apihelp-paramvalue|query+watchlist|type|categorize}}",
"apihelp-query+watchlist-param-owner": "{{doc-apihelp-param|query+watchlist|owner}}",
"apihelp-query+watchlist-param-token": "{{doc-apihelp-param|query+watchlist|token}}",
"apihelp-query+watchlist-example-simple": "{{doc-apihelp-example|query+watchlist}}",
/**
* @var int
- * Number of pages this WikiPage is embedded by; set by CategoryMembershipChange::setRecursive()
+ * Number of pages this WikiPage is embedded by
+ * Set by CategoryMembershipChange::checkTemplateLinks()
*/
private $numTemplateLinks = 0;
* @param int $type may be CategoryMembershipChange::CATEGORY_ADDITION
* or CategoryMembershipChange::CATEGORY_REMOVAL
* @param array $params
- * - prefixedUrl: result of Title::->getPrefixedURL()
+ * - prefixedText: result of Title::->getPrefixedText()
*
* @return string
*/
*/
public function insertDiffHist( &$s, &$rc, $unpatrolled ) {
# Diff link
- if ( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
+ if (
+ $rc->mAttribs['rc_type'] == RC_NEW ||
+ $rc->mAttribs['rc_type'] == RC_LOG ||
+ $rc->mAttribs['rc_type'] == RC_CATEGORIZE
+ ) {
$diffLink = $this->message['diff'];
} elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
$diffLink = $this->message['diff'];
$query
);
}
- $diffhist = $diffLink . $this->message['pipe-separator'];
- # History link
- $diffhist .= Linker::linkKnown(
- $rc->getTitle(),
- $this->message['hist'],
- array(),
- array(
- 'curid' => $rc->mAttribs['rc_cur_id'],
- 'action' => 'history'
- )
- );
+ if ( $rc->mAttribs['rc_type'] == RC_CATEGORIZE ) {
+ $diffhist = $diffLink . $this->message['pipe-separator'] . $this->message['hist'];
+ } else {
+ $diffhist = $diffLink . $this->message['pipe-separator'];
+ # History link
+ $diffhist .= Linker::linkKnown(
+ $rc->getTitle(),
+ $this->message['hist'],
+ array(),
+ array(
+ 'curid' => $rc->mAttribs['rc_cur_id'],
+ 'action' => 'history'
+ )
+ );
+ }
+
// @todo FIXME: Hard coded ". .". Is there a message for this? Should there be?
$s .= $this->msg( 'parentheses' )->rawParams( $diffhist )->escaped() .
' <span class="mw-changeslist-separator">. .</span> ';
return false;
}
+
+ /**
+ * Determines whether a revision is linked to this change; this may not be the case
+ * when the categorization wasn't done by an edit but a conditional parser function
+ *
+ * @since 1.27
+ *
+ * @param RecentChange|RCCacheEntry $rcObj
+ * @return bool
+ */
+ protected function isCategorizationWithoutRevision( $rcObj ) {
+ return intval( $rcObj->getAttribute( 'rc_type' ) ) === RC_CATEGORIZE
+ && intval( $rcObj->getAttribute( 'rc_this_oldid' ) ) === 0;
+ }
+
}
if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
$data['logEntry'] = $this->insertLogEntry( $rcObj );
+ } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
+ $data['comment'] = $this->insertComment( $rcObj );
} else {
# User links
$data['userLink'] = $rcObj->userlink;
/** @var $block0 RecentChange */
$block0 = $block[0];
$last = $block[count( $block ) - 1];
- if ( !$allLogs ) {
+ if ( !$allLogs && $rcObj->mAttribs['rc_type'] != RC_CATEGORIZE ) {
if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
$links['total-changes'] = $nchanges[$n];
} elseif ( $isnew ) {
}
# History
- if ( $allLogs ) {
+ if ( $allLogs || $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ) {
// don't show history link for logs
} elseif ( $namehidden || !$block0->getTitle()->exists() ) {
$links['history'] = $this->message['enhancedrc-history'];
}
# Diff and hist links
- if ( $type != RC_LOG ) {
+ if ( $type == RC_LOG && $type != RC_CATEGORIZE ) {
$query['action'] = 'history';
- $data['historyLink'] = ' ' . $this->msg( 'parentheses' )
- ->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
- $rcObj->getTitle(),
- $this->message['hist'],
- array(),
- $query
- ) )->escaped();
+ $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
}
$data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator">. .</span> ';
if ( $type == RC_LOG ) {
$data['logEntry'] = $this->insertLogEntry( $rcObj );
+ } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
+ $data['comment'] = $this->insertComment( $rcObj );
} else {
$data['userLink'] = $rcObj->userlink;
$data['userTalkLink'] = $rcObj->usertalklink;
$data['comment'] = $this->insertComment( $rcObj );
+ if ( $type == RC_CATEGORIZE ) {
+ $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
+ }
$data['rollback'] = $this->getRollback( $rcObj );
}
return $line;
}
+ /**
+ * Returns value to be used in 'historyLink' element of $data param in
+ * EnhancedChangesListModifyBlockLineData hook.
+ *
+ * @since 1.27
+ *
+ * @param RCCacheEntry $rc
+ * @param array $query array of key/value pairs to append as a query string
+ * @return string HTML
+ */
+ public function getDiffHistLinks( RCCacheEntry $rc, array $query ) {
+ $pageTitle = $rc->getTitle();
+ if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) {
+ // For categorizations we must swap the category title with the page title!
+ $pageTitle = Title::newFromID( $rc->getAttribute( 'rc_cur_id' ) );
+ }
+
+ $retVal = ' ' . $this->msg( 'parentheses' )
+ ->rawParams( $rc->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
+ $pageTitle,
+ $this->message['hist'],
+ array(),
+ $query
+ ) )->escaped();
+ return $retVal;
+ }
+
/**
* If enhanced RC is in use, this function takes the previously cached
* RC lines, arranges them, and outputs the HTML
// Regular entries
} else {
$unpatrolled = $this->showAsUnpatrolled( $rc );
-
$this->insertDiffHist( $html, $rc, $unpatrolled );
# M, N, b and ! (minor, new, bot and unpatrolled)
$html .= $this->recentChangesFlags(
if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
$html .= $this->insertLogEntry( $rc );
+ } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
+ $html .= $this->insertComment( $rc );
} else {
# User tool links
$this->insertUserRelatedLinks( $html, $rc );
$diffLink = $diffMessage;
} elseif ( in_array( $cacheEntry->mAttribs['rc_type'], $logTypes ) ) {
$diffLink = $diffMessage;
+ } elseif ( $cacheEntry->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) {
+ $rcCurId = $cacheEntry->getAttribute( 'rc_cur_id' );
+ $pageTitle = Title::newFromID( $rcCurId );
+ if ( $pageTitle === null ) {
+ wfDebugLog( 'RCCacheEntryFactory', 'Could not get Title for rc_cur_id: ' . $rcCurId );
+ return $diffMessage;
+ }
+ $diffUrl = htmlspecialchars( $pageTitle->getLinkURL( $queryParams ) );
+ $diffLink = "<a href=\"$diffUrl\" tabindex=\"$counter\">$diffMessage</a>";
} else {
$diffUrl = htmlspecialchars( $cacheEntry->getTitle()->getLinkURL( $queryParams ) );
$diffLink = "<a href=\"$diffUrl\" tabindex=\"$counter\">$diffMessage</a>";
$editor = $this->getPerformer();
$title = $this->getTitle();
- if ( Hooks::run( 'AbortEmailNotification', array( $editor, $title, $this ) ) ) {
- # @todo FIXME: This would be better as an extension hook
- $enotif = new EmailNotification();
- $enotif->notifyOnPageChange( $editor, $title,
- $this->mAttribs['rc_timestamp'],
- $this->mAttribs['rc_comment'],
- $this->mAttribs['rc_minor'],
- $this->mAttribs['rc_last_oldid'],
- $this->mExtra['pageStatus'] );
+ // Never send an RC notification email about categorization changes
+ if ( $this->mAttribs['rc_type'] != RC_CATEGORIZE ) {
+ if ( Hooks::run( 'AbortEmailNotification', array( $editor, $title, $this ) ) ) {
+ # @todo FIXME: This would be better as an extension hook
+ $enotif = new EmailNotification();
+ $enotif->notifyOnPageChange(
+ $editor,
+ $title,
+ $this->mAttribs['rc_timestamp'],
+ $this->mAttribs['rc_comment'],
+ $this->mAttribs['rc_minor'],
+ $this->mAttribs['rc_last_oldid'],
+ $this->mExtra['pageStatus']
+ );
+ }
}
}
/** @var bool Whether to queue jobs for recursive updates */
public $mRecursive;
+ /** @var bool Whether this job was triggered by a recursive update job */
+ private $mTriggeredRecursive;
+
+ /** @var Revision Revision for which this update has been triggered */
+ private $mRevision;
+
/**
* @var null|array Added links if calculated.
*/
}
protected function doIncrementalUpdate() {
+ global $wgRCWatchCategoryMembership;
# Page links
$existing = $this->getExistingLinks();
$this->invalidateCategories( $categoryUpdates );
$this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
+ # Category membership changes
+ if (
+ $wgRCWatchCategoryMembership &&
+ !$this->mTriggeredRecursive && ( $categoryInserts || $categoryDeletes )
+ ) {
+ $this->triggerCategoryChanges( $categoryInserts, $categoryDeletes );
+ }
+
# Page properties
$existing = $this->getExistingProperties();
}
+ private function triggerCategoryChanges( $categoryInserts, $categoryDeletes ) {
+ $catMembChange = new CategoryMembershipChange( $this->mTitle, $this->mRevision );
+
+ if ( $this->mRecursive ) {
+ $catMembChange->checkTemplateLinks();
+ }
+
+ foreach ( $categoryInserts as $categoryName => $value ) {
+ $categoryTitle = Title::newFromText( $categoryName, NS_CATEGORY );
+ $catMembChange->triggerCategoryAddedNotification( $categoryTitle );
+ }
+
+ foreach ( $categoryDeletes as $categoryName => $value ) {
+ $categoryTitle = Title::newFromText( $categoryName, NS_CATEGORY );
+ $catMembChange->triggerCategoryRemovedNotification( $categoryTitle );
+ }
+ }
+
/**
* Queue recursive jobs for this page
*
return $this->mImages;
}
+ /**
+ * Set this object as being triggered by a recursive LinksUpdate
+ *
+ * @since 1.27
+ */
+ public function setTriggeredRecursive() {
+ $this->mTriggeredRecursive = true;
+ }
+
+ /**
+ * Set the revision corresponding to this LinksUpdate
+ *
+ * @since 1.27
+ *
+ * @param Revision $revision
+ */
+ public function setRevision( Revision $revision ) {
+ $this->mRevision = $revision;
+ }
+
/**
* Invalidate any necessary link lists related to page property changes
* @param array $changed
} else {
$extraParams['masterPos'] = false;
}
+ $extraParams['triggeredRecursive'] = true;
// Convert this into no more than $wgUpdateRowsPerJob RefreshLinks per-title
// jobs and possibly a recursive RefreshLinks job for the rest of the backlinks
$jobs = BacklinkJobUtils::partitionBacklinkJob(
}
$updates = $content->getSecondaryDataUpdates( $title, null, false, $parserOutput );
+ foreach ( $updates as $key => $update ) {
+ if ( $update instanceof LinksUpdate && isset( $this->params['triggeredRecursive'] ) ) {
+ $update->setTriggeredRecursive();
+ }
+ }
+
DataUpdate::runUpdates( $updates );
InfoAction::invalidateCache( $title );
$updates = $content->getSecondaryDataUpdates(
$this->getTitle(), null, $recursive, $editInfo->output );
foreach ( $updates as $update ) {
+ if ( $update instanceof LinksUpdate ) {
+ $update->setRevision( $revision );
+ }
DeferredUpdates::addUpdate( $update );
}
}
* @return FormOptions
*/
public function getDefaultOptions() {
+ $config = $this->getConfig();
$opts = new FormOptions();
$opts->add( 'hideminor', false );
$opts->add( 'hidepatrolled', false );
$opts->add( 'hidemyself', false );
+ if ( $config->get( 'RCWatchCategoryMembership' ) ) {
+ $opts->add( 'hidecategorization', false );
+ }
+
$opts->add( 'namespace', '', FormOptions::INTNULL );
$opts->add( 'invert', false );
$opts->add( 'associated', false );
$conds[] = 'rc_user_text != ' . $dbr->addQuotes( $user->getName() );
}
}
+ if ( $opts['hidecategorization'] === true ) {
+ $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
+ }
// Namespace filtering
if ( $opts['namespace'] !== '' ) {
public function getDefaultOptions() {
$opts = parent::getDefaultOptions();
$user = $this->getUser();
+ $config = $this->getConfig();
$opts->add( 'days', $user->getIntOption( 'rcdays' ) );
$opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
$opts->add( 'hidepatrolled', $user->getBoolOption( 'hidepatrolled' ) );
$opts->add( 'hidemyself', false );
+ if ( $config->get( 'RCWatchCategoryMembership' ) ) {
+ $opts->add( 'hidecategorization', $user->getBoolOption( 'hidecategorization' ) );
+ }
+
$opts->add( 'categories', '' );
$opts->add( 'categories_any', false );
$opts->add( 'tagfilter', '' );
if ( 'hidemyself' === $bit ) {
$opts['hidemyself'] = true;
}
+ if ( 'hidecategorization' === $bit ) {
+ $opts['hidecategorization'] = true;
+ }
if ( is_numeric( $bit ) ) {
$opts['limit'] = $bit;
$lang = $this->getLanguage();
$user = $this->getUser();
+ $config = $this->getConfig();
if ( $options['from'] ) {
$note .= $this->msg( 'rcnotefrom' )
->numParams( $options['limit'] )
}
# Sort data for display and make sure it's unique after we've added user data.
- $linkLimits = $this->getConfig()->get( 'RCLinkLimits' );
+ $linkLimits = $config->get( 'RCLinkLimits' );
$linkLimits[] = $options['limit'];
sort( $linkLimits );
$linkLimits = array_unique( $linkLimits );
- $linkDays = $this->getConfig()->get( 'RCLinkDays' );
+ $linkDays = $config->get( 'RCLinkDays' );
$linkDays[] = $options['days'];
sort( $linkDays );
$linkDays = array_unique( $linkDays );
'hidemyself' => 'rcshowhidemine'
);
+ if ( $config->get( 'RCWatchCategoryMembership' ) ) {
+ $filters['hidecategorization'] = 'rcshowhidecategorization';
+ }
+
$showhide = array( 'show', 'hide' );
foreach ( $this->getCustomFilters() as $key => $params ) {
// The following messages are used here:
// rcshowhideminor-show, rcshowhideminor-hide, rcshowhidebots-show, rcshowhidebots-hide,
// rcshowhideanons-show, rcshowhideanons-hide, rcshowhideliu-show, rcshowhideliu-hide,
- // rcshowhidepatr-show, rcshowhidepatr-hide, rcshowhidemine-show, rcshowhidemine-hide.
+ // rcshowhidepatr-show, rcshowhidepatr-hide, rcshowhidemine-show, rcshowhidemine-hide,
+ // rcshowhidecategorization-show, rcshowhidecategorization-hide.
$linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
// Extensions can define additional filters, but don't need to define the corresponding
// messages. If they don't exist, just fall back to 'show' and 'hide'.
$opts->add( 'hidepatrolled', $user->getBoolOption( 'watchlisthidepatrolled' ) );
$opts->add( 'hidemyself', $user->getBoolOption( 'watchlisthideown' ) );
+ if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
+ $opts->add( 'hidecategorization', $user->getBoolOption( 'watchlisthidecategorization' ) );
+ }
+
$opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' ) );
return $opts;
'hidemyself' => 'rcshowhidemine',
'hidepatrolled' => 'rcshowhidepatr'
);
+
+ if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
+ $filters['hidecategorization'] = 'rcshowhidecategorization';
+ }
+
foreach ( $this->getCustomFilters() as $key => $params ) {
$filters[$key] = $params['msg'];
}
"tog-hideminor": "Hide minor edits from recent changes",
"tog-hidepatrolled": "Hide patrolled edits from recent changes",
"tog-newpageshidepatrolled": "Hide patrolled pages from new page list",
+ "tog-hidecategorization": "Hide categorization of pages",
"tog-extendwatchlist": "Expand watchlist to show all changes, not just the most recent",
"tog-usenewrc": "Group changes by page in recent changes and watchlist",
"tog-numberheadings": "Auto-number headings",
"tog-watchlisthideliu": "Hide edits by logged in users from the watchlist",
"tog-watchlisthideanons": "Hide edits by anonymous users from the watchlist",
"tog-watchlisthidepatrolled": "Hide patrolled edits from the watchlist",
+ "tog-watchlisthidecategorization": "Hide categorization of pages",
"tog-ccmeonemails": "Send me copies of emails I send to other users",
"tog-diffonly": "Do not show page content below diffs",
"tog-showhiddencats": "Show hidden categories",
"rcshowhidemine": "$1 my edits",
"rcshowhidemine-show": "Show",
"rcshowhidemine-hide": "Hide",
+ "rcshowhidecategorization": "$1 page categorization",
+ "rcshowhidecategorization-show": "Show",
+ "rcshowhidecategorization-hide": "Hide",
"rclinks": "Show last $1 changes in last $2 days<br />$3",
"diff": "diff",
"hist": "hist",
"spam_blanking": "All revisions contained links to $1, blanking",
"spam_deleting": "All revisions contained links to $1, deleting",
"simpleantispam-label": "Anti-spam check.\nDo <strong>not</strong> fill this in!",
+ "autochange-username": "MediaWiki automatic change",
"pageinfo-header": "-",
"pageinfo-title": "Information for \"$1\"",
"pageinfo-not-current": "Sorry, it's impossible to provide this information for old revisions.",
"tog-hideminor": "[[Special:Preferences]], tab 'Recent changes'. Offers user to hide minor edits in recent changes or not. {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
"tog-hidepatrolled": "Option in Recent changes tab of [[Special:Preferences]] (if [[mw:Manual:$wgUseRCPatrol|$wgUseRCPatrol]] is enabled). {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
"tog-newpageshidepatrolled": "Toggle in [[Special:Preferences]], section \"Recent changes\" (if [[mw:Manual:$wgUseRCPatrol|$wgUseRCPatrol]] is enabled). {{Gender}}",
+ "tog-hidecategorization": "Option in \"Recent changes\" tab of [[Special:Preferences]]. Offers user to hide/show categorization of pages. Appears next to messages such as {{msg-mw|tog-hideminor}}.",
"tog-extendwatchlist": "[[Special:Preferences]], tab 'Watchlist'. Offers user to show all applicable changes in watchlist (by default only the last change to a page on the watchlist is shown). {{Gender}}",
"tog-usenewrc": "{{Gender}}\nUsed as label for the checkbox in [[Special:Preferences]], tab \"Recent changes\".\n\nOffers user to use alternative representation of [[Special:RecentChanges]] and watchlist.",
"tog-numberheadings": "[[Special:Preferences]], tab 'Misc'. Offers numbered headings on content pages to user. {{Gender}}",
"tog-watchlisthideliu": "Option in tab 'Watchlist' of [[Special:Preferences]]. {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
"tog-watchlisthideanons": "Option in tab 'Watchlist' of [[Special:Preferences]]. {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
"tog-watchlisthidepatrolled": "Option in Watchlist tab of [[Special:Preferences]]. {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
+ "tog-watchlisthidecategorization": "Option in Watchlist tab of [[Special:Preferences]]. Offers user to hide/show categorization of pages. Appears next to checkboxes with labels such as {{msg-mw|tog-watchlisthideminor}}.",
"tog-ccmeonemails": "Option in [[Special:Preferences]] > {{int:prefs-personal}} > {{int:email}}. {{Gender}}",
"tog-diffonly": "Toggle option used in [[Special:Preferences]]. {{Gender}}",
"tog-showhiddencats": "Toggle option used in [[Special:Preferences]]. {{Gender}}",
"rcshowhidemine": "Option text in [[Special:RecentChanges]]. Parameters:\n* $1 - the \"show/hide\" command, with the text taken from either {{msg-mw|rcshowhidemine-show}} or {{msg-mw|rcshowhidemine-hide}}",
"rcshowhidemine-show": "{{doc-actionlink}}\nOption text in [[Special:RecentChanges]] in conjunction with {{msg-mw|rcshowhidemine}}.\n\nSee also:\n* {{msg-mw|rcshowhidemine-hide}}\n{{Identical|show}}",
"rcshowhidemine-hide": "{{doc-actionlink}}\nOption text in [[Special:RecentChanges]] in conjunction with {{msg-mw|rcshowhidemine}}.\n\nSee also:\n* {{msg-mw|rcshowhidemine-show}}\n{{Identical|hide}}",
+ "rcshowhidecategorization": "Option text in [[Special:RecentChanges]]. Parameters:\n* $1 - the \"show/hide\" command, with the text taken from either {{msg-mw|rcshowhidecategorization-show}} or {{msg-mw|rcshowhidecategorization-hide}}",
+ "rcshowhidecategorization-show": "{{doc-actionlink}}\nOption text in [[Special:RecentChanges]] in conjunction with {{msg-mw|rcshowhidecategorization}}.\n\nSee also:\n* {{msg-mw|rcshowhidecategorization-hide}}\n{{Identical|show}}",
+ "rcshowhidecategorization-hide": "{{doc-actionlink}}\nOption text in [[Special:RecentChanges]] in conjunction with {{msg-mw|rcshowhidecategorization}}.\n\nSee also:\n* {{msg-mw|rcshowhidecategorization-show}}\n{{Identical|hide}}",
"rclinks": "Used on [[Special:RecentChanges]].\n* $1 - a list of different choices with number of pages to be shown.<br /> Example: \"''50{{int:pipe-separator}}100{{int:pipe-separator}}250{{int:pipe-separator}}500\".\n* $2 - a list of clickable links with a number of days for which recent changes are to be displayed.<br /> Example: \"''1{{int:pipe-separator}}3{{int:pipe-separator}}7{{int:pipe-separator}}14{{int:pipe-separator}}30''\".\n* $3 - a block of text that consists of other messages.<br /> Example: \"''Hide minor edits{{int:pipe-separator}}Show bots{{int:pipe-separator}}Hide anonymous users{{int:pipe-separator}}Hide logged-in users{{int:pipe-separator}}Hide patrolled edits{{int:pipe-separator}}Hide my edits''\"\nList elements are separated by {{msg-mw|Pipe-separator}} each. Each list element is, or contains, a link.",
"diff": "Short form of \"differences\". Used on [[Special:RecentChanges]], [[Special:Watchlist]], ...\n{{Identical|Diff}}",
"hist": "Short form of \"history\". Used on [[Special:RecentChanges]], [[Special:Watchlist]], ...",
"spam_blanking": "Edit summary for spam cleanup script.\n\nUsed when a page is blanked (made to have no content, but still exist) because the script could not find an appropriate revision to set the page to.\n\nParameters:\n* $1 - a spammed domain name",
"spam_deleting": "Edit summary for spam cleanup script.\n\nUsed when a page is deleted because all revisions contained a particular link.\n\nParameters:\n* $1 - a spammed domain name",
"simpleantispam-label": "Used as label for the input box in \"Edit\" page.\n\nThe label and the input box are always hidden.",
+ "autochange-username": "Used as bot / unknown username.",
"pageinfo-header": "{{ignored}}Custom text for the top of the info page (action=info).",
"pageinfo-title": "Page title for action=info. Parameters:\n* $1 is the page name",
"pageinfo-not-current": "Error message displayed when information for an old revision is requested. Example: [{{fullurl:Project:News|oldid=4266597&action=info}}]",
$this->assertEquals( '', $html );
}
+ public function testCategorizationLineFormatting() {
+ $html = $this->createCategorizationLine(
+ $this->getCategorizationChange( '20150629191735', 0, 0 )
+ );
+ $this->assertNotContains( '(diff | hist)', strip_tags( $html ) );
+ }
+
+ public function testCategorizationLineFormattingWithRevision() {
+ $html = $this->createCategorizationLine(
+ $this->getCategorizationChange( '20150629191735', 1025, 1024 )
+ );
+ $this->assertContains( '(diff | hist)', strip_tags( $html ) );
+ }
+
/**
* @todo more tests for actual formatting, this is more of a smoke test
*/
return $recentChange;
}
+ /**
+ * @return RecentChange
+ */
+ private function getCategorizationChange( $timestamp, $thisId, $lastId ) {
+ $wikiPage = new WikiPage( Title::newFromText( 'Testpage' ) );
+ $wikiPage->doEditContent( new WikitextContent( 'Some random text' ), 'page created' );
+
+ $wikiPage = new WikiPage( Title::newFromText( 'Category:Foo' ) );
+ $wikiPage->doEditContent( new WikitextContent( 'Some random text' ), 'category page created' );
+
+ $user = $this->getTestUser();
+ $recentChange = $this->testRecentChangesHelper->makeCategorizationRecentChange(
+ $user, 'Category:Foo', $wikiPage->getId(), $thisId, $lastId, $timestamp
+ );
+
+ return $recentChange;
+ }
+
/**
* @return User
*/
return $user;
}
+ private function createCategorizationLine( $recentChange ) {
+ $enhancedChangesList = $this->newEnhancedChangesList();
+ $cacheEntry = $this->testRecentChangesHelper->getCacheEntry( $recentChange );
+
+ $reflection = new \ReflectionClass( get_class( $enhancedChangesList ) );
+ $method = $reflection->getMethod( 'recentChangesBlockLine' );
+ $method->setAccessible( true );
+
+ return $method->invokeArgs( $enhancedChangesList, array( $cacheEntry ) );
+ }
+
}
return $change;
}
+ public function getCacheEntry( $recentChange ) {
+ $rcCacheFactory = new RCCacheEntryFactory(
+ new RequestContext(),
+ array( 'diff' => 'diff', 'cur' => 'cur', 'last' => 'last' )
+ );
+ return $rcCacheFactory->newFromRecentChange( $recentChange, false );
+ }
+
+ public function makeCategorizationRecentChange(
+ User $user, $titleText, $curid, $thisid, $lastid, $timestamp
+ ) {
+
+ $attribs = array_merge(
+ $this->getDefaultAttributes( $titleText, $timestamp ),
+ array(
+ 'rc_type' => RC_CATEGORIZE,
+ 'rc_user' => $user->getId(),
+ 'rc_user_text' => $user->getName(),
+ 'rc_this_oldid' => $thisid,
+ 'rc_last_oldid' => $lastid,
+ 'rc_cur_id' => $curid,
+ 'rc_comment' => '[[:Testpage]] added to category',
+ 'rc_old_len' => 0,
+ 'rc_new_len' => 0,
+ )
+ );
+
+ return $this->makeRecentChange( $attribs, 0, 0 );
+ }
+
private function getDefaultAttributes( $titleText, $timestamp ) {
return array(
'rc_id' => 545,
'externallinks',
'imagelinks',
'templatelinks',
- 'iwlinks'
+ 'iwlinks',
+ 'recentchanges',
)
);
}
'iw_wikiid' => 'linksupdatetest',
)
);
+ $this->setMwGlobals( 'wgRCWatchCategoryMembership', true );
+ }
+
+ public function addDBData() {
+ $this->insertPage( 'Testing' );
+ $this->insertPage( 'Some_other_page' );
+ $this->insertPage( 'Template:TestingTemplate' );
}
protected function makeTitleAndParserOutput( $name, $id ) {
) );
}
+ public function testOnAddingAndRemovingCategory_recentChangesRowIsAdded() {
+ $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
+
+ $title = Title::newFromText( 'Testing' );
+ $wikiPage = new WikiPage( $title );
+ $wikiPage->doEditContent( new WikitextContent( '[[Category:Foo]]' ), 'added category' );
+
+ $this->assertRecentChangeByCategorization(
+ $title,
+ $wikiPage->getParserOutput( new ParserOptions() ),
+ Title::newFromText( 'Category:Foo' ),
+ array( array( 'Foo', '[[:Testing]] added to category' ) )
+ );
+
+ $wikiPage->doEditContent( new WikitextContent( '[[Category:Bar]]' ), 'added category' );
+ $this->assertRecentChangeByCategorization(
+ $title,
+ $wikiPage->getParserOutput( new ParserOptions() ),
+ Title::newFromText( 'Category:Foo' ),
+ array(
+ array( 'Foo', '[[:Testing]] added to category' ),
+ array( 'Foo', '[[:Testing]] removed from category' ),
+ )
+ );
+
+ $this->assertRecentChangeByCategorization(
+ $title,
+ $wikiPage->getParserOutput( new ParserOptions() ),
+ Title::newFromText( 'Category:Bar' ),
+ array(
+ array( 'Bar', '[[:Testing]] added to category' ),
+ )
+ );
+ }
+
+ public function testOnAddingAndRemovingCategoryToTemplates_embeddingPagesAreIgnored() {
+ $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
+
+ $templateTitle = Title::newFromText( 'Template:TestingTemplate' );
+ $templatePage = new WikiPage( $templateTitle );
+
+ $wikiPage = new WikiPage( Title::newFromText( 'Testing' ) );
+ $wikiPage->doEditContent( new WikitextContent( '{{TestingTemplate}}' ), 'added template' );
+ $otherWikiPage = new WikiPage( Title::newFromText( 'Some_other_page' ) );
+ $otherWikiPage->doEditContent( new WikitextContent( '{{TestingTemplate}}' ), 'added template' );
+ $templatePage->doEditContent( new WikitextContent( '[[Category:Foo]]' ), 'added category' );
+
+ $this->assertRecentChangeByCategorization(
+ $templateTitle,
+ $templatePage->getParserOutput( new ParserOptions() ),
+ Title::newFromText( 'Foo' ),
+ array( array( 'Foo', '[[:Template:TestingTemplate]] and 2 pages added to category' ) )
+ );
+ }
+
/**
* @covers ParserOutput::addInterwikiLink
*/
$this->assertSelect( $table, $fields, $condition, $expectedRows );
return $update;
}
+
+ protected function assertRecentChangeByCategorization(
+ Title $pageTitle, ParserOutput $parserOutput, Title $categoryTitle, $expectedRows
+ ) {
+ $update = new LinksUpdate( $pageTitle, $parserOutput );
+ $revision = Revision::newFromTitle( $pageTitle );
+ $update->setRevision( $revision );
+ $update->beginTransaction();
+ $update->doUpdate();
+ $update->commitTransaction();
+
+ $this->assertSelect(
+ 'recentchanges',
+ 'rc_title, rc_comment',
+ array(
+ 'rc_type' => RC_CATEGORIZE,
+ 'rc_namespace' => NS_CATEGORY,
+ 'rc_title' => $categoryTitle->getDBkey()
+ ),
+ $expectedRows
+ );
+ }
}
*/
class SpecialRecentchangesTest extends MediaWikiTestCase {
+ protected function setUp() {
+ parent::setUp();
+ $this->setMwGlobals( 'wgRCWatchCategoryMembership', true );
+ }
+
/**
* @var SpecialRecentChanges
*/
$this->assertConditions(
array( # expected
'rc_bot' => 0,
- 0 => "rc_namespace = '0'",
+ 0 => "rc_type != '6'",
+ 1 => "rc_namespace = '0'",
),
array(
'namespace' => NS_MAIN,
$this->assertConditions(
array( # expected
'rc_bot' => 0,
- 0 => sprintf( "rc_namespace != '%s'", NS_MAIN ),
+ 0 => "rc_type != '6'",
+ 1 => sprintf( "rc_namespace != '%s'", NS_MAIN ),
),
array(
'namespace' => NS_MAIN,
$this->assertConditions(
array( # expected
'rc_bot' => 0,
- 0 => sprintf( "(rc_namespace = '%s' OR rc_namespace = '%s')", $ns1, $ns2 ),
+ 0 => "rc_type != '6'",
+ 1 => sprintf( "(rc_namespace = '%s' OR rc_namespace = '%s')", $ns1, $ns2 ),
),
array(
'namespace' => $ns1,
$this->assertConditions(
array( # expected
'rc_bot' => 0,
- 0 => sprintf( "(rc_namespace != '%s' AND rc_namespace != '%s')", $ns1, $ns2 ),
+ 0 => "rc_type != '6'",
+ 1 => sprintf( "(rc_namespace != '%s' AND rc_namespace != '%s')", $ns1, $ns2 ),
),
array(
'namespace' => $ns1,