Ticket #30471: 30471.2.diff
File 30471.2.diff, 1.9 KB (added by , 10 years ago) |
---|
-
src/wp-includes/functions.php
2662 2662 $json = call_user_func_array( 'json_encode', $args ); 2663 2663 2664 2664 // If json_encode() was successful, no need to do more sanity checking. 2665 if ( false !== $json ) { 2665 // ... unless we're in an old version of PHP, and json_encode() returned 2666 // a string containing 'null'. Then we need to do more sanity checking. 2667 if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) { 2666 2668 return $json; 2667 2669 } 2668 2670 -
tests/phpunit/tests/functions.php
554 554 555 555 $this->assertEquals( 'aあb', $utf8 ); 556 556 557 // json_encode() returns different things in different PHP versions. 558 // See: https://core.trac.wordpress.org/ticket/30471 559 if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) { 560 $expected = '"a\u3042b"'; 561 } else { 562 $expected = 'null'; 563 } 557 $this->assertEquals( '"a\u3042b"', wp_json_encode( $eucjp ) ); 564 558 565 $this->assertEquals( $expected, wp_json_encode( $eucjp ) );566 567 559 mb_detect_order( $old_charsets ); 568 560 } 569 561 … … 582 574 583 575 $this->assertEquals( 'aあb', $utf8 ); 584 576 585 // json_encode() returns different things in different PHP versions. 586 // See: https://core.trac.wordpress.org/ticket/30471 587 if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) { 588 $expected = '["c","a\u3042b"]'; 589 } else { 590 $expected = '["c",null]'; 591 } 577 $this->assertEquals( '["c","a\u3042b"]', wp_json_encode( array( 'c', $eucjp ) ) ); 592 578 593 $this->assertEquals( $expected, wp_json_encode( array( 'c', $eucjp ) ) );594 595 579 mb_detect_order( $old_charsets ); 596 580 } 597 581