use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
/**
* A special page that lists last changes made to the wiki,
if ( ( $config->get( 'EnotifWatchlist' ) || $config->get( 'ShowUpdatedMarker' ) )
&& $request->getVal( 'reset' )
&& $request->wasPosted()
+ && $user->matchEditToken( $request->getVal( 'token' ) )
) {
$user->clearAllNotifications();
$output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
/**
* @inheritdoc
*/
- protected function registerFiltersFromDefinitions( array $definition ) {
- foreach ( $definition as $groupName => &$groupDefinition ) {
- foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
- if ( isset( $filterDefinition['showHideSuffix'] ) ) {
- $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
- }
- }
+ protected function transformFilterDefinition( array $filterDefinition ) {
+ if ( isset( $filterDefinition['showHideSuffix'] ) ) {
+ $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
}
- parent::registerFiltersFromDefinitions( $definition );
+ return $filterDefinition;
}
/**
$hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
$reviewStatus = $this->getFilterGroup( 'reviewStatus' );
- $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
- $hidePatrolled->setDefault( $user->getBoolOption( 'watchlisthidepatrolled' ) );
+ if ( $reviewStatus !== null ) {
+ // Conditional on feature being available and rights
+ $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
+ $hidePatrolled->setDefault( $user->getBoolOption( 'watchlisthidepatrolled' ) );
+ }
$authorship = $this->getFilterGroup( 'authorship' );
$hideMyself = $authorship->getFilter( 'hidemyself' );
$changeType = $this->getFilterGroup( 'changeType' );
$hideCategorization = $changeType->getFilter( 'hidecategorization' );
- $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
+ if ( $hideCategorization !== null ) {
+ // Conditional on feature being available
+ $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
+ }
}
/**
$opts->add( 'days', $user->getOption( 'watchlistdays' ), FormOptions::FLOAT );
$opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' ) );
- if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
- // The user has submitted the form, so we dont need the default values
- return $opts;
- }
return $opts;
}
}
}
+ if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
+ $allBooleansFalse = [];
+
+ // If the user submitted the form, start with a baseline of "all
+ // booleans are false", then change the ones they checked. This
+ // means we ignore the defaults.
+
+ // This is how we handle the fact that HTML forms don't submit
+ // unchecked boxes.
+ foreach ( $this->filterGroups as $filterGroup ) {
+ if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
+ foreach ( $filterGroup->getFilters() as $filter ) {
+ $allBooleansFalse[$filter->getName()] = false;
+ }
+ }
+ }
+
+ $params = $params + $allBooleansFalse;
+ }
+
// Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
// methods defined on WebRequest and removing this dependency would cause some code duplication.
$request = new DerivativeRequest( $this->getRequest(), $params );
'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
Xml::submitButton( $this->msg( 'enotif_reset' )->text(),
[ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
+ Html::hidden( 'token', $user->getEditToken() ) . "\n" .
Html::hidden( 'reset', 'all' ) . "\n";
foreach ( $nondefaults as $key => $value ) {
$form .= Html::hidden( $key, $value ) . "\n";