In `WP_Text_Diff_Renderer_Table`:

* In [28525], `$_diff_threshold`, `$inline_diff_renderer`, and `$_show_split_view` were marked `protected`; magic methods were also added.
* The magic methods should only perform operations on a whitelisted set of properties, now specified in `$compat_fields`
* Remove `__call()`, is unnecessary and can wreak havoc on the parent class.

This class is used in one place: `wp_text_diff()`.

See #30891.

Built from https://develop.svn.wordpress.org/trunk@31135


git-svn-id: http://core.svn.wordpress.org/trunk@31116 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-01-10 22:58:24 +00:00
parent a56d920454
commit 65a459b34f
2 changed files with 15 additions and 19 deletions

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31134';
$wp_version = '4.2-alpha-31135';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -68,6 +68,8 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
*/
protected $_show_split_view = true;
protected $compat_fields = array( '_show_split_view', 'inline_diff_renderer', '_diff_threshold' );
/**
* Constructor - Call parent constructor with params array.
*
@ -465,8 +467,10 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
* @return mixed Property.
*/
public function __get( $name ) {
if ( in_array( $name, $this->compat_fields ) ) {
return $this->$name;
}
}
/**
* Make private properties settable for backwards compatibility.
@ -479,8 +483,10 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
* @return mixed Newly-set property.
*/
public function __set( $name, $value ) {
if ( in_array( $name, $this->compat_fields ) ) {
return $this->$name = $value;
}
}
/**
* Make private properties checkable for backwards compatibility.
@ -492,8 +498,10 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
* @return bool Whether the property is set.
*/
public function __isset( $name ) {
if ( in_array( $name, $this->compat_fields ) ) {
return isset( $this->$name );
}
}
/**
* Make private properties un-settable for backwards compatibility.
@ -504,21 +512,9 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
* @param string $name Property to unset.
*/
public function __unset( $name ) {
if ( in_array( $name, $this->compat_fields ) ) {
unset( $this->$name );
}
/**
* Make private/protected methods readable for backwards compatibility.
*
* @since 4.0.0
* @access public
*
* @param callable $name Method to call.
* @param array $arguments Arguments to pass when calling.
* @return mixed|bool Return value of the callback, false otherwise.
*/
public function __call( $name, $arguments ) {
return call_user_func_array( array( $this, $name ), $arguments );
}
}