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. git-svn-id: https://develop.svn.wordpress.org/trunk@31138 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
406b174a55
commit
ad81bf20db
|
@ -24,18 +24,16 @@ class WP_Error {
|
||||||
*
|
*
|
||||||
* @since 2.1.0
|
* @since 2.1.0
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private $errors = array();
|
public $errors = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the list of data for error codes.
|
* Stores the list of data for error codes.
|
||||||
*
|
*
|
||||||
* @since 2.1.0
|
* @since 2.1.0
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private $error_data = array();
|
public $error_data = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the error.
|
* Initialize the error.
|
||||||
|
@ -64,58 +62,6 @@ class WP_Error {
|
||||||
$this->error_data[$code] = $data;
|
$this->error_data[$code] = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Make private properties readable for backwards compatibility.
|
|
||||||
*
|
|
||||||
* @since 4.0.0
|
|
||||||
* @access public
|
|
||||||
*
|
|
||||||
* @param string $name Property to get.
|
|
||||||
* @return mixed Property.
|
|
||||||
*/
|
|
||||||
public function __get( $name ) {
|
|
||||||
return $this->$name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make private properties settable for backwards compatibility.
|
|
||||||
*
|
|
||||||
* @since 4.0.0
|
|
||||||
* @access public
|
|
||||||
*
|
|
||||||
* @param string $name Property to set.
|
|
||||||
* @param mixed $value Property value.
|
|
||||||
* @return mixed Newly-set property.
|
|
||||||
*/
|
|
||||||
public function __set( $name, $value ) {
|
|
||||||
return $this->$name = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make private properties checkable for backwards compatibility.
|
|
||||||
*
|
|
||||||
* @since 4.0.0
|
|
||||||
* @access public
|
|
||||||
*
|
|
||||||
* @param string $name Property to check if set.
|
|
||||||
* @return bool Whether the property is set.
|
|
||||||
*/
|
|
||||||
public function __isset( $name ) {
|
|
||||||
return isset( $this->$name );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make private properties un-settable for backwards compatibility.
|
|
||||||
*
|
|
||||||
* @since 4.0.0
|
|
||||||
* @access public
|
|
||||||
*
|
|
||||||
* @param string $name Property to unset.
|
|
||||||
*/
|
|
||||||
public function __unset( $name ) {
|
|
||||||
unset( $this->$name );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all error codes.
|
* Retrieve all error codes.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue