There were 2 failures:

1) Drupal\Tests\Component\Utility\JsonTest::testReversibility
Encoding a string to JSON and decoding back results in the original string.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-
-

- !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+

/var/www/d8/core/tests/Drupal/Tests/Component/Utility/JsonTest.php:108
/usr/share/php/PHPUnit/TextUI/Command.php:192
/usr/share/php/PHPUnit/TextUI/Command.php:130

2) Drupal\Tests\Component\Utility\JsonTest::testStructuredReversibility
Encoding structured data to JSON and decoding back not results in the original data.
Failed asserting that Array (
    0 => true
    1 => false
    2 => 0
    3 => 1
    4 => '0'
    5 => '1'
    6 => ''
    7 => Array (
        'key1' => ''
        'key2' => Array (
            'nested' => true
        )
    )
) is identical to Array (
    0 => true
    1 => false
    2 => 0
    3 => 1
    4 => '0'
    5 => '1'
    6 => Binary String: 0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f
    7 => Array (
        'key1' => Binary String: 0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f
        'key2' => Array (
            'nested' => true
        )
    )
).

/var/www/d8/core/tests/Drupal/Tests/Component/Utility/JsonTest.php:128
/usr/share/php/PHPUnit/TextUI/Command.php:192
/usr/share/php/PHPUnit/TextUI/Command.php:130

Files: 
CommentFileSizeAuthor
#10 json-wtf-2068593-10.patch1.13 KBBerdir
PASSED: [[SimpleTest]]: [MySQL] 58,783 pass(es).
[ View ]
#7 json-wtf-2068593-7.patch574 bytesBerdir
FAILED: [[SimpleTest]]: [MySQL] 59,054 pass(es), 1 fail(s), and 0 exception(s).
[ View ]
#1 failure.txt1.81 KBParisLiakos

Comments

ParisLiakos’s picture

StatusFileSize
new1.81 KB

seems, it wont show correctly, so attaching the failure as txt

ParisLiakos’s picture

maybe it is because of #1210798: In PHP 5.4, html_entity_decode() doesn't decode invalid numeric entities
we had similar problems with the XssTest

neclimdul’s picture

Seems to be only chr(0) that's causing problems. populating with 1-128 instead of 0-128 fixes the tests. We can probably ignore testings encoding NULL characters.

Berdir’s picture

Trying to run this on http://3v4l.org/pCtWM but it seems to work fine in 5.3.0 - 5.5.4? Something wrong with my test script?

ParisLiakos’s picture

your script returns bool(false) in my 5.5.4 enviroment

it gives me bool(true) if i modify the for to start from 1 and not 0

neclimdul’s picture

Ditto.

I looked into it a bit more, its treating the NUL as a string terminator. If you move the NUL to the end of the string the decoded value still doesn't match but its 127 characters long instead of 0.

I'd like more buy in but I'm not sure we need to test the NUL character. We're not testing PHP here but that things behave sanely. 1-128 still seems a valid testing string.

As far as the observations, I'm wondering if JSON library versions are behaving different. That would mean its not actually the PHP version so much as the JSON library its linked against which makes more sense and matches Berdir's observation.

Here's some information about my setup:

PHP version string: PHP 5.5.4-1+debphp.org~raring+1 (cli) (built: Sep 27 2013 12:47:39)
This ppa: http://ppa.launchpad.net/ondrej/php5/ubuntu
JSON section from my phpinfo:

json support enabled
json version 1.3.2-dev
JSON-C headers version 0.11.99
JSON-C library version 0.11.99

And what I could get from 34vl for their version of 5.4 (surprisingly phpinfo wasn't blocked and didn't blow up).
json json support => enabled
json version => 1.2.1

I notice they have 1.2.1 and I've got 1.3.2-dev(which comes from the ppa).

Berdir’s picture

Status:Active» Needs review
StatusFileSize
new574 bytes
FAILED: [[SimpleTest]]: [MySQL] 59,054 pass(es), 1 fail(s), and 0 exception(s).
[ View ]

Yes, I thought it could be a library. Which is crazy.

Anyway, I'm fine with starting with 1. We should probably open an upstream bug report about it, though?

ParisLiakos’s picture

the json project debian builds its php5-json package:
https://github.com/remicollet/pecl-json-c
where there is a relevant issue https://github.com/remicollet/pecl-json-c/issues/7 ..and i think a commit happened which might have fixed that..i will try to test it

Status:Needs review» Needs work

The last submitted patch, json-wtf-2068593-7.patch, failed testing.

Berdir’s picture

Status:Needs work» Needs review
Issue tags:+PHP 5.5
StatusFileSize
new1.13 KB
PASSED: [[SimpleTest]]: [MySQL] 58,783 pass(es).
[ View ]

There's really no excuse for not executing a unit test before uploading a patch :)

I think even (or actually, especially!) when we can prove that this test fail is related to the issue linked in #8 and hopefully fixed by it, we still need to do this, we can't change which version debian/ubuntu ships soon enough I assume.

neclimdul’s picture

Status:Needs review» Reviewed & tested by the community
Issue tags:-PHP 5.5

Passes for me. Assuming core isn't broken this'll come back green so...

neclimdul’s picture

Issue tags:+PHP 5.5

...

neclimdul’s picture

Title:JsonTest fails on PHP 5.5» JsonTest fails with pecl-json

fixing for commits.

webchick’s picture

Status:Reviewed & tested by the community» Fixed

I've no issue with committing this, but this is by far the most bizarre bug I've ever seen. $i = 0 is not exactly crazy edge case material. Well done tracking this down!

Committed and pushed to 8.x. Thanks!

Berdir’s picture

@webchick: It's not $i = 0 that's special, it's chr($i) when $i = 0.

ParisLiakos’s picture

just FYI: the issue in #8 fixes that upstream..it is now in fedora and debian

Automatically closed -- issue fixed for 2 weeks with no activity.