Catrope has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/377377 )
Change subject: Hide RC/WL related preferences as appropriate ...................................................................... Hide RC/WL related preferences as appropriate If the new filters are enabled on the RC page, hide the RC-related preferences. This was already being done, but the logic didn't take the new opt-out preference into account. If the new filters are enabled on the Watchlist, hide the WL-related preferences too. If the new filters are enabled on both, hide the threshold preference as well. Bug: T175611 Change-Id: Ia9355fb95e82c72185d2df93d48115f718fabe99 --- M includes/Hooks.php M includes/Hooks/PreferencesHookHandler.php 2 files changed, 35 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES refs/changes/77/377377/1 diff --git a/includes/Hooks.php b/includes/Hooks.php index bc3d8ec..6f72133 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -790,6 +790,18 @@ return $context->getTitle()->isSpecial( 'Watchlist' ); } + public static function isRCStructuredUiEnabled( IContextSource $context ) { + $page = new SpecialRecentChanges(); + $page->setContext( $context ); + return $page->isStructuredFilterUiEnabled(); + } + + public static function isWLStructuredUiEnabled( IContextSource $context ) { + $page = new SpecialWatchlist(); + $page->setContext( $context ); + return $page->isStructuredFilterUiEnabled(); + } + /** * @param IContextSource $context * @return bool Whether highlights should be shown @@ -812,16 +824,12 @@ } if ( self::isRCPage( $context ) ) { - $page = new SpecialRecentChanges(); - $page->setContext( $context ); - return !$page->isStructuredFilterUiEnabled() && + return !self::isRCStructuredUiEnabled() && $user->getBoolOption( 'ores-damaging-flag-rc' ); } if ( self::isWLPage( $context ) ) { - $page = new SpecialWatchlist(); - $page->setContext( $context ); - return !$page->isStructuredFilterUiEnabled() && + return !self::isWLStructuredUiEnabled() && $user->getBoolOption( 'oresHighlight' ); } diff --git a/includes/Hooks/PreferencesHookHandler.php b/includes/Hooks/PreferencesHookHandler.php index a0452ae..26b34a5 100644 --- a/includes/Hooks/PreferencesHookHandler.php +++ b/includes/Hooks/PreferencesHookHandler.php @@ -3,6 +3,9 @@ namespace ORES\Hooks; use ORES\Hooks; +use DerivativeContext; +use DerivativeRequest; +use RequestContext; use User; class PreferencesHookHandler { @@ -72,14 +75,27 @@ 'section' => 'rc/advancedrc', 'label-message' => 'ores-pref-rc-hidenondamaging', ]; - // Hide RC prefs if enhanced filters are enabled - if ( $user->getBoolOption( 'rcenhancedfilters' ) ) { - // HACK: Note that this only hides the preferences on the preferences page, - // it does not cause them to behave as if they're set to their default value, - // because this hook only runs on the preferences page. + + // Hide RC/wL prefs if enhanced filters are enabled + $context = new DerivativeContext( RequestContext::getMain() ); + $context->setUser( $user ); + $context->setRequest( new DerivativeRequest( $context->getRequest(), [] ) ); + $rcFiltersEnabled = Hooks::isRCStructuredUiEnabled( $context ); + $wlFiltersEnabled = Hooks::isWLStructuredUiEnabled( $context ); + // HACK: Note that this only hides the preferences on the preferences page, + // it does not cause them to behave as if they're set to their default value, + // because this hook only runs on the preferences page. + if ( $rcFiltersEnabled ) { $wgHiddenPrefs[] = 'oresRCHideNonDamaging'; $wgHiddenPrefs[] = 'ores-damaging-flag-rc'; } + if ( $wlFiltersEnabled ) { + $wgHiddenPrefs[] = 'oresWatchlistHideNonDamaging'; + $wgHiddenPrefs[] = 'oresHighlight'; + } + if ( $rcFiltersEnabled && $wlFiltersEnabled ) { + $wgHiddenPrefs[] = 'oresDamagingPref'; + } } } -- To view, visit https://gerrit.wikimedia.org/r/377377 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia9355fb95e82c72185d2df93d48115f718fabe99 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ORES Gerrit-Branch: master Gerrit-Owner: Catrope <r...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits