Santhosh has uploaded a new change for review.

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

Change subject: While adapting references, Validate whether the source has 
references list
......................................................................

While adapting references, Validate whether the source has references list

Testplan:
Translate the following article to any language
https://en.wikipedia.org/w/index.php?title=Samsung_Galaxy_A7&oldid=668069510
You will notice that the references list is missing in loaded source article.
Use source as translation and translate all sections, publish.
Publish will fail without this patch.

Bug: T104947
Change-Id: I198f5c62b78a7b9e8cf0b613e3e5a870b4c8b2fd
---
M modules/tools/ext.cx.tools.reference.js
1 file changed, 14 insertions(+), 1 deletion(-)


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

diff --git a/modules/tools/ext.cx.tools.reference.js 
b/modules/tools/ext.cx.tools.reference.js
index f85293d..c44a7ad 100644
--- a/modules/tools/ext.cx.tools.reference.js
+++ b/modules/tools/ext.cx.tools.reference.js
@@ -323,7 +323,20 @@
        }
 
        function processReferences( $section ) {
-               var $sourceSection, referenceAdaptor, isRestoredFromDraft;
+               var $sourceSection, referenceAdaptor, isRestoredFromDraft, 
$referenceLists;
+
+               $referenceLists = $( '[typeof*="mw:Extension/references"]' );
+               if ( !$referenceLists.length ) {
+                       // No references list!. There can be multiple reasons 
for this.
+                       // (a) References list section use a template that we 
cannot adapt & filtered out from source.
+                       // (b) References are in multi-part template that we 
cannot process at this point.
+                       // Or any unknown reason. But if we adapt a reference 
without reference list at the
+                       // translation, parsoid will fail causing publishing 
failure. That is serious issue and
+                       // we are avoiding it.
+                       mw.log( '[CX] References list not found in source 
article. References will be removed' );
+                       $section.find( '[typeof*="mw:Extension/ref"]' 
).remove();
+                       return;
+               }
 
                isRestoredFromDraft = $section.data( 'cx-draft' ) === true;
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I198f5c62b78a7b9e8cf0b613e3e5a870b4c8b2fd
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