WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/16/2015 01:05:52 AM (5 years ago)
Author:
wonderboymusic
Message:

In PHP 5.0.0, is_a() became deprecated in favour of the instanceof operator. Calling is_a() would result in an E_STRICT warning.

In PHP 5.3.0, is_a() is no longer deprecated, and will therefore no longer throw E_STRICT warnings.

To avoid warnings in PHP < 5.3.0, convert all is_a() calls to $var instanceof WP_Class calls.

instanceof does not throw any error if the variable being tested is not an object, it simply returns false.

Props markoheijnen, wonderboymusic.
Fixes #25672.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/user.php

    r31144 r31188  
    113113 */
    114114function wp_authenticate_username_password($user, $username, $password) {
    115     if ( is_a( $user, 'WP_User' ) ) {
     115    if ( $user instanceof WP_User ) {
    116116        return $user;
    117117    }
     
    168168 */
    169169function wp_authenticate_cookie($user, $username, $password) {
    170     if ( is_a( $user, 'WP_User' ) ) {
     170    if ( $user instanceof WP_User ) {
    171171        return $user;
    172172    }
     
    203203 */
    204204function wp_authenticate_spam_check( $user ) {
    205     if ( $user && is_a( $user, 'WP_User' ) && is_multisite() ) {
     205    if ( $user instanceof WP_User && is_multisite() ) {
    206206        /**
    207207         * Filter whether the user has been marked as a spammer.
     
    17111711    global $wpdb;
    17121712
    1713     if ( is_a( $userdata, 'stdClass' ) ) {
     1713    if ( $userdata instanceof stdClass ) {
    17141714        $userdata = get_object_vars( $userdata );
    1715     } elseif ( is_a( $userdata, 'WP_User' ) ) {
     1715    } elseif ( $userdata instanceof WP_User ) {
    17161716        $userdata = $userdata->to_array();
    17171717    }
     
    19701970 */
    19711971function wp_update_user($userdata) {
    1972     if ( is_a( $userdata, 'stdClass' ) )
     1972    if ( $userdata instanceof stdClass ) {
    19731973        $userdata = get_object_vars( $userdata );
    1974     elseif ( is_a( $userdata, 'WP_User' ) )
     1974    } elseif ( $userdata instanceof WP_User ) {
    19751975        $userdata = $userdata->to_array();
     1976    }
    19761977
    19771978    $ID = (int) $userdata['ID'];
Note: See TracChangeset for help on using the changeset viewer.