Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
6ead7a0c
authored
2014-07-29 12:01:28 -0400
by
Marty Penner
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Ensure the User metacache is updated when a meta field is set
1 parent
9e90ca86
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
lib/User.php
lib/User.php
View file @
6ead7a0
...
...
@@ -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
);
...
...
Please
register
or
sign in
to post a comment