[wp-trac] [WordPress Trac] #20043: WP_User missing magic __unset() method
WordPress Trac
noreply at wordpress.org
Tue Sep 22 12:39:34 UTC 2015
#20043: WP_User missing magic __unset() method
-----------------------------+------------------------
Reporter: johnjamesjacoby | Owner: chriscct7
Type: enhancement | Status: reopened
Priority: normal | Milestone: 4.4
Component: Users | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-----------------------------+------------------------
Changes (by boonebgorges):
* keywords: has-patch needs-docs => has-patch
* status: closed => reopened
* resolution: fixed =>
Comment:
[34380] is causing errors in the `test_user_unset_uppercase_id()` test
introduced in the same changeset. What's happening is this:
- `__unset()` unsets `$user->ID`
- The test then attempts to access `$user->ID`. Since the property no
longer exists (`! isset( $user->ID )`), the magic `__get()` kicks in.
- `__get()` tries to `get_user_meta( $this->ID, 'ID', true )`. But
`$this->ID` is an undefined property.
Unsetting an object property like `ID` is going to cause similar problems
through core and elsewhere. Either we should have a blacklist of
properties that cannot be unset (so `unset( $user->ID )` would return
false), or `unset( $user->ID )` should just empty the property (`$user->ID
= 0`).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/20043#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list