In WP_Query, only call magic method internals again whitelists of properties and methods, $compat_fields and $compat_methods. Remove __unset() since __set() is not implemented.

See #30891.


git-svn-id: https://develop.svn.wordpress.org/trunk@31151 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-01-11 22:40:53 +00:00
parent 1178e8a6e1
commit 156a673660

View File

@ -1300,6 +1300,10 @@ class WP_Query {
*/ */
private $stopwords; private $stopwords;
private $compat_fields = array( 'query_vars_hash', 'query_vars_changed' );
private $compat_methods = array( 'init_query_flags', 'parse_tax_query' );
/** /**
* Resets query flags to false. * Resets query flags to false.
* *
@ -3956,11 +3960,13 @@ class WP_Query {
* @return mixed Property. * @return mixed Property.
*/ */
public function __get( $name ) { public function __get( $name ) {
return $this->$name; if ( in_array( $name, $this->compat_fields ) ) {
return $this->$name;
}
} }
/** /**
* Make private properties settable for backwards compatibility. * Make private properties checkable for backwards compatibility.
* *
* @since 4.0.0 * @since 4.0.0
* @access public * @access public
@ -3969,19 +3975,9 @@ class WP_Query {
* @return bool Whether the property is set. * @return bool Whether the property is set.
*/ */
public function __isset( $name ) { public function __isset( $name ) {
return isset( $this->$name ); if ( in_array( $name, $this->compat_fields ) ) {
} return isset( $this->$name );
}
/**
* Make private properties settable for backwards compatibility.
*
* @since 4.0.0
* @access public
*
* @param string $name Property to unset.
*/
public function __unset( $name ) {
unset( $this->$name );
} }
/** /**
@ -3992,10 +3988,13 @@ class WP_Query {
* *
* @param callable $name Method to call. * @param callable $name Method to call.
* @param array $arguments Arguments to pass when calling. * @param array $arguments Arguments to pass when calling.
* @return mixed|bool Return value of the callback, otherwise false. * @return mixed|bool Return value of the callback, false otherwise.
*/ */
public function __call( $name, $arguments ) { public function __call( $name, $arguments ) {
return call_user_func_array( array( $this, $name ), $arguments ); if ( in_array( $name, $this->compat_methods ) ) {
return call_user_func_array( array( $this, $name ), $arguments );
}
return false;
} }
/** /**