Ticket #30006: add_deprecated_property.patch
File add_deprecated_property.patch, 10.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/functions.php
286 286 return false; 287 287 } 288 288 $data = trim( $data ); 289 289 if ( 'N;' == $data ) { 290 290 return true; 291 291 } 292 292 if ( strlen( $data ) < 4 ) { … … 2512 2512 2513 2513 -webkit-box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba(0,0,0,.08); 2514 2514 box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba(0,0,0,.08); 2515 2515 vertical-align: top; 2516 2516 } 2517 2517 2518 2518 .button.button-large { … … 2538 2538 border-color: #999; 2539 2539 color: #333; 2540 2540 -webkit-box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); 2541 2541 box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); 2542 2542 } 2543 2543 2544 2544 <?php if ( 'rtl' == $text_direction ) : ?> … … 2768 2768 ':arrow:' => 'icon_arrow.gif', 2769 2769 ':shock:' => 'icon_eek.gif', 2770 2770 ':smile:' => 'icon_smile.gif', 2771 2771 ':???:' => 'icon_confused.gif', 2772 2772 ':cool:' => 'icon_cool.gif', 2773 2773 ':evil:' => 'icon_evil.gif', 2774 2774 ':grin:' => 'icon_biggrin.gif', … … 2777 2777 ':razz:' => 'icon_razz.gif', 2778 2778 ':roll:' => 'icon_rolleyes.gif', 2779 2779 ':wink:' => 'icon_wink.gif', 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2780 ':cry:' => 'icon_cry.gif', 2781 ':eek:' => 'icon_surprised.gif', 2782 ':lol:' => 'icon_lol.gif', 2783 ':mad:' => 'icon_mad.gif', 2784 ':sad:' => 'icon_sad.gif', 2785 '8-)' => 'icon_cool.gif', 2786 '8-O' => 'icon_eek.gif', 2787 ':-(' => 'icon_sad.gif', 2788 ':-)' => 'icon_smile.gif', 2789 ':-?' => 'icon_confused.gif', 2790 ':-D' => 'icon_biggrin.gif', 2791 ':-P' => 'icon_razz.gif', 2792 ':-o' => 'icon_surprised.gif', 2793 ':-x' => 'icon_mad.gif', 2794 ':-|' => 'icon_neutral.gif', 2795 ';-)' => 'icon_wink.gif', 2796 2796 // This one transformation breaks regular text with frequency. 2797 2797 // '8)' => 'icon_cool.gif', 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2798 '8O' => 'icon_eek.gif', 2799 ':(' => 'icon_sad.gif', 2800 ':)' => 'icon_smile.gif', 2801 ':?' => 'icon_confused.gif', 2802 ':D' => 'icon_biggrin.gif', 2803 ':P' => 'icon_razz.gif', 2804 ':o' => 'icon_surprised.gif', 2805 ':x' => 'icon_mad.gif', 2806 ':|' => 'icon_neutral.gif', 2807 ';)' => 'icon_wink.gif', 2808 ':!:' => 'icon_exclaim.gif', 2809 ':?:' => 'icon_question.gif', 2810 2810 ); 2811 2811 } 2812 2812 … … 3329 3329 } 3330 3330 3331 3331 /** 3332 * Mark a property as deprecated and inform when it has been used. 3333 * 3334 * There is a hook deprecated_property_run that will be called that can be used 3335 * to get the backtrace up to what file and function used the deprecated 3336 * property. 3337 * 3338 * The current behavior is to trigger a user error if WP_DEBUG is true. 3339 * 3340 * @since X4.2 3341 * @access private 3342 * 3343 * @param string $property The property that was accessed. 3344 * @param string $version The version of WordPress that deprecated the argument used. 3345 * @param string $message Optional. A message regarding the change. Default null. 3346 */ 3347 function _deprecated_property( $property, $version, $message = null ) { 3348 3349 /** 3350 * Fires when a deprecated property is accessed. 3351 * 3352 * @since X4.2 3353 * 3354 * @param string $property The property that was accessed. 3355 * @param string $message A message regarding the change. 3356 * @param string $version The version of WordPress that deprecated the property used. 3357 */ 3358 do_action( 'deprecated_property_run', $property, $message, $version ); 3359 3360 /** 3361 * Filter whether to trigger an error for deprecated properties. 3362 * 3363 * @since X4.2 3364 * 3365 * @param bool $trigger Whether to trigger the error for deprecated properties. Default true. 3366 */ 3367 if ( WP_DEBUG && apply_filters( 'deprecated_property_trigger_error', true ) ) { 3368 if ( function_exists( '__' ) ) { 3369 if ( ! is_null( $message ) ) 3370 trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! %3$s'), $property, $version, $message ) ); 3371 else 3372 trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $property, $version ) ); 3373 } else { 3374 if ( ! is_null( $message ) ) 3375 trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! %3$s', $property, $version, $message ) ); 3376 else 3377 trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $property, $version ) ); 3378 } 3379 } 3380 } 3381 3382 /** 3332 3383 * Mark something as being incorrectly called. 3333 3384 * 3334 3385 * There is a hook doing_it_wrong_run that will be called that can be used -
tests/phpunit/includes/testcase.php
196 196 } 197 197 add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); 198 198 add_action( 'deprecated_argument_run', array( $this, 'deprecated_function_run' ) ); 199 add_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) ); 199 add_action( 'deprecated_property_run', array( $this, 'deprecated_function_run' ) ); 200 add_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) ); 201 200 202 add_action( 'deprecated_function_trigger_error', '__return_false' ); 201 203 add_action( 'deprecated_argument_trigger_error', '__return_false' ); 204 add_action( 'deprecated_property_trigger_error', '__return_false' ); 202 205 add_action( 'doing_it_wrong_trigger_error', '__return_false' ); 203 206 } 204 207 -
tests/phpunit/tests/functions/deprecated.php
23 23 protected $_deprecated_arguments = array(); 24 24 25 25 /** 26 * List of properties that have been passed through _deprecated_property() 27 * @var string[] 28 */ 29 protected $_deprecated_properties = array(); 30 31 /** 26 32 * List of files that have been passed through _deprecated_file() 27 33 * @var string[] 28 34 */ … … 34 40 */ 35 41 public function setUp() { 36 42 parent::setUp(); 43 37 44 $this->_deprecated_functions = array(); 38 $this->_deprecated_arguments = array();39 $this->_deprecated_files = array();40 45 add_action( 'deprecated_function_run' , array( $this, 'deprecated_function' ), 10, 3 ); 41 46 add_action( 'deprecated_function_trigger_error', '__return_false' ); 47 48 $this->_deprecated_arguments = array(); 42 49 add_action( 'deprecated_argument_run' , array( $this, 'deprecated_argument' ), 10, 3 ); 43 50 add_action( 'deprecated_argument_trigger_error', '__return_false' ); 51 52 $this->_deprecated_properties = array(); 53 add_action( 'deprecated_property_run' , array( $this, 'deprecated_property' ), 10, 3 ); 54 add_action( 'deprecated_property_trigger_error', '__return_false' ); 55 56 $this->_deprecated_files = array(); 44 57 add_action( 'deprecated_file_included' , array( $this, 'deprecated_file' ), 10, 4 ); 45 58 add_action( 'deprecated_file_trigger_error', '__return_false' ); 46 59 } … … 52 65 public function teardown() { 53 66 remove_action( 'deprecated_function_run' , array( $this, 'deprecated_function' ), 10, 3 ); 54 67 remove_action( 'deprecated_function_trigger_error', '__return_false' ); 68 55 69 remove_action( 'deprecated_argument_run' , array( $this, 'deprecated_argument' ), 10, 3 ); 56 70 remove_action( 'deprecated_argument_trigger_error', '__return_false' ); 57 remove_action( 'deprecated_file_included' , array( $this, 'deprecated_argument' ), 10, 4 ); 71 72 remove_action( 'deprecated_property_run' , array( $this, 'deprecated_property' ), 10, 3 ); 73 remove_action( 'deprecated_property_trigger_error', '__return_false' ); 74 75 remove_action( 'deprecated_file_included' , array( $this, 'deprecated_file' ), 10, 4 ); 58 76 remove_action( 'deprecated_file_trigger_error', '__return_false' ); 77 59 78 parent::tearDown(); 60 79 } 61 80 … … 90 109 } 91 110 92 111 /** 93 * Catch arguments that have passed through _deprecated_ argument94 * @param string $ argument112 * Catch arguments that have passed through _deprecated_property 113 * @param string $property 95 114 * @param string $message 96 115 * @param float $version 97 116 * @return void 98 117 */ 99 public function deprecated_file( $file, $version, $replacement, $message ) { 118 public function deprecated_property( $property, $message, $version ) { 119 $this->_deprecated_properties[] = array( 120 'property' => $property, 121 'message' => $message, 122 'version' => $version 123 ); 124 } 125 126 /** 127 * Catch arguments that have passed through _deprecated_file 128 * @param string $file 129 * @param string $message 130 * @param float $version 131 * @param string $replacement 132 * @return void 133 */ 134 public function deprecated_file( $file, $replacement, $version, $message ) { 100 135 $this->_deprecated_files[] = array( 101 136 'file' => $file, 102 137 'version' => $version, … … 113 148 */ 114 149 protected function was_deprecated( $type, $name ) { 115 150 switch ( $type ) { 151 case 'property' : 152 $search = $this->_deprecated_properties; 153 $key = 'property'; 154 break; 116 155 case 'argument' : 117 156 $search = $this->_deprecated_arguments; 118 157 $key = 'argument';