Page MenuHomePhabricator

No warning about invalid JSON in existing <templatedata> block, odd behavior.
Closed, ResolvedPublic

Description

  1. Edit Template:RFC
  2. You get a warning "Please note: there is already a TemplateData block on the related page 'Template:RFC/doc'."
  3. OK, so edit RFC/doc
  4. Its markup does indeed show a <templatedata> block of code, with description and params
  5. I want to edit that, so click [Manage TemplateData] button.

Result:

  • Template description and parameter order are empty. There's a panel button to "Add 13 parameters", but they and description should show up in the existing template.

The existing <templatedata> is invalid JSON (the status parameter's description is a multi-line string, it should be one line with '\n's), maybe that's the problem. But there's no warning, not even in the browser console or from any APi request. I can load, edit, and save Template:RFC/doc without getting any warning that it's got an invalid <templatedata> block.

Furthermore, if I [[ http://www.mediawiki.org/w/api.php?action=templatedata&titles=Template:RFC | make the templatedata API request for Template:RFC ]], it returns all the templatedata parameters, despite the bad JSON (it puts the status parameter's description on one line).

Expected result: either show me the current template parameters because the templatedata API request succeeds; or warn or fail on edit/preview/save because the <templatedata> block is not valid JSON.

Event Timeline

Spage assigned this task to Mooeypoo.
Spage raised the priority of this task from to Needs Triage.
Spage updated the task description. (Show Details)
Spage added a project: TemplateData.
Spage subscribed.

Okay, wow, good catch!

It seems to be the semi-invalid multiline description in the 'status' parameter. If I remove it, the TemplateData editor loads perfectly.

You're absolutely right that the dialog should ideally deal with this and if not, it should state that the json is invalid. I'll have to check into how the json parser works in javascript and see how I can fix it up. It seems like the PHP json parser can handle this (since as you said, the API works) but something is obviously not working with the javascript version.

I'm checking into that. Thanks!

Change 194991 had a related patch set uploaded (by Mooeypoo):
Reorganize api calls and add sourceHandler and error message

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

Change 194991 merged by jenkins-bot:
Reorganize api calls and add sourceHandler and error message

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