Disable search for global filters

It solves a bug and other problems, especially related to permissions.
Tested as much as I could but with an imperfect global filters system,
so there may still be something wrong.

Bug: T191539
Change-Id: I0771fa048d21031ed1e0f8a6909213bdb869a5ed
This commit is contained in:
Daimona Eaytoy 2018-04-05 18:39:04 +02:00
parent 714735ff6b
commit 17c51445db
2 changed files with 22 additions and 15 deletions

View file

@ -29,10 +29,6 @@ class AbuseFilterViewList extends AbuseFilterView {
$conds = [];
$deleted = $request->getVal( 'deletedfilters' );
$hidedisabled = $request->getBool( 'hidedisabled' );
if ( $this->canViewPrivate() ) {
$querypattern = $request->getVal( 'querypattern' );
$searchmode = $request->getVal( 'searchoption', 'LIKE' );
}
$defaultscope = 'all';
if ( isset( $wgAbuseFilterCentralDB ) && !$wgAbuseFilterIsCentral ) {
// Show on remote wikis as default only local filters
@ -40,6 +36,14 @@ class AbuseFilterViewList extends AbuseFilterView {
}
$scope = $request->getVal( 'rulescope', $defaultscope );
$searchEnabled = $this->canViewPrivate() && !( isset( $wgAbuseFilterCentralDB ) &&
!$wgAbuseFilterIsCentral && $scope == 'global' );
if ( $searchEnabled ) {
$querypattern = $request->getVal( 'querypattern' );
$searchmode = $request->getVal( 'searchoption', 'LIKE' );
}
if ( $deleted == 'show' ) {
# Nothing
} elseif ( $deleted == 'only' ) {
@ -99,7 +103,7 @@ class AbuseFilterViewList extends AbuseFilterView {
$this->showList(
$conds,
compact( 'deleted', 'hidedisabled', 'querypattern', 'searchmode', 'scope' )
compact( 'deleted', 'hidedisabled', 'querypattern', 'searchmode', 'scope', 'searchEnabled' )
);
}
@ -110,7 +114,13 @@ class AbuseFilterViewList extends AbuseFilterView {
Xml::element( 'h2', null, $this->msg( 'abusefilter-list' )->parse() )
);
if ( $this->canViewPrivate() ) {
$deleted = $optarray['deleted'];
$hidedisabled = $optarray['hidedisabled'];
$scope = $optarray['scope'];
$searchEnabled = $optarray['searchEnabled'];
if ( $searchEnabled ) {
$querypattern = $optarray['querypattern'];
$searchmode = $optarray['searchmode'];
} else {
@ -118,16 +128,11 @@ class AbuseFilterViewList extends AbuseFilterView {
$searchmode = '';
}
$deleted = $optarray['deleted'];
$hidedisabled = $optarray['hidedisabled'];
$scope = $optarray['scope'];
if ( isset( $wgAbuseFilterCentralDB ) && !$wgAbuseFilterIsCentral && $scope == 'global' ) {
$pager = new GlobalAbuseFilterPager(
$this,
$conds,
$this->linkRenderer,
[ $querypattern, $searchmode ]
$this->linkRenderer
);
} else {
$pager = new AbuseFilterPager(
@ -184,7 +189,9 @@ class AbuseFilterViewList extends AbuseFilterView {
'selected' => $hidedisabled,
];
if ( $this->canViewPrivate() ) {
// ToDo: Since this is only for saving space, we should convert it
// to use a 'hide-if'
if ( $searchEnabled ) {
$formDescriptor['querypattern'] = [
'name' => 'querypattern',
'type' => 'text',

View file

@ -4,8 +4,8 @@
* Class to build paginated filter list for wikis using global abuse filters
*/
class GlobalAbuseFilterPager extends AbuseFilterPager {
function __construct( $page, $conds, $linkRenderer, $query ) {
parent::__construct( $page, $conds, $linkRenderer, $query );
function __construct( $page, $conds, $linkRenderer ) {
parent::__construct( $page, $conds, $linkRenderer, [ '', 'LIKE' ] );
global $wgAbuseFilterCentralDB;
$this->mDb = wfGetDB( DB_REPLICA, [], $wgAbuseFilterCentralDB );
}