Last modified: 2013-05-08 18:38:25 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T49948, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 47948 - VisualEditor: JSON.stringify won't work if data contains DOM elements
VisualEditor: JSON.stringify won't work if data contains DOM elements
Status: RESOLVED FIXED
Product: VisualEditor
Classification: Unclassified
MediaWiki integration (Other open bugs)
unspecified
All All
: Highest critical
: VE-deploy-2013-05-13
Assigned To: Ed Sanders
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-01 18:51 UTC by Krinkle
Modified: 2013-05-08 18:38 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Krinkle 2013-05-01 18:51:58 UTC
Steps to reproduce problem:
1. Edit https://www.mediawiki.org/wiki/Git/Commit_message_guidelines in VisualEditor
2. Add some text
3. "Review and save"
4. "Something is wrong"
5. "Report problem"

Expected behaviour:
Make an http request somewhere and report back in the UI.

Actual behaviour:
No http request is made and UI is unresponsive.

console:
> Uncaught TypeError: Converting circular structure to JSON
> at:
> > mw.Target.prototype.reportProblem = function(message) {
> > var ...., report = { title: .., oldid: .., .. };
> > $.post(mw.config.get('wgVisualEditorConfig').reportProblemURL, {'data': JSON.stringify(report)}, function() {

debug:

var objs = [];
JSON.stringify(a, function (k, v) {
  var i;
  if (v === Object(v)) {
    i = objs.indexOf(v);
    if (i !== -1) {
      console.log('dupe at #' + i, v);
    }
    objs.push(v);
  }
  return v;
});
dupe at #66 
<p data-parsoid=​"{"dsr":​[0,139,0,0]​}​">​
"The "
<b data-parsoid=​"{"tsr":​[4,7]​,"dsr":​[4,24,3,3]​}​">​commit message​</b>​
" play an important role in revision control systems. They are the first thing other people will see of your commit."
</p>​
Comment 1 Krinkle 2013-05-06 17:12:56 UTC
@Ed: I suspect the circular reference is coming from inside the data model. Can you look into this?

See ve.init.mw.Target.js, method #reportProblem.
Comment 2 Ed Sanders 2013-05-08 13:23:49 UTC
This is caused by the linear data now contain DOM elements in alien nodes (and other nodes that store original HTML). We will need to pre-process the data before serialising. We already do this in the unit tests so shouldn't be too difficult.
Comment 3 Gerrit Notification Bot 2013-05-08 13:44:56 UTC
Related URL: https://gerrit.wikimedia.org/r/62811 (Gerrit Change Id807ccc6ff31d063be815ed4988cb35684adb76a)
Comment 4 Krinkle 2013-05-08 16:27:24 UTC
Ah, because native DOM element objects have all kinds of "convenience" pointers like "firstChild", "children", "nextSibling", "paretNode", "ownerDocument", which all have the same as well, so its like a circular reference nightmare.
Comment 5 James Forrester 2013-05-08 18:38:25 UTC
Fixed in master.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links