Page MenuHomePhabricator

TemplateData API should not return a default format if it is not set (currently defaults to inline)
Closed, ResolvedPublic1 Estimated Story Points

Description

Event Timeline

matmarex renamed this task from Visual editor seems to push users to remove line breaks in templates to Parsoid removes line breaks in template syntax when 'format' not specified.Feb 29 2016, 8:39 PM
matmarex triaged this task as High priority.
matmarex edited projects, added Parsoid; removed VisualEditor.

Hmm ... as far as I know, all the instances I saw was where the format was explicitly specified as inline in templatedata. I cannot verify on all these edits since it looks like someone has already updated the templatedata for the templates to use format:block and there is no revision history for templatedata.

But, next time anyone encounters this, can you add a link but not edit templatedata?

So, to be clear, till this behavior can be reproduced with a template that has no templatedata format specified (vs. explicitly being specified as inline), there is nothing to do on the Parsoid end.

See T128474#2075975 which verifies my hypothesis in the T128474 case. I am fairly confident (based on similar instances I have seen) that the itwiki scenario was very similar. I am going to close this ticket now. Please re-open if there is something that involves Parsoid.

ssastry changed the task status from Resolved to Invalid.Mar 1 2016, 4:00 PM
ssastry reopened this task as Open.EditedMar 1 2016, 4:47 PM

Aha .. this looks like a problem with the mediawiki API.

See this templatedata entry for enwiki:Template:Quote .. note that it has no format entry there.

Now, check the templatedata information returned by the API .. it returns 'format:inline'.

So, the mediawiki API needs a fix. It is interpreting the templatedata spec very strictly and returning an explicit format:inline if there is no format entry present. However, this prevents API clients (like Parsoid) from distinguishing between missing format and explicit format and doing the right thing.

ssastry renamed this task from Parsoid removes line breaks in template syntax when 'format' not specified to Mediawiki API should not return a format:inline for templatedata if the format information is missing.Mar 1 2016, 4:49 PM
ssastry edited projects, added MediaWiki-Action-API; removed Parsoid.
matmarex added a project: TemplateData.

So… TemplateData actually defaults to 'inline' if this parameter is not specified. (It's even documented: https://github.com/wikimedia/mediawiki-extensions-TemplateData/blob/master/Specification.md#316-format.) That's very wrong.

So… TemplateData actually defaults to 'inline' if this parameter is not specified. (It's even documented: https://github.com/wikimedia/mediawiki-extensions-TemplateData/blob/master/Specification.md#316-format.) That's very wrong.

The spec does say: "In the absence of the parameter being set, the system will supply inline as a fallback value" ... so the interpretation is right on the surface, but the API should not be the one doing the interpretation .. it should return the data as is and let clients make the call.

Change 274138 had a related patch set uploaded (by Bartosz Dziewoński):
Don't enforce 'inline' format if none given

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

@ssastry Can you verify that the above is going to play well with Parsoid? I don't have the development version set up, and the APT one seems to be lagging behind.

Parsoid has tests with various types of templatedata information returned by the mock API ... so, Parsoid should be good with this change.

The serialization logic is here that specifies default behavior.

I have some comments on your patch that I'll leave there.

Dunno if it's related but I noticed also addition of spaces between | and template parameter(s) (for example: https://it.wikipedia.org/w/index.php?title=Aleksandra_Michajlovna_Kollontaj&curid=1678007&diff=79272986&oldid=77542336 )

Dunno if it's related but I noticed also addition of spaces between | and template parameter(s) (for example: https://it.wikipedia.org/w/index.php?title=Aleksandra_Michajlovna_Kollontaj&curid=1678007&diff=79272986&oldid=77542336 )

No, this looks like a different Parsoid issue. There might be a slight mismatch in what the wt2html-side thinks is the normalized form and what the html2wt-side thinks is the normalized form which might be causing this.

In case you were in doubt, I encountered this too with {{multiple image}} converting params to inline. I have since fixed it: https://en.wikipedia.org/w/index.php?title=Template%3AMultiple_image%2Fdoc&type=revision&diff=707936853&oldid=707935963

Change 274138 merged by jenkins-bot:
[BREAKING CHANGE] Change default format to null instead of 'inline'

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

Change 274482 had a related patch set uploaded (by Jforrester):
[BREAKING CHANGE] Change default format to null instead of 'inline'

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

Jdforrester-WMF renamed this task from Mediawiki API should not return a format:inline for templatedata if the format information is missing to TemplateData API should not return a default format if it is not set (currently defaults to inline).Mar 2 2016, 9:55 PM

Change 274482 merged by jenkins-bot:
[BREAKING CHANGE] Change default format to null instead of 'inline'

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

Backported to wmf.15 and will be deployed to Wikimedia wikis this week, per https://www.mediawiki.org/wiki/MediaWiki_1.27/Roadmap.

After the deployment (happening tomorrow or the day after, see the Roadmap page), this may continue to affect templates which had TemplateData, but no "format" specified in it, until the template page (not the doc page, the template page) is null-edited.

Anything we should tell the communities about in the ambassadors list?

Jdforrester-WMF set the point value for this task to 1.

Yeah, I guess. There was a bug that caused VisualEditor to damage template syntax of infoboxes and similar templates. This bug is now fixed, but may still affect templates until they are purged.

Yeah, I guess. There was a bug that caused VisualEditor to damage template syntax of infoboxes and similar templates. This bug is now fixed, but may still affect templates until they are purged.

I would qualify that statement. "... to incorrectly modify template syntax of some infoboxes and similar templates." because:

  • damage sounds harsher than it needs to be
  • not all template edits are affected

Something like this?

"Templates using TemplateData that were edited with the visual editor might have some problems. This can be fixed by editing and saving the templates without making any changes."

https://pt.wikipedia.org/w/api.php?action=templatedata&titles=Template:Info/Munic%C3%ADpio%20do%20Brasil&format=json still has this problem which is the cause of this bug report @ https://en.wikipedia.org/wiki/Wikipedia:VisualEditor/Feedback#Unconfiguring_the_infoboxes. I didn't quite follow what the fix was for this in terms of cached TemplateData? null save of the templates?

A purge is supposed to work, yes. If it doesn't, try null editing.