Page MenuHomePhabricator

Update/replace/supplement spyc (YAML parsing library)
Closed, ResolvedPublic

Description

We've got another bug about API YAML output being wrong (bug 28586), so this is sort of a dupe, but with more detail/scope than bug 22292

Looking at r42547 where Tim stripped most of the "scary" stuff out, which Niklas brought back into Translates spyc in r53613 (which looks to be gone in trunk translate now)

Looking at trunk spyc [1] it seems not to include that stuff (which is good). It however only lists itself as YAML 1.0 compliant [2].

Looking around, there seems to be only a few PHP YAML libraries, spyc being one of the PHP coded ones, and the other being Symfonys YAML library [3].

Looking at PECL and such type libraries, we do have syck [4], which Niklas has seemingly labelled as "// Just horrible output" in Translate, and also a version usable via Perl (I don't think such specific external dependancies/shelling out is the best way for something like this).

Finally there seems to be php-yaml [5], "The Yaml PHP Extension provides a wrapper to the LibYAML library"

Looking at the YAML site [6] it only lists those 3, with various levels of specification implementation, not seemingly implementing the current 1.2 spec. A stackoverflow post [7] seems to concur, suggesting Symfony has partial 1.2 spec implementation.

It seems the options are:

  • Keeping the ancient currently used 0.2.3 (Hmmm), with our custom hacks...
  • Upgrade it to 0.4.5svn (which seemingly doesn't have the scary code), and port our hacks/updates/changes (if needed(?)). SVN diffing this might be hard, so may need to ask Tim/Roan or both to review the newer one and see if there is anything that is god awfully bad
  • Move to the symfony YAML parser (seemingly well maintained), but no idea about the dependancy tree. A few files is ok, but if we've got to import most of Symfony, it's a non starter. Looks to be a max of 4 files (not had a chance to look at it in detail), possibly with less needed if we're not reading in YAML etc
  • Do a combination of above, and maybe add support for a "best case", "next best case", "resultant fallback" approach like we do elsewhere, adding support for some of the PECL libraries. Possibly do this like Translate does, have a variable to use to set this, to what you want, rather than the fallback type we have elsewhere

[1] http://code.google.com/p/spyc/source/browse/trunk/spyc.php
[2] http://code.google.com/p/spyc/
[3] http://components.symfony-project.org/yaml/installation
[4] http://pecl.php.net/package/syck
[5] http://code.google.com/p/php-yaml/
[6] http://www.yaml.org/
[7] http://stackoverflow.com/questions/294355/php-yaml-parsers


Version: unspecified
Severity: enhancement

Details

Reference
bz28591

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:30 PM
bzimport set Reference to bz28591.

Using symfony:

bug 28586 (YAML: strings that are the same as boolean literals) is fixed
bug 21945 (Add chomp control in YAML) is non replicable. Seemingly slightly different output format.
bug 21922 (YAML output should quote asterisk when used as key) is not regressed
bug 15448 (YAML output returns empty strings instead of 0) is not regressed
bug 12120 (Unescaped quote in YAML output) seemingly can't reproduce on reverted revision
bug 11719 (Remove trailing blanks in YAML output) seemingly can't reproduce on reverted revision

r31940 (Avoid number/string confusion in YAML) is not regressed

Feels very much something that should be Unit Tested (if things weren't so broken...)