mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-13 17:27:20 +00:00
Merge "Cleanup filter id handling on Special:AbuseFilter/history"
This commit is contained in:
commit
42525e4d5a
|
@ -7,7 +7,7 @@ class AbuseFilterViewHistory extends AbuseFilterView {
|
|||
*/
|
||||
public function __construct( SpecialAbuseFilter $page, $params ) {
|
||||
parent::__construct( $page, $params );
|
||||
$this->mFilter = $this->mParams[1] ?? null;
|
||||
$this->mFilter = $this->mParams['filter'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,9 +16,7 @@ class AbuseFilterViewHistory extends AbuseFilterView {
|
|||
public function show() {
|
||||
$out = $this->getOutput();
|
||||
$out->enableOOUI();
|
||||
$filter = $this->getRequest()->getText( 'filter' ) ?: $this->mFilter;
|
||||
// Ensure the parameter is a valid filter ID
|
||||
$filter = (int)$filter;
|
||||
$filter = $this->getRequest()->getIntOrNull( 'filter' ) ?: $this->mFilter;
|
||||
|
||||
if ( $filter ) {
|
||||
$out->setPageTitle( $this->msg( 'abusefilter-history' )->numParams( $filter ) );
|
||||
|
|
|
@ -4,7 +4,7 @@ use MediaWiki\Linker\LinkRenderer;
|
|||
|
||||
class AbuseFilterHistoryPager extends TablePager {
|
||||
/**
|
||||
* @var int The filter ID
|
||||
* @var int|null The filter ID
|
||||
*/
|
||||
public $mFilter;
|
||||
/**
|
||||
|
@ -17,12 +17,12 @@ class AbuseFilterHistoryPager extends TablePager {
|
|||
public $mUser;
|
||||
|
||||
/**
|
||||
* @param int $filter
|
||||
* @param ?int $filter
|
||||
* @param AbuseFilterViewHistory $page
|
||||
* @param string $user User name
|
||||
* @param LinkRenderer $linkRenderer
|
||||
*/
|
||||
public function __construct( int $filter, AbuseFilterViewHistory $page, $user,
|
||||
public function __construct( ?int $filter, AbuseFilterViewHistory $page, $user,
|
||||
LinkRenderer $linkRenderer ) {
|
||||
parent::__construct( $page->getContext(), $linkRenderer );
|
||||
$this->mFilter = $filter;
|
||||
|
@ -252,6 +252,7 @@ class AbuseFilterHistoryPager extends TablePager {
|
|||
* @return Title
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->mPage->getTitle( 'history/' . $this->mFilter );
|
||||
$subpage = $this->mFilter ? ( 'history/' . $this->mFilter ) : 'history';
|
||||
return $this->mPage->getTitle( $subpage );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,9 +114,7 @@ class SpecialAbuseFilter extends AbuseFilterSpecialPage {
|
|||
|
||||
if ( $params[0] === 'history' || $params[0] === 'log' ) {
|
||||
if ( count( $params ) <= 2 ) {
|
||||
if ( isset( $params[1] ) ) {
|
||||
$params[1] = (int)$params[1];
|
||||
}
|
||||
$params = isset( $params[1] ) ? [ 'filter' => (int)$params[1] ] : [];
|
||||
return [ AbuseFilterViewHistory::class, 'recentchanges', $params ];
|
||||
}
|
||||
if ( count( $params ) === 4 && $params[2] === 'item' ) {
|
||||
|
|
|
@ -20,16 +20,16 @@ class SpecialAbuseFilterTest extends MediaWikiUnitTestCase {
|
|||
[ 'foo', AbuseFilterViewList::class, 'home' ],
|
||||
[ '1', AbuseFilterViewEdit::class, 'edit', [ 'filter' => 1 ] ],
|
||||
[ 'new', AbuseFilterViewEdit::class, 'edit', [ 'filter' => null ] ],
|
||||
[ 'history', AbuseFilterViewHistory::class, 'recentchanges', [ 'history' ] ],
|
||||
[ 'history/1', AbuseFilterViewHistory::class, 'recentchanges', [ 'history', 1 ] ],
|
||||
[ 'history', AbuseFilterViewHistory::class, 'recentchanges', [] ],
|
||||
[ 'history/1', AbuseFilterViewHistory::class, 'recentchanges', [ 'filter' => 1 ] ],
|
||||
[ 'history/1/item/2', AbuseFilterViewEdit::class, '', [ 'filter' => 1, 'history' => 2 ] ],
|
||||
[ 'history/foo/bar', AbuseFilterViewList::class, 'home' ],
|
||||
[ 'history/1/diff/2/3', AbuseFilterViewDiff::class, '', [ 'history', '1', 'diff', '2', '3' ] ],
|
||||
[ 'history/1/diff/prev/3', AbuseFilterViewDiff::class, '', [ 'history', '1', 'diff', 'prev', '3' ] ],
|
||||
[ 'history/1/diff/prev/cur', AbuseFilterViewDiff::class, '', [ 'history', '1', 'diff', 'prev', 'cur' ] ],
|
||||
[ 'history/1/foo/2/3', AbuseFilterViewList::class, 'home' ],
|
||||
[ 'log', AbuseFilterViewHistory::class, 'recentchanges', [ 'log' ] ],
|
||||
[ 'log/1', AbuseFilterViewHistory::class, 'recentchanges', [ 'log', 1 ] ],
|
||||
[ 'log', AbuseFilterViewHistory::class, 'recentchanges', [] ],
|
||||
[ 'log/1', AbuseFilterViewHistory::class, 'recentchanges', [ 'filter' => 1 ] ],
|
||||
[ 'log/1/item/2', AbuseFilterViewEdit::class, '', [ 'filter' => 1, 'history' => 2 ] ],
|
||||
[ 'log/foo/bar', AbuseFilterViewList::class, 'home' ],
|
||||
[ 'log/1/diff/2/3', AbuseFilterViewDiff::class, '', [ 'log', '1', 'diff', '2', '3' ] ],
|
||||
|
|
Loading…
Reference in a new issue