[wp-trac] [WordPress Trac] #25672: is_a() causing errors with get_users()
WordPress Trac
noreply at wordpress.org
Thu Oct 24 19:04:26 UTC 2013
#25672: is_a() causing errors with get_users()
------------------------------+------------------------------
Reporter: dgdax | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Warnings/Notices | Version: 3.6.1
Severity: normal | Resolution:
Keywords: needs-patch |
------------------------------+------------------------------
Comment (by dgdax):
Glad to see this is generating some discussion...
Some additional comments/reactions to the above:
- thanks to #Sergey for cleaning up my description
- `is_a()` does work in PHP 5.3+, but behaviour changed since v5.3.7 -
and this is what is causing the problem.
- `instanceof` appears to be the 'officially' preferred method, and as
#marko points out, there are performance benefits also (because no need
for instantiation?). Apparently in some situations where `instanceof` can
also cause instantiation, but I believe these are rare.
- I think the negation issue is really just a warning to developers to be
careful when changing the code. The addition of the brackets `( ... )` in
the corrected example is simply good coding practice, as it makes the
intention explicit, both to PHP and to the next developer reading the
code. (for comparison, would you be so surprised if `( ! $user1 == $user2
)` gave a different result to `( $user1 !== $user2 )` ? )
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25672#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list