Make WordPress Core


Ignore:
Timestamp:
01/11/2015 10:40:53 PM (12 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r31126 r31151  
    13001300         */
    13011301        private $stopwords;
     1302
     1303        private $compat_fields = array( 'query_vars_hash', 'query_vars_changed' );
     1304
     1305        private $compat_methods = array( 'init_query_flags', 'parse_tax_query' );
    13021306
    13031307        /**
    … …  
    39573961         */
    39583962        public function __get( $name ) {
    3959                 return $this->$name;
    3960         }
    3961 
    3962         /**
    3963          * Make private properties settable for backwards compatibility.
     3963                if ( in_array( $name, $this->compat_fields ) ) {
     3964                        return $this->$name;
     3965                }
     3966        }
     3967
     3968        /**
     3969         * Make private properties checkable for backwards compatibility.
    39643970         *
    39653971         * @since 4.0.0
    … …  
    39703976         */
    39713977        public function __isset( $name ) {
    3972                 return isset( $this->$name );
    3973         }
    3974 
    3975         /**
    3976          * Make private properties settable for backwards compatibility.
    3977          *
    3978          * @since 4.0.0
    3979          * @access public
    3980          *
    3981          * @param string $name Property to unset.
    3982          */
    3983         public function __unset( $name ) {
    3984                 unset( $this->$name );
     3978                if ( in_array( $name, $this->compat_fields ) ) {
     3979                        return isset( $this->$name );
     3980                }
    39853981        }
    39863982
    … …  
    39933989         * @param callable $name      Method to call.
    39943990         * @param array    $arguments Arguments to pass when calling.
    3995          * @return mixed|bool Return value of the callback, otherwise false.
     3991         * @return mixed|bool Return value of the callback, false otherwise.
    39963992         */
    39973993        public function __call( $name, $arguments ) {
    3998                 return call_user_func_array( array( $this, $name ), $arguments );
     3994                if ( in_array( $name, $this->compat_methods ) ) {
     3995                        return call_user_func_array( array( $this, $name ), $arguments );
     3996                }
     3997                return false;
    39993998        }
    40003999
Note: See TracChangeset for help on using the changeset viewer.