Changeset 46205
- Timestamp:
- 09/20/2019 07:52:38 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-json.php
r45730 r46205 1 1 <?php 2 _deprecated_file( basename( __FILE__ ), '5.3.0', null, 'The PHP native JSON extension is now a requirement.' ); 3 2 4 if ( ! class_exists( 'Services_JSON' ) ) : 3 5 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ … … 143 145 function __construct( $use = 0 ) 144 146 { 147 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 148 145 149 $this->use = $use; 146 150 $this->_mb_strlen = function_exists('mb_strlen'); … … 153 157 */ 154 158 public function Services_JSON( $use = 0 ) { 159 _deprecated_constructor( 'Services_JSON', '5.3.0', get_class( $this ) ); 155 160 self::__construct( $use ); 156 161 } … … 173 178 function utf162utf8($utf16) 174 179 { 180 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 181 175 182 // oh please oh please oh please oh please oh please 176 183 if($this->_mb_convert_encoding) { … … 217 224 function utf82utf16($utf8) 218 225 { 226 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 227 219 228 // oh please oh please oh please oh please oh please 220 229 if($this->_mb_convert_encoding) { … … 261 270 function encode($var) 262 271 { 272 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 273 263 274 header('Content-type: application/json'); 264 275 return $this->encodeUnsafe($var); … … 277 288 function encodeUnsafe($var) 278 289 { 290 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 291 279 292 // see bug #16908 - regarding numeric locale printing 280 293 $lc = setlocale(LC_NUMERIC, 0); … … 298 311 function _encode($var) 299 312 { 300 313 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 314 301 315 switch (gettype($var)) { 302 316 case 'boolean': … … 540 554 function name_value($name, $value) 541 555 { 556 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 557 542 558 $encoded_value = $this->_encode($value); 543 559 … … 559 575 function reduce_string($str) 560 576 { 577 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 578 561 579 $str = preg_replace(array( 562 580 … … 590 608 function decode($str) 591 609 { 610 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 611 592 612 $str = $this->reduce_string($str); 593 613 … … 775 795 776 796 if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) { 777 797 // "name":value pair 778 798 $key = $this->decode($parts[1]); 779 799 $val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B")); … … 871 891 function isError($data, $code = null) 872 892 { 893 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 894 873 895 if (class_exists('pear')) { 874 896 return PEAR::isError($data, $code); … … 888 910 function strlen8( $str ) 889 911 { 912 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 913 890 914 if ( $this->_mb_strlen ) { 891 915 return mb_strlen( $str, "8bit" ); … … 903 927 function substr8( $string, $start, $length=false ) 904 928 { 929 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 930 905 931 if ( $length === false ) { 906 932 $length = $this->strlen8( $string ) - $start; … … 921 947 $mode = null, $options = null, $userinfo = null) 922 948 { 949 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 950 923 951 parent::PEAR_Error($message, $code, $mode, $options, $userinfo); 924 952 } 925 953 926 public function Services_JSON_Error($message = 'unknown error', $code = null,954 public function Services_JSON_Error($message = 'unknown error', $code = null, 927 955 $mode = null, $options = null, $userinfo = null) { 928 self::__construct($message = 'unknown error', $code = null,929 $mode = null, $options = null, $userinfo = null);930 }956 _deprecated_constructor( 'Services_JSON_Error', '5.3.0', get_class( $this ) ); 957 self::__construct($message, $code, $mode, $options, $userinfo); 958 } 931 959 } 932 960 … … 944 972 $mode = null, $options = null, $userinfo = null ) 945 973 { 946 974 _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); 947 975 } 948 976 … … 952 980 public function Services_JSON_Error( $message = 'unknown error', $code = null, 953 981 $mode = null, $options = null, $userinfo = null ) { 982 _deprecated_constructor( 'Services_JSON_Error', '5.3.0', get_class( $this ) ); 954 983 self::__construct( $message, $code, $mode, $options, $userinfo ); 955 984 } 956 985 } 957 986 958 987 } 959 988 -
trunk/tests/phpunit/tests/compat.php
r45607 r46205 180 180 } 181 181 182 /** 183 * @expectedException PHPUnit_Framework_Error_Notice 184 */ 182 185 function test_json_encode_decode() { 183 186 require_once( ABSPATH . WPINC . '/class-json.php' );
Note: See TracChangeset
for help on using the changeset viewer.