[MediaWiki-commits] [Gerrit] Remove expensive synchronous template validation - change (mediawiki...UploadWizard)

2014-09-08 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Remove expensive synchronous template validation
..


Remove expensive synchronous template validation

In 1.25 the async parameter gets deprecated. This very advanced
feature requires such deep knowledge of how Commons works
that I believe the users who know about it don't really need the
validation. Furthermore, the worst case scenario is just that junk
gets added to a section of the file page's wikitext by a user not
knowing what they're doing. Which doesn't seem like a big deal, since
it can always be fixed after publication.

Change-Id: I6fd8972e9dd9c578d437245598f2d837bd62085d
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/854
---
M UploadWizardHooks.php
M i18n/en.json
M resources/mw.UploadWizardLicenseInput.js
3 files changed, 0 insertions(+), 94 deletions(-)

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



diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index 0f92db4..220a6fa 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -349,7 +349,6 @@
'mwe-upwiz-error-license-wikitext-missing',
'mwe-upwiz-error-license-wikitext-too-short',
'mwe-upwiz-error-license-wikitext-too-long',
-   'mwe-upwiz-error-license-wikitext-invalid',
'mwe-upwiz-details-error-count',
'mwe-upwiz-license-cc-by-sa-4.0',
'mwe-upwiz-license-cc-by-sa-3.0',
diff --git a/i18n/en.json b/i18n/en.json
index 21e587a..930396f 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -221,7 +221,6 @@
"mwe-upwiz-error-license-wikitext-missing": "You selected an option 
which requires you to enter wikitext.",
"mwe-upwiz-error-license-wikitext-too-short": "The wikitext here is too 
short to be a license",
"mwe-upwiz-error-license-wikitext-too-long": "The wikitext you entered 
is too long.",
-   "mwe-upwiz-error-license-wikitext-invalid": "This does not seem to be 
valid wikitext, or does not contain a license.",
"mwe-upwiz-details-error-count": "There {{PLURAL:$1|is one error|are $1 
errors}} with the {{PLURAL:$2|form|forms}} above. Correct the 
{{PLURAL:$1|error|errors}}, and try submitting again.",
"mwe-upwiz-too-many-files-ok": "OK",
"mwe-upwiz-too-many-files-text": "You can only upload $1 
{{PLURAL:$1|file|files}} at once but you tried to upload $2 
{{PLURAL:$2|file|files}} in total. Please try again with fewer files!",
diff --git a/resources/mw.UploadWizardLicenseInput.js 
b/resources/mw.UploadWizardLicenseInput.js
index 6056eae..50cc6dc 100644
--- a/resources/mw.UploadWizardLicenseInput.js
+++ b/resources/mw.UploadWizardLicenseInput.js
@@ -15,9 +15,6 @@
 
 ( function( mw, $ ) {
 
-var catNsId = mw.config.get( 'wgNamespaceIds' ).category,
-   templateNsId = mw.config.get( 'wgNamespaceIds' ).template;
-
 mw.UploadWizardLicenseInput = function( selector, values, config, count, api ) 
{
this.count = count;
 
@@ -442,8 +439,6 @@
errors.push( [ $errorEl, 
'mwe-upwiz-error-license-wikitext-too-short' ] );
} else if ( text.length > 
mw.UploadWizard.config.maxCustomLicenseLength ) {
errors.push( [ $errorEl, 
'mwe-upwiz-error-license-wikitext-too-long' ] );
-   } else if ( !input.validateWikiText( text ) ) {
-   errors.push( [ $errorEl, 
'mwe-upwiz-error-license-wikitext-invalid' ] );
}
} );
}
@@ -476,93 +471,6 @@
 */
