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

Change subject: T92177: Fix assertion failure in td-fixup code
......................................................................


T92177: Fix assertion failure in td-fixup code

* Remove the assertion and replace with a logging error about
  unhandled fixup scenarios. Not sure the failed fixup and
  resultant incorrect rendering is any better than the assertion
  failure, but will at least eliminate repeated retries from
  clients (and the job queue).

Change-Id: Ibb1838ef5aec7cc4566ae9b8be26f4acc61e0a2a
---
M lib/dom.t.TableFixups.js
1 file changed, 14 insertions(+), 25 deletions(-)

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



diff --git a/lib/dom.t.TableFixups.js b/lib/dom.t.TableFixups.js
index e428bcd..353caa0 100644
--- a/lib/dom.t.TableFixups.js
+++ b/lib/dom.t.TableFixups.js
@@ -85,24 +85,6 @@
        return true;
 };
 
-
-/**
- * Helpers for reparseTemplatedAttributes
- */
-TableFixups.prototype.hasOnlyOneTransclusionChild = function (node) {
-       var n = 0;
-       node.childNodes.forEach(function(n) {
-               if (DU.isFirstEncapsulationWrapperNode(n)) {
-                       n++;
-               }
-               if (n > 1) {
-                       return false;
-               }
-       });
-       return true;
-};
-
-
 /**
  * Collect potential attribute content
  *
@@ -111,7 +93,7 @@
  * nowiki content. Collection stops when encountering other nodes or a pipe
  * character.
  */
-TableFixups.prototype.collectAttributishContent = function(node, 
templateWrapper) {
+TableFixups.prototype.collectAttributishContent = function(env, node, 
templateWrapper) {
        var buf = [],
                nodes = [],
                transclusionNode = templateWrapper ||
@@ -159,8 +141,19 @@
                } else if (DU.hasTypeOf(child, 'mw:Transclusion') &&
                                DU.allChildrenAreTextOrComments(child))
                {
+                       // And only handle a single nested transclusion for now.
+                       // TODO: Handle data-mw construction for 
multi-transclusion content
+                       // as well, then relax this restriction.
+                       //
+                       // If we already had a transclusion node, we return
+                       // without attempting to fix this up.
+                       if (transclusionNode) {
+                               env.log("error/dom/tdfixup", "Unhandled 
TD-fixup scenario.",
+                                       "Encountered multiple transclusion 
children of a <td>");
+                               return { transclusionNode: null };
+                       }
+
                        // We encountered a transclusion wrapper
-                       console.assert(!transclusionNode);
                        buf.push(child.textContent);
                        transclusionNode = child;
                } else if (transclusionNode &&
@@ -216,7 +209,7 @@
 
 TableFixups.prototype.reparseTemplatedAttributes = function(env, node, 
templateWrapper) {
        // Collect attribute content and examine it
-       var attributishContent = this.collectAttributishContent(node, 
templateWrapper),
+       var attributishContent = this.collectAttributishContent(env, node, 
templateWrapper),
                transclusionNode = attributishContent.transclusionNode;
 
        // First of all make sure we have a transclusion
@@ -224,10 +217,6 @@
        if (!transclusionNode
                // Check for the pipe character in the attributish text.
                || 
!/^[^|]+\|[^|]*([^|]\|\|[^|]*)*$/.test(attributishContent.txt)
-               // And only handle a single nested transclusion for now.
-               // TODO: Handle data-mw construction for multi-transclusion 
content
-               // as well, then relax this restriction.
-               || !this.hasOnlyOneTransclusionChild(node)
           )
        {
                return;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibb1838ef5aec7cc4566ae9b8be26f4acc61e0a2a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Marcoil <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to