In `WP_User_Query`, only call magic method internals against a whitelist of properties, `$compat_fields`.

See #30891.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31125 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-01-11 22:00:23 +00:00
parent d079899553
commit a79c242038
2 changed files with 20 additions and 7 deletions

View File

@ -473,6 +473,8 @@ class WP_User_Query {
*/ */
private $total_users = 0; private $total_users = 0;
private $compat_fields = array( 'results', 'total_users' );
// SQL clauses // SQL clauses
public $query_fields; public $query_fields;
public $query_from; public $query_from;
@ -928,8 +930,10 @@ class WP_User_Query {
* @return mixed Property. * @return mixed Property.
*/ */
public function __get( $name ) { public function __get( $name ) {
if ( in_array( $name, $this->compat_fields ) ) {
return $this->$name; return $this->$name;
} }
}
/** /**
* Make private properties settable for backwards compatibility. * Make private properties settable for backwards compatibility.
@ -937,13 +941,15 @@ class WP_User_Query {
* @since 4.0.0 * @since 4.0.0
* @access public * @access public
* *
* @param string $name Property to set. * @param string $name Property to check if set.
* @param mixed $value Property value. * @param mixed $value Property value.
* @return mixed Newly-set property. * @return mixed Newly-set property.
*/ */
public function __set( $name, $value ) { public function __set( $name, $value ) {
if ( in_array( $name, $this->compat_fields ) ) {
return $this->$name = $value; return $this->$name = $value;
} }
}
/** /**
* Make private properties checkable for backwards compatibility. * Make private properties checkable for backwards compatibility.
@ -955,8 +961,10 @@ class WP_User_Query {
* @return bool Whether the property is set. * @return bool Whether the property is set.
*/ */
public function __isset( $name ) { public function __isset( $name ) {
if ( in_array( $name, $this->compat_fields ) ) {
return isset( $this->$name ); return isset( $this->$name );
} }
}
/** /**
* Make private properties un-settable for backwards compatibility. * Make private properties un-settable for backwards compatibility.
@ -967,8 +975,10 @@ class WP_User_Query {
* @param string $name Property to unset. * @param string $name Property to unset.
*/ */
public function __unset( $name ) { public function __unset( $name ) {
if ( in_array( $name, $this->compat_fields ) ) {
unset( $this->$name ); unset( $this->$name );
} }
}
/** /**
* Make private/protected methods readable for backwards compatibility. * Make private/protected methods readable for backwards compatibility.
@ -981,8 +991,11 @@ class WP_User_Query {
* @return mixed|bool Return value of the callback, false otherwise. * @return mixed|bool Return value of the callback, false otherwise.
*/ */
public function __call( $name, $arguments ) { public function __call( $name, $arguments ) {
if ( 'get_search_sql' === $name ) {
return call_user_func_array( array( $this, $name ), $arguments ); return call_user_func_array( array( $this, $name ), $arguments );
} }
return false;
}
} }
/** /**

View File

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