From 712a7e96748f1ffa971411e04ffcf22c2fb0c0da Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sat, 20 Jul 2013 02:52:53 +0200 Subject: [PATCH 1/2] Don't set ignoreHidden=true when calling User::getOption This parameter is confusingly named, but the purpose of it is is to undo what wgHiddenPrefs does. So instead of returning the default value and ignoring the value previously stored in the user's preferences, setting ignoreHidden=true would instead give us the stored value dispite it being no longer visible on Special:Preferences. We also don't need to do $defaulOverride since the default (null) is falsy already. Change-Id: I397ac16aae4a2ed02687dff8552548c662f5d9bb --- VisualEditor.hooks.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index e3795bc704..3d55ffd97b 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -62,12 +62,7 @@ class VisualEditorHooks { !$skin->getTitle()->isRedirect() && // User has the 'visualeditor-enable' preference set - $skin->getUser()->getOption( - 'visualeditor-enable', - /*default=*/ false, - // HACK: Allows us to suppress the option in preferences when it's on for all. - /*ignoreHidden=*/ true - ) && + $skin->getUser()->getOption( 'visualeditor-enable' ) && // The user's current skin is supported in_array( $skin->getSkinName(), self::$supportedSkins ) && From 95f135b0c8bc53a3b5d335e5eae710e67adb91a3 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 22 Jul 2013 19:50:25 +0200 Subject: [PATCH 2/2] hooks: Only check relevant page title instead of both The relevant page title is equal to the native page title if we're on a regular page (e.g. both are Foo on Foo and on Special:MovePage/Foo one is Special:MovePage and the other Foo). In that case there is no point in checking both, especially if it is with the OR condition. Change-Id: I310e638a73312afea421a399ce4c6ea9b4254cbf --- VisualEditor.hooks.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index 3d55ffd97b..e39fb9184f 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -67,12 +67,8 @@ class VisualEditorHooks { // The user's current skin is supported in_array( $skin->getSkinName(), self::$supportedSkins ) && - ( - // Article in the VisualEditor namespace - in_array( $skin->getTitle()->getNamespace(), $wgVisualEditorNamespaces ) || - // Special page action for an article in the VisualEditor namespace - in_array( $skin->getRelevantTitle()->getNamespace(), $wgVisualEditorNamespaces ) - ) && + // The current page is in a VisualEditor-enabled namespace + in_array( $skin->getRelevantTitle()->getNamespace(), $wgVisualEditorNamespaces ) && // Only use VisualEditor if the page is wikitext, not CSS/JS $skin->getTitle()->getContentModel() === CONTENT_MODEL_WIKITEXT