X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FChangesListSpecialPage.php;h=09ed3c444068f57d4819ec4be9d5918312c60625;hb=9af9555c532da70b4daf625910039e70280bf84d;hp=4d02ddc5edd0352e41f255b967307e1f03910551;hpb=3345b70b63ec828a58796b7f39a063c703f50339;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 4d02ddc5ed..09ed3c4440 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -960,7 +960,90 @@ abstract class ChangesListSpecialPage extends SpecialPage { * @param FormOptions $opts */ public function validateOptions( FormOptions $opts ) { - // nothing by default + if ( $this->fixContradictoryOptions( $opts ) ) { + $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) ); + $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) ); + } + } + + /** + * Fix invalid options by resetting pairs that should never appear together. + * + * @param FormOptions $opts + * @return bool True if any option was reset + */ + private function fixContradictoryOptions( FormOptions $opts ) { + $fixed = $this->fixBackwardsCompatibilityOptions( $opts ); + + foreach ( $this->filterGroups as $filterGroup ) { + if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) { + $filters = $filterGroup->getFilters(); + + if ( count( $filters ) === 1 ) { + // legacy boolean filters should not be considered + continue; + } + + $allInGroupEnabled = array_reduce( + $filters, + function ( $carry, $filter ) use ( $opts ) { + return $carry && $opts[ $filter->getName() ]; + }, + /* initialValue */ count( $filters ) > 0 + ); + + if ( $allInGroupEnabled ) { + foreach ( $filters as $filter ) { + $opts[ $filter->getName() ] = false; + } + + $fixed = true; + } + } + } + + return $fixed; + } + + /** + * Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards + * compatibility. + * + * This is deprecated and may be removed. + * + * @param FormOptions $opts + * @return bool True if this change was mode + */ + private function fixBackwardsCompatibilityOptions( FormOptions $opts ) { + if ( $opts['hideanons'] && $opts['hideliu'] ) { + $opts->reset( 'hideanons' ); + if ( !$opts['hidebots'] ) { + $opts->reset( 'hideliu' ); + $opts['hidehumans'] = 1; + } + + return true; + } + + return false; + } + + /** + * Convert parameters values from true/false to 1/0 + * so they are not omitted by wfArrayToCgi() + * Bug 36524 + * + * @param array $params + * @return array + */ + protected function convertParamsForLink( $params ) { + foreach ( $params as &$value ) { + if ( $value === false ) { + $value = '0'; + } + } + unset( $value ); + return $params; } /** @@ -999,7 +1082,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { // Namespace filtering if ( $opts[ 'namespace' ] !== '' ) { - $namespaces = explode( ',', $opts[ 'namespace' ] ); + $namespaces = explode( ';', $opts[ 'namespace' ] ); if ( $opts[ 'associated' ] ) { $associatedNamespaces = array_map( @@ -1049,15 +1132,6 @@ abstract class ChangesListSpecialPage extends SpecialPage { '' ); - // It makes no sense to hide both anons and logged-in users. When this occurs, try a guess on - // what the user meant and either show only bots or force anons to be shown. - - // ------- - - // XXX: We're no longer doing this handling. To preserve back-compat, we need to complete - // T151873 (particularly the hideanons/hideliu/hidebots/hidehumans part) in conjunction - // with merging this. - if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts ) ) { @@ -1284,7 +1358,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { $aboveNewcomer = $dbr->makeList( [ 'user_editcount >= ' . intval( $wgLearnerEdits ), - 'user_registration <= ' . $dbr->timestamp( $learnerCutoff ), + 'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ), ], IDatabase::LIST_AND ); @@ -1292,7 +1366,8 @@ abstract class ChangesListSpecialPage extends SpecialPage { $aboveLearner = $dbr->makeList( [ 'user_editcount >= ' . intval( $wgExperiencedUserEdits ), - 'user_registration <= ' . $dbr->timestamp( $experiencedUserCutoff ), + 'user_registration <= ' . + $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ), ], IDatabase::LIST_AND );