8000 Yaml interobability problem with PECL yaml · Issue #4135 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Yaml interobability problem with PECL yaml #4135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nonanet opened this issue Apr 27, 2012 · 5 comments
Closed

Yaml interobability problem with PECL yaml #4135

nonanet opened this issue Apr 27, 2012 · 5 comments

Comments

@nonanet
Copy link
nonanet commented Apr 27, 2012

Symfony's YAML parser/dumper behaves differently than the PHP PECL yaml parser/dumper.

Example code:

<?php

require_once("Symfony/Component/Yaml/Parser.php");
require_once("Symfony/Component/Yaml/Yaml.php");
require_once("Symfony/Component/Yaml/Inline.php");
require_once("Symfony/Component/Yaml/Dumper.php");
require_once("Symfony/Component/Yaml/Unescaper.php");
require_once("Symfony/Component/Yaml/Escaper.php");
require_once("Symfony/Component/Yaml/Exception/ExceptionInterface.php");
require_once("Symfony/Component/Yaml/Exception/DumpException.php");
require_once("Symfony/Component/Yaml/Exception/ParseException.php");


$data = array('data' => array('date' => array('cr=bla'), 'username' => 'foo'));

$yaml = (yaml_emit($data));

$parser = new Symfony\Component\Yaml\Parser();

$data2 = $parser->parse($yaml);

echo "ORIG\n";
var_dump($data);
echo "NEW:\n";
var_dump($data2);



?>

returns the following results:

ORIG
array(1) {
  ["data"]=>
  array(2) {
    ["date"]=>
    array(1) {
      [0]=>
      string(6) "cr=bla"
    }
    ["username"]=>
    string(3) "foo"
  }
}
NEW:
array(1) {
  ["data"]=>
  array(3) {
    ["date"]=>
    NULL
    [0]=>
    string(6) "cr=bla"
    ["username"]=>
    string(3) "foo"
  }
}

This is

alex@debvirt:~/work/EPPTest$ php -v
PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 13:13:26)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

alex@debvirt:~/work/EPPTest$ pecl list | fgrep yaml
yaml          1.0.1   stable

Installed packages, channel pear.symfony.com:
=============================================
Package Version State
Yaml    2.0.12  stable
@nonanet
Copy link
Author
nonanet commented Apr 27, 2012

Sorry for the crappy formatting..

@stof
Copy link
Member
stof commented Apr 27, 2012

I fixed the formatting. Could you give the YAML too ?

@vicb
Copy link
Contributor
vicb commented Apr 27, 2012

Duplictae of #4022

@vicb vicb closed this as completed Apr 27, 2012
@nonanet
Copy link
Author
nonanet commented Apr 27, 2012

The YAML produced by PECL yaml is as follows:

---
data:
  date:
  - cr=bla
  username: foo
...

@stof
Copy link
Member
stof commented Apr 27, 2012

yeah, it is indeed a duplicate. We already have a pull request with a fix

fabpot added a commit that referenced this issue May 8, 2012
Commits
-------

80a2a92 [2.1][Component][Yaml] fix 4022

Discussion
----------

[2.1][Component][Yaml] fix 4022

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: [![Build Status](https://secure.travis-ci.org/gajdaw/symfony.png?branch=2_1_component_yaml_fix_4022)](http://travis-ci.org/gajdaw/symfony)
Fixes the following tickets: #4121, #4022, #4135
Todo:

---------------------------------------------------------------------------

by stof at 2012-04-27T13:03:15Z

Why is it marked as ``[2.2]`` if it is a bugfix ?

@fabpot ping

---------------------------------------------------------------------------

by gajdaw at 2012-04-27T14:42:21Z

The title should be [2.1] - now it is correct.

I marked it 2.0 and PR was for 2.0 originally.

Fabien suggested that it should go to master branch: #4121 (comment)

---------------------------------------------------------------------------

by fabpot at 2012-05-07T09:17:31Z

That does not work when you have something after the unindented collection:

    collection:
        key:
        - a
        - b
        - c
    foo: bar

---------------------------------------------------------------------------

by gajdaw at 2012-05-07T11:11:30Z

@fabpot Last commit contains test with your yaml:

    collection:
        key:
        - a
        - b
        - c
    foo: bar

Everything seems fine. Can you give me a hint: what do you mean, when you say "That does not work"?

---------------------------------------------------------------------------

by fabpot at 2012-05-07T12:36:19Z

Sorry, the failing test is the following:

    test: Key/value after unindented collection
    brief: >
        Key/value after unindented collection
    yaml: |
        collection:
            key:
            - a
            - b
            - c
            foo: bar
    php: |
        array('collection' => array('key' => array('a', 'b', 'c'), 'foo' => 'bar'))

---------------------------------------------------------------------------

by gajdaw at 2012-05-07T15:48:26Z

@fabpot Last commit passed your test.

---------------------------------------------------------------------------

by fabpot at 2012-05-07T17:28:21Z

Can you squash your commits? Thanks.

---------------------------------------------------------------------------

by travisbot at 2012-05-08T05:32:58Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1273487) (merged 20891c58 into 919604a).

---------------------------------------------------------------------------

by gajdaw at 2012-05-08T05:36:51Z

Done.

---------------------------------------------------------------------------

by travisbot at 2012-05-08T07:23:47Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1274162) (merged 80a2a92 into 898ff4e).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0