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

Change subject: Don't strip id attributes from DOM nodes -- required for <ref> 
tags
......................................................................


Don't strip id attributes from DOM nodes -- required for <ref> tags

While we've stopped corrupting pages with today's deploy, we are
now returning http 500s in scenarios where because of edits, some
<ref>s get marked modified by the DOMDiff algorithm. This bug
didn't affect new <ref> tags. Because of the unsophisticated nature
of our DOMDiff algorithm, sometimes, wrappers of unmodified
content do get marked modified and if an unedited <ref> happened
to be one of those, the Parsoid serializer tripped on this bug.

Bug: T93228
Change-Id: Ia9477057e13c5831f08464a44ac816b1c080b9da
---
M lib/mediawiki.DOMUtils.js
M lib/mediawiki.WikitextSerializer.js
2 files changed, 8 insertions(+), 7 deletions(-)

Approvals:
  Arlolra: Looks good to me, approved
  Catrope: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/lib/mediawiki.DOMUtils.js b/lib/mediawiki.DOMUtils.js
index 7227fcf..8ed1efd 100644
--- a/lib/mediawiki.DOMUtils.js
+++ b/lib/mediawiki.DOMUtils.js
@@ -2014,10 +2014,9 @@
                        var el = document.getElementById( key );
                        if ( el ) {
                                this.setJSONAttribute( el, 'data-parsoid', 
dp.ids[key] );
-                               if ( /^mw[\w-]{2,}$/.test( key ) ) {
-                                       el.removeAttribute( 'id' );
-                               }
                        }
+                       // Leave id attribute behind -- it is used by citation
+                       // code to extract <ref> body from the DOM.
                }.bind( this ));
        },
 
diff --git a/lib/mediawiki.WikitextSerializer.js 
b/lib/mediawiki.WikitextSerializer.js
index c84a4a2..d2c281e 100644
--- a/lib/mediawiki.WikitextSerializer.js
+++ b/lib/mediawiki.WikitextSerializer.js
@@ -222,9 +222,11 @@
                // in v2 API when there is no matching data-parsoid entry found
                // for this id.
                if (k === "id" && /^mw[\w-]{2,}$/.test(kv.v)) {
-                       state.env.log("warning/html2wt",
-                               "Parsoid id found on element without a matching 
data-parsoid " +
-                               "entry: ID=" + kv.v + "; ELT=" + 
node.outerHTML);
+                       if (!node.getAttribute("data-parsoid")) {
+                               state.env.log("warning/html2wt",
+                                       "Parsoid id found on element without a 
matching data-parsoid " +
+                                       "entry: ID=" + kv.v + "; ELT=" + 
node.outerHTML);
+                       }
                        continue;
                }
 
@@ -598,7 +600,7 @@
                                        // Bail out of here since we cannot 
meaningfully recover
                                        // from this without losing content and 
corrupting the page.
                                        state.env.log("fatal",
-                                               "extension src id points to 
non-existent element for: ",
+                                               "extension src id " + 
dataMW.body.id + " points to non-existent element for: ",
                                                node.outerHTML + extraDebug);
                                }
                        }

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

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

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

Reply via email to