jenkins-bot has submitted this change and it was merged.

Change subject: (Re-)Add ability to work even if preference is hidden
......................................................................


(Re-)Add ability to work even if preference is hidden

We want to mark the preference as hidden as we then subsequently remove it.
However, if a preference is hidden and we don't set ignoreHidden=true, then
it will always fail to trigger VisualEditor, which is sad. Consequently, add
this awful hack until deployment of VisualEditor is true for all wikis.

(We may want to refactor this enablement code a bit - it's a tad ugly. I've
added some more spacing just so you can see what's what, but…)

Change-Id: Ia43c9241b53dddb3dcb8b3edfb3b5163e19e18b1
---
M VisualEditor.hooks.php
1 file changed, 12 insertions(+), 2 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 9c9f2f3..895ad99 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -43,17 +43,27 @@
        public static function onBeforePageDisplay( &$output, &$skin ) {
                global $wgVisualEditorNamespaces, 
$wgVisualEditorEnableEventLogging;
                if (
-                       // Disable on redirect pages until redirects are 
editable
+                       // BUG 47328: Disable on redirect pages until redirects 
are editable
                        !$skin->getTitle()->isRedirect() &&
+
                        // User has the 'visualeditor-enable' preference set
-                       $skin->getUser()->getOption( 'visualeditor-enable' ) &&
+                       $skin->getUser()->getOption(
+                               'visualeditor-enable',
+                               /*default=*/ false,
+                               // HACK: Allows us to suppress the option in 
preferences when it's on for all.
+                               /*ignoreHidden=*/ true
+                       ) &&
+
+                       // 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 )
                        ) &&
+
                        // Only use VisualEditor if the page is wikitext, not 
CSS/JS
                        $skin->getTitle()->getContentModel() === 
CONTENT_MODEL_WIKITEXT
                ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/70655
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia43c9241b53dddb3dcb8b3edfb3b5163e19e18b1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Jforrester <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to