Jackmcbarn has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/160367

Change subject: Let wikis disable "Allow saving code with errors"
......................................................................

Let wikis disable "Allow saving code with errors"

Add $wgScribuntoAllowSavingBadCode. When set to false, the option allowing
users to save code with syntax errors will be removed.

Change-Id: Icb3da00a86b9773287dcd0c9277ad61446ec07ce
---
M Scribunto.php
M common/Hooks.php
2 files changed, 24 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto 
refs/changes/67/160367/1

diff --git a/Scribunto.php b/Scribunto.php
index 7cc3aa2..d9e9354 100644
--- a/Scribunto.php
+++ b/Scribunto.php
@@ -170,6 +170,11 @@
  */
 $wgScribuntoUseCodeEditor = false;
 
+/**
+ * Set to false to force all code to be checked for syntax errors before it 
can be saved
+ */
+$wgScribuntoAllowSavingBadCode = true;
+
 define( 'NS_MODULE', 828 );
 define( 'NS_MODULE_TALK', 829 );
 
diff --git a/common/Hooks.php b/common/Hooks.php
index 750e5db..8e2aa08 100644
--- a/common/Hooks.php
+++ b/common/Hooks.php
@@ -251,17 +251,20 @@
                        return true;
                }
 
-               $req = RequestContext::getMain()->getRequest();
-               $name = 'scribunto_ignore_errors';
+               global $wgScribuntoAllowSavingBadCode;
+               if ( $wgScribuntoAllowSavingBadCode ) {
+                       $req = RequestContext::getMain()->getRequest();
+                       $name = 'scribunto_ignore_errors';
 
-               $attribs = array(
-                       'tabindex' => ++$tabindex,
-                       'id' => "mw-$name",
-               );
-               $checkboxes['scribunto'] =
-                       Xml::check( $name, $req->getCheck( $name ), $attribs ) .
-                       ' ' .
-                       Xml::label( wfMessage( 'scribunto-ignore-errors' 
)->text(), "mw-$name" );
+                       $attribs = array(
+                               'tabindex' => ++$tabindex,
+                               'id' => "mw-$name",
+                       );
+                       $checkboxes['scribunto'] =
+                               Xml::check( $name, $req->getCheck( $name ), 
$attribs ) .
+                               ' ' .
+                               Xml::label( wfMessage( 
'scribunto-ignore-errors' )->text(), "mw-$name" );
+               }
 
                // While we're here, lets set up the edit module
                global $wgOut;
@@ -308,9 +311,12 @@
                        return true;
                }
 
-               $req = RequestContext::getMain()->getRequest();
-               if ( $req->getBool( 'scribunto_ignore_errors' ) ) {
-                       return true;
+               global $wgScribuntoAllowSavingBadCode;
+               if ( $wgScribuntoAllowSavingBadCode ) {
+                       $req = RequestContext::getMain()->getRequest();
+                       if ( $req->getBool( 'scribunto_ignore_errors' ) ) {
+                               return true;
+                       }
                }
 
                $engine = Scribunto::newDefaultEngine();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb3da00a86b9773287dcd0c9277ad61446ec07ce
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <jackmcb...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to