isSet: function() {
return this.getSelectedInputs().length > 0;
-   },
-
-
-   /**
-* Attempt to determine if wikitext parses... and maybe does it contain 
a license tag
-* @return boolean
-*/
-   validateWikiText: function( text ) {
-   var ast, templates, found, licenseCategory,
-   input = this,
-   parser = new mw.jqueryMsg.parser();
-
-   try {
-   ast = parser.wikiTextToAst( text );
-   } catch (e) {
-   mw.log.warn( e.message );
-   return false;
-   }
-
-   function accumTemplates( node, templates ) {
-   var nodeName, lcNodeName;
-
-   if ( typeof node === 'object' ) {
-   nodeName = node[0];
-   lcNodeName = nodeName.toLowerCase();
-
-   // templates like Self are special cased, as it 
is not a license tag and also reparses its string argument

[MediaWiki-commits] [Gerrit] Remove expensive synchronous template validation - change (mediawiki...UploadWizard)

2014-09-04 Thread Gilles (Code Review)
Gilles has uploaded a new change for review.

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

Change subject: Remove expensive synchronous template validation
..

Remove expensive synchronous template validation

In 1.25 the async parameter gets deprecated. This very advanced
feature requires such deep knowledge of how Commons works
that I believe the users who know about it don't really need the
validation. Furthermore, the worst case scenario is just that junk
gets added to a section of the file page's wikitext by a user not
knowing what they're doing. Which doesn't seem like a big deal, since
it can always be fixed after publication.

Change-Id: I6fd8972e9dd9c578d437245598f2d837bd62085d
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/854
---
M UploadWizardHooks.php
M i18n/en.json
M resources/mw.UploadWizardLicenseInput.js
3 files changed, 0 insertions(+), 91 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/89/158589/1

diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index 0f92db4..220a6fa 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -349,7 +349,6 @@
'mwe-upwiz-error-license-wikitext-missing',
'mwe-upwiz-error-license-wikitext-too-short',
'mwe-upwiz-error-license-wikitext-too-long',
-   'mwe-upwiz-error-license-wikitext-invalid',
'mwe-upwiz-details-error-count',
'mwe-upwiz-license-cc-by-sa-4.0',
'mwe-upwiz-license-cc-by-sa-3.0',
diff --git a/i18n/en.json b/i18n/en.json
index 21e587a..930396f 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -221,7 +221,6 @@
"mwe-upwiz-error-license-wikitext-missing": "You selected an option 
which requires you to enter wikitext.",
"mwe-upwiz-error-license-wikitext-too-short": "The wikitext here is too 
short to be a license",
"mwe-upwiz-error-license-wikitext-too-long": "The wikitext you entered 
is too long.",
-   "mwe-upwiz-error-license-wikitext-invalid": "This does not seem to be 
valid wikitext, or does not contain a license.",
"mwe-upwiz-details-error-count": "There {{PLURAL:$1|is one error|are $1 
errors}} with the {{PLURAL:$2|form|forms}} above. Correct the 
{{PLURAL:$1|error|errors}}, and try submitting again.",
"mwe-upwiz-too-many-files-ok": "OK",
"mwe-upwiz-too-many-files-text": "You can only upload $1 
{{PLURAL:$1|file|files}} at once but you tried to upload $2 
{{PLURAL:$2|file|files}} in total. Please try again with fewer files!",
diff --git a/resources/mw.UploadWizardLicenseInput.js 
b/resources/mw.UploadWizardLicenseInput.js
index 6056eae..8a9e154 100644
--- a/resources/mw.UploadWizardLicenseInput.js
+++ b/resources/mw.UploadWizardLicenseInput.js
@@ -442,8 +442,6 @@
errors.push( [ $errorEl, 
'mwe-upwiz-error-license-wikitext-too-short' ] );
} else if ( text.length > 
mw.UploadWizard.config.maxCustomLicenseLength ) {
errors.push( [ $errorEl, 
'mwe-upwiz-error-license-wikitext-too-long' ] );
-   } else if ( !input.validateWikiText( text ) ) {
-   errors.push( [ $errorEl, 
'mwe-upwiz-error-license-wikitext-invalid' ] );
}
} );
}
@@ -476,93 +474,6 @@
 */
isSet: function() {
return this.getSelectedInputs().length > 0;
-   },
-
-
-   /**
-* Attempt to determine if wikitext parses... and maybe does it contain 
a license tag
-* @return boolean
-*/
-   validateWikiText: function( text ) {
-   var ast, templates, found, licenseCategory,
-   input = this,
-   parser = new mw.jqueryMsg.parser();
-
-   try {
-   ast = parser.wikiTextToAst( text );
-   } catch (e) {
-   mw.log.warn( e.message );
-   return false;
-   }
-
-   function accumTemplates( node, templates ) {
-   var nodeName, lcNodeName;
-
-   if ( typeof node === 'object' ) {
-   nodeName = node[0];
-   lcNodeName = nodeName.toLowerCase();
-
-   // templates like Self are special cased, as it 
is not a license tag and also reparses its string arguments into templates
-   // e.g.  {{self|Cc-by-sa-3.0}}  --> we should 
add 'Cc-by-sa-3.0' to the templates
-   if (
-   
mw.UploadWizard.config