Make WordPress Core

Changeset 31138


Ignore:
Timestamp:
01/11/2015 12:00:05 AM (12 years ago)
Author:
wonderboymusic
Message:

In WP_Error:

  • wp_send_json_error() accesses $errors on an instance, it must be public
  • $error_data is a local message cache for error codes and doesn't particularly hide info, would be the only non-public field or method in the class

Make $errors and $error_data public and remove magic methods.

See #30891.

File:
1 edited

Legend:

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

    r31126 r31138  
    2525         * @since 2.1.0
    2626         * @var array
    27          * @access private
    28          */
    29         private $errors = array();
     27         */
     28        public $errors = array();
    3029
    3130        /**
     
    3433         * @since 2.1.0
    3534         * @var array
    36          * @access private
    37          */
    38         private $error_data = array();
     35         */
     36        public $error_data = array();
    3937
    4038        /**
     
    6361                if ( ! empty($data) )
    6462                        $this->error_data[$code] = $data;
    65         }
    66 
    67         /**
    68          * Make private properties readable for backwards compatibility.
    69          *
    70          * @since 4.0.0
    71          * @access public
    72          *
    73          * @param string $name Property to get.
    74          * @return mixed Property.
    75          */
    76         public function __get( $name ) {
    77                 return $this->$name;
    78         }
    79 
    80         /**
    81          * Make private properties settable for backwards compatibility.
    82          *
    83          * @since 4.0.0
    84          * @access public
    85          *
    86          * @param string $name  Property to set.
    87          * @param mixed  $value Property value.
    88          * @return mixed Newly-set property.
    89          */
    90         public function __set( $name, $value ) {
    91                 return $this->$name = $value;
    92         }
    93 
    94         /**
    95          * Make private properties checkable for backwards compatibility.
    96          *
    97          * @since 4.0.0
    98          * @access public
    99          *
    100          * @param string $name Property to check if set.
    101          * @return bool Whether the property is set.
    102          */
    103         public function __isset( $name ) {
    104                 return isset( $this->$name );
    105         }
    106 
    107         /**
    108          * Make private properties un-settable for backwards compatibility.
    109          *
    110          * @since 4.0.0
    111          * @access public
    112          *
    113          * @param string $name Property to unset.
    114          */
    115         public function __unset( $name ) {
    116                 unset( $this->$name );
    11763        }
    11864
Note: See TracChangeset for help on using the changeset viewer.