Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#10 | json-wtf-2068593-10.patch | 1.13 KB | Berdir |
#7 | json-wtf-2068593-7.patch | 574 bytes | Berdir |
#1 | failure.txt | 1.81 KB | ParisLiakos |
Comments
Comment #1
ParisLiakos CreditAttribution: ParisLiakos commentedseems, it wont show correctly, so attaching the failure as txt
Comment #2
ParisLiakos CreditAttribution: ParisLiakos commentedmaybe 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
Comment #3
neclimdulSeems 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.
Comment #4
BerdirTrying 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?
Comment #5
ParisLiakos CreditAttribution: ParisLiakos commentedyour script returns
bool(false)
in my 5.5.4 enviromentit gives me
bool(true)
if i modify the for to start from 1 and not 0Comment #6
neclimdulDitto.
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:
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).
Comment #7
BerdirYes, 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?
Comment #8
ParisLiakos CreditAttribution: ParisLiakos commentedthe 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
Comment #10
BerdirThere'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.
Comment #11
neclimdulPasses for me. Assuming core isn't broken this'll come back green so...
Comment #12
neclimdul...
Comment #13
neclimdulfixing for commits.
Comment #14
webchickI'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!
Comment #15
Berdir@webchick: It's not $i = 0 that's special, it's chr($i) when $i = 0.
Comment #16
ParisLiakos CreditAttribution: ParisLiakos commentedjust FYI: the issue in #8 fixes that upstream..it is now in fedora and debian