From eed3698c495ec77abe9c140509f4bcac12aceb66 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 11 Jan 2015 22:41:24 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@31151 git-svn-id: http://core.svn.wordpress.org/trunk@31132 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 33 ++++++++++++++++----------------- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 6084b10127..5bf5fba17f 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1300,6 +1300,10 @@ class WP_Query { */ 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. * @@ -3956,11 +3960,13 @@ class WP_Query { * @return mixed Property. */ 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 * @access public @@ -3969,19 +3975,9 @@ class WP_Query { * @return bool Whether the property is set. */ public function __isset( $name ) { - 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 ); + if ( in_array( $name, $this->compat_fields ) ) { + return isset( $this->$name ); + } } /** @@ -3992,10 +3988,13 @@ class WP_Query { * * @param callable $name Method to call. * @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 ) { - 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; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index e685deeb8e..b28e00d501 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31150'; +$wp_version = '4.2-alpha-31151'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.