Santhosh has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397408 )

Change subject: Guard against js errors for invalid/corrupted(?) templates
......................................................................

Guard against js errors for invalid/corrupted(?) templates

This just prevents a potential js error when a templates data-mw
has no parts attribute, which I had assumed impossible.

I tried to reproduce the issue, but failed.

Bug: T182528
Change-Id: I68f42397aec336af84f568b51c71ef62e85d7957
---
M modules/tools/ext.cx.tools.template.js
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/08/397408/1

diff --git a/modules/tools/ext.cx.tools.template.js 
b/modules/tools/ext.cx.tools.template.js
index 13e4d0d..e36d248 100644
--- a/modules/tools/ext.cx.tools.template.js
+++ b/modules/tools/ext.cx.tools.template.js
@@ -68,6 +68,11 @@
                        }
                }
 
+               if ( !mwData.parts ) {
+                       mw.log( '[CX] data-mw for Template#' + 
this.$template.attr( 'id' ) + ' has no parts.' );
+                       return $.Deferred().reject().promise();
+               }
+
                if ( mwData.parts.length > 1 ) {
                        mw.log( '[CX] Skipping multipart template for now for 
Template#' + this.$template.attr( 'id' ) );
                        return $.Deferred().reject().promise();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I68f42397aec336af84f568b51c71ef62e85d7957
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

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

Reply via email to