jenkins-bot has submitted this change and it was merged.
Change subject: RC filter: hidebyothers
......................................................................
RC filter: hidebyothers
Allows hiding edits by other users on
Special:RecentChanges.
It is not available in the current UI but
will be used by the ERI project.
Bug: T149859
Change-Id: I8c1e2238a41d6f5e5ac44cc12cb02a6b4271c237
---
M includes/specialpage/ChangesListSpecialPage.php
M tests/phpunit/includes/specials/SpecialRecentchangesTest.php
2 files changed, 97 insertions(+), 1 deletion(-)
Approvals:
Mattflaschen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/specialpage/ChangesListSpecialPage.php
b/includes/specialpage/ChangesListSpecialPage.php
index 01782f3..cb13840 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -145,6 +145,7 @@
$opts->add( 'hideliu', false );
$opts->add( 'hidepatrolled', false );
$opts->add( 'hidemyself', false );
+ $opts->add( 'hidebyothers', false );
if ( $config->get( 'RCWatchCategoryMembership' ) ) {
$opts->add( 'hidecategorization', false );
@@ -247,6 +248,7 @@
$conds[] = 'rc_user != 0';
}
}
+
if ( $opts['hidemyself'] ) {
if ( $user->getId() ) {
$conds[] = 'rc_user != ' . $dbr->addQuotes(
$user->getId() );
@@ -254,6 +256,14 @@
$conds[] = 'rc_user_text != ' .
$dbr->addQuotes( $user->getName() );
}
}
+ if ( $opts['hidebyothers'] ) {
+ if ( $user->getId() ) {
+ $conds[] = 'rc_user = ' . $dbr->addQuotes(
$user->getId() );
+ } else {
+ $conds[] = 'rc_user_text = ' . $dbr->addQuotes(
$user->getName() );
+ }
+ }
+
if ( $this->getConfig()->get( 'RCWatchCategoryMembership' )
&& $opts['hidecategorization'] === true
) {
diff --git a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
index cc16e5f..c51217c 100644
--- a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
+++ b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
@@ -22,9 +22,17 @@
protected $rc;
/** helper to test SpecialRecentchanges::buildMainQueryConds() */
- private function assertConditions( $expected, $requestOptions = null,
$message = '' ) {
+ private function assertConditions(
+ $expected,
+ $requestOptions = null,
+ $message = '',
+ $user = null
+ ) {
$context = new RequestContext;
$context->setRequest( new FauxRequest( $requestOptions ) );
+ if ( $user ) {
+ $context->setUser( $user );
+ }
# setup the rc object
$this->rc = new SpecialRecentChanges();
@@ -129,4 +137,82 @@
[ NS_TALK, NS_MAIN ],
];
}
+
+ public function testRcHidemyselfFilter() {
+ $user = $this->getTestUser()->getUser();
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user != '{$user->getId()}'",
+ 1 => "rc_type != '6'",
+ ],
+ [
+ 'hidemyself' => 1,
+ ],
+ "rc conditions: hidemyself=1 (logged in)",
+ $user
+ );
+
+ $user = User::newFromName( '10.11.12.13', false );
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user_text != '10.11.12.13'",
+ 1 => "rc_type != '6'",
+ ],
+ [
+ 'hidemyself' => 1,
+ ],
+ "rc conditions: hidemyself=1 (anon)",
+ $user
+ );
+ }
+
+ public function testRcHidebyothersFilter() {
+ $user = $this->getTestUser()->getUser();
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user = '{$user->getId()}'",
+ 1 => "rc_type != '6'",
+ ],
+ [
+ 'hidebyothers' => 1,
+ ],
+ "rc conditions: hidebyothers=1 (logged in)",
+ $user
+ );
+
+ $user = User::newFromName( '10.11.12.13', false );
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user_text = '10.11.12.13'",
+ 1 => "rc_type != '6'",
+ ],
+ [
+ 'hidebyothers' => 1,
+ ],
+ "rc conditions: hidebyothers=1 (anon)",
+ $user
+ );
+ }
+
+ public function testRcHidemyselfHidebyothersFilter() {
+ $user = $this->getTestUser()->getUser();
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user != '{$user->getId()}'",
+ 1 => "rc_user = '{$user->getId()}'",
+ 2 => "rc_type != '6'",
+ ],
+ [
+ 'hidemyself' => 1,
+ 'hidebyothers' => 1,
+ ],
+ "rc conditions: hidemyself=1 hidebyothers=1 (logged
in)",
+ $user
+ );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/321372
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8c1e2238a41d6f5e5ac44cc12cb02a6b4271c237
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Mooeypoo <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits