From bbc7ca2d0dd1bd6ee7005c145979efff4832c868 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 11 Jan 2015 21:59:54 +0000 Subject: [PATCH] In `WP_User_Query`, only call magic method internals against a whitelist of properties, `$compat_fields`. See #30891. git-svn-id: https://develop.svn.wordpress.org/trunk@31144 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/user.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index 17fe9fcdaf..15a20f3b98 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -473,6 +473,8 @@ class WP_User_Query { */ private $total_users = 0; + private $compat_fields = array( 'results', 'total_users' ); + // SQL clauses public $query_fields; public $query_from; @@ -928,7 +930,9 @@ class WP_User_Query { * @return mixed Property. */ public function __get( $name ) { - return $this->$name; + if ( in_array( $name, $this->compat_fields ) ) { + return $this->$name; + } } /** @@ -937,12 +941,14 @@ class WP_User_Query { * @since 4.0.0 * @access public * - * @param string $name Property to set. + * @param string $name Property to check if set. * @param mixed $value Property value. * @return mixed Newly-set property. */ public function __set( $name, $value ) { - return $this->$name = $value; + if ( in_array( $name, $this->compat_fields ) ) { + return $this->$name = $value; + } } /** @@ -955,7 +961,9 @@ class WP_User_Query { * @return bool Whether the property is set. */ public function __isset( $name ) { - return isset( $this->$name ); + if ( in_array( $name, $this->compat_fields ) ) { + return isset( $this->$name ); + } } /** @@ -967,7 +975,9 @@ class WP_User_Query { * @param string $name Property to unset. */ public function __unset( $name ) { - unset( $this->$name ); + if ( in_array( $name, $this->compat_fields ) ) { + unset( $this->$name ); + } } /** @@ -981,7 +991,10 @@ class WP_User_Query { * @return mixed|bool Return value of the callback, false otherwise. */ public function __call( $name, $arguments ) { - return call_user_func_array( array( $this, $name ), $arguments ); + if ( 'get_search_sql' === $name ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; } }