This is part of a chain that reverts:
e412ff5ecc.
NOTE:
- The feature is disabled by default
- User settings default to hiding changes
- T109707 Touching a file on wikisource adds and
removes it from a category... Even when page
has no changes.... WTF? See linked issue,
marked as stalled with a possible way forward
for this patch.
@see https://gerrit.wikimedia.org/r/#/c/235467/
Changes since version 1:
- T109604 - Page names in comment are no longer
url encoded / have _'s
- T109638 & T110338 - Reserved username now used
when we can't determine a username for the change
(we could perhaps set the user and id to be blank
in the RC table, but who knows what this might do)
- T109688 - History links are now disabled in RC....
(could be fine for the introduction and worked
on more in the future)
- Categorization changes are now always patrolled
- Touching on T109672 in this change emails will never
be sent regarding categorization changes. (this
can of course be changed in a followup)
- Added $wgRCWatchCategoryMembership defaulting to true
for enabling / disabling the feature
- T109700 - for cases when no revision was retrieved
for a category change set the bot flag to true.
This means all changes caused by parser functions
& Lua will be marked as bot, as will changes that
cant find their revision due to slave lag..
Bug: T9148
Bug: T109604
Bug: T109638
Bug: T109688
Bug: T109700
Bug: T110338
Bug: T110340
Change-Id: I51c2c1254de862f24a26ef9dbbf027c6c83e9063
166 lines
4.2 KiB
PHP
166 lines
4.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Helper for generating test recent changes entries.
|
|
*
|
|
* @author Katie Filbert < aude.wiki@gmail.com >
|
|
*/
|
|
class TestRecentChangesHelper {
|
|
|
|
public function makeEditRecentChange( User $user, $titleText, $curid, $thisid, $lastid,
|
|
$timestamp, $counter, $watchingUsers
|
|
) {
|
|
|
|
$attribs = array_merge(
|
|
$this->getDefaultAttributes( $titleText, $timestamp ),
|
|
array(
|
|
'rc_user' => $user->getId(),
|
|
'rc_user_text' => $user->getName(),
|
|
'rc_this_oldid' => $thisid,
|
|
'rc_last_oldid' => $lastid,
|
|
'rc_cur_id' => $curid
|
|
)
|
|
);
|
|
|
|
return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
|
|
}
|
|
|
|
public function makeLogRecentChange(
|
|
$logType, $logAction, User $user, $titleText, $timestamp, $counter, $watchingUsers
|
|
) {
|
|
$attribs = array_merge(
|
|
$this->getDefaultAttributes( $titleText, $timestamp ),
|
|
array(
|
|
'rc_cur_id' => 0,
|
|
'rc_user' => $user->getId(),
|
|
'rc_user_text' => $user->getName(),
|
|
'rc_this_oldid' => 0,
|
|
'rc_last_oldid' => 0,
|
|
'rc_old_len' => null,
|
|
'rc_new_len' => null,
|
|
'rc_type' => 3,
|
|
'rc_logid' => 25,
|
|
'rc_log_type' => $logType,
|
|
'rc_log_action' => $logAction,
|
|
'rc_source' => 'mw.log'
|
|
)
|
|
);
|
|
|
|
return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
|
|
}
|
|
|
|
public function makeDeletedEditRecentChange( User $user, $titleText, $timestamp, $curid,
|
|
$thisid, $lastid, $counter, $watchingUsers
|
|
) {
|
|
$attribs = array_merge(
|
|
$this->getDefaultAttributes( $titleText, $timestamp ),
|
|
array(
|
|
'rc_user' => $user->getId(),
|
|
'rc_user_text' => $user->getName(),
|
|
'rc_deleted' => 5,
|
|
'rc_cur_id' => $curid,
|
|
'rc_this_oldid' => $thisid,
|
|
'rc_last_oldid' => $lastid
|
|
)
|
|
);
|
|
|
|
return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
|
|
}
|
|
|
|
public function makeNewBotEditRecentChange( User $user, $titleText, $curid, $thisid, $lastid,
|
|
$timestamp, $counter, $watchingUsers
|
|
) {
|
|
|
|
$attribs = array_merge(
|
|
$this->getDefaultAttributes( $titleText, $timestamp ),
|
|
array(
|
|
'rc_user' => $user->getId(),
|
|
'rc_user_text' => $user->getName(),
|
|
'rc_this_oldid' => $thisid,
|
|
'rc_last_oldid' => $lastid,
|
|
'rc_cur_id' => $curid,
|
|
'rc_type' => 1,
|
|
'rc_bot' => 1,
|
|
'rc_source' => 'mw.new'
|
|
)
|
|
);
|
|
|
|
return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
|
|
}
|
|
|
|
private function makeRecentChange( $attribs, $counter, $watchingUsers ) {
|
|
$change = new RecentChange();
|
|
$change->setAttribs( $attribs );
|
|
$change->counter = $counter;
|
|
$change->numberofWatchingusers = $watchingUsers;
|
|
|
|
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,
|
|
'rc_user' => 0,
|
|
'rc_user_text' => '127.0.0.1',
|
|
'rc_ip' => '127.0.0.1',
|
|
'rc_title' => $titleText,
|
|
'rc_namespace' => 0,
|
|
'rc_timestamp' => $timestamp,
|
|
'rc_old_len' => 212,
|
|
'rc_new_len' => 188,
|
|
'rc_comment' => '',
|
|
'rc_minor' => 0,
|
|
'rc_bot' => 0,
|
|
'rc_type' => 0,
|
|
'rc_patrolled' => 1,
|
|
'rc_deleted' => 0,
|
|
'rc_logid' => 0,
|
|
'rc_log_type' => null,
|
|
'rc_log_action' => '',
|
|
'rc_params' => '',
|
|
'rc_source' => 'mw.edit'
|
|
);
|
|
}
|
|
|
|
public function getTestContext( User $user ) {
|
|
$context = new RequestContext();
|
|
$context->setLanguage( Language::factory( 'en' ) );
|
|
|
|
$context->setUser( $user );
|
|
|
|
$title = Title::newFromText( 'RecentChanges', NS_SPECIAL );
|
|
$context->setTitle( $title );
|
|
|
|
return $context;
|
|
}
|
|
}
|