6ead7a0c by Marty Penner

Ensure the User metacache is updated when a meta field is set

1 parent 9e90ca86
......@@ -7,7 +7,7 @@ class User {
public $id = 0;
protected $_wpuser;
public $_metacache = Array(); // should be protected, need to figure out how invisible byte works with serialize and not using base64 encode
public $_metacache = []; // should be protected, need to figure out how invisible byte works with serialize and not using base64 encode
public function __construct($id, $name = '', $blog_id = '') {
$this->_wpuser = new WP_User($id, $name, $blog_id);
......@@ -22,12 +22,20 @@ class User {
return $this->getMeta($key, true);
}
/**
* Magically set a meta value and persist it to the store.
*
* @param $key
* @param $val
*/
public function __set($key, $val) {
$this->setMeta($key, $val);
// Update the meta cache
$this->_metacache[$key] = $val;
}
public function __sleep() {
return Array('_metacache', 'id', 'ID');
return ['_metacache', 'id', 'ID'];
}
public function __wakeup() {
......@@ -46,7 +54,7 @@ class User {
public function __call($method, $params) {
if (method_exists($this->_wpuser, $method)) {
$this->setUser();
return call_user_func_array(Array($this->_wpuser, $method), $params);
return call_user_func_array([$this->_wpuser, $method], $params);
}
$classname = get_class($this->_wpuser);
......