Make WordPress Core

Changeset 31135


Ignore:
Timestamp:
01/10/2015 10:57:17 PM (10 years ago)
Author:
wonderboymusic
Message:

In WP_Text_Diff_Renderer_Table:

  • In [28525], $_diff_threshold, $inline_diff_renderer, and $_show_split_view were marked protected; magic methods were also added.
  • The magic methods should only perform operations on a whitelisted set of properties, now specified in $compat_fields
  • Remove __call(), is unnecessary and can wreak havoc on the parent class.

This class is used in one place: wp_text_diff().

See #30891.

File:
1 edited

Legend:

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

    r30497 r31135  
    6868     */
    6969    protected $_show_split_view = true;
     70
     71    protected $compat_fields = array( '_show_split_view', 'inline_diff_renderer', '_diff_threshold' );
    7072
    7173    /**
     
    466468     */
    467469    public function __get( $name ) {
    468         return $this->$name;
     470        if ( in_array( $name, $this->compat_fields ) ) {
     471            return $this->$name;
     472        }
    469473    }
    470474
     
    480484     */
    481485    public function __set( $name, $value ) {
    482         return $this->$name = $value;
     486        if ( in_array( $name, $this->compat_fields ) ) {
     487            return $this->$name = $value;
     488        }
    483489    }
    484490
     
    493499     */
    494500    public function __isset( $name ) {
    495         return isset( $this->$name );
     501        if ( in_array( $name, $this->compat_fields ) ) {
     502            return isset( $this->$name );
     503        }
    496504    }
    497505
     
    505513     */
    506514    public function __unset( $name ) {
    507         unset( $this->$name );
    508     }
    509 
    510     /**
    511      * Make private/protected methods readable for backwards compatibility.
    512      *
    513      * @since 4.0.0
    514      * @access public
    515      *
    516      * @param callable $name      Method to call.
    517      * @param array    $arguments Arguments to pass when calling.
    518      * @return mixed|bool Return value of the callback, false otherwise.
    519      */
    520     public function __call( $name, $arguments ) {
    521         return call_user_func_array( array( $this, $name ), $arguments );
     515        if ( in_array( $name, $this->compat_fields ) ) {
     516            unset( $this->$name );
     517        }
    522518    }
    523519}
Note: See TracChangeset for help on using the changeset viewer.