Page MenuHomePhabricator

Inconsistent detection of JSON errors in templatedata
Closed, DuplicatePublic

Description

In JSON, trailing commas (e.g. {"a": "b",}) are not valid. Thus, the templatedata in this old revision is invalid because of the trailing comma after "Description des problèmes relevés lors de la relecture.":

https://fr.wikipedia.org/w/index.php?title=Mod%C3%A8le:Relecture_apr%C3%A8s_label/Documentation&oldid=162682818

Surprisingly, MediaWiki manages to parse the templatedata in this revision most of the time, but not always. Sometimes, the template data block is not displayed and "Erreur de syntaxe dans JSON." (= "Syntax error in JSON.") is shown instead. I could not find a way to reliable reproduce this.

The parsing behavior should be made consistent.

Note: among the old revisions of the page that contain the error, some have the "PHP7" tag and some others do not, so I have no reason to believe this is related to the HHVM => PHP 7 migration.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I remember that at some point in the migration to HHVM we discovered that HHVM's JSON parser was less strict than PHP's, and allowed the trailing commas. I don't remember if we did anything about that, but it might be the same problem?

I remember that at some point in the migration to HHVM we discovered that HHVM's JSON parser was less strict than PHP's, and allowed the trailing commas. I don't remember if we did anything about that, but it might be the same problem?

Yes, this is a long-standing bug. Dupe of T128029.