Make WordPress Core

Changeset 59337


Ignore:
Timestamp:
11/03/2024 11:01:38 PM (6 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Explicitly return false in magic __isset() methods.

This commit fixes an issue where some magic __isset() methods were potentially returning void (if the prop is not in an allow-listed array of fields) instead of an explicit boolean false.

Addressed methods:

  • WP_Comment::__isset()
  • WP_Query::__isset()

Follow-up to [28523], [31151], [34583], [34599].

Props justlevine.
See #52217.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r56433 r59337  
    352352     * @since 4.4.0
    353353     *
    354      * @param string $name Property name.
    355      * @return bool
     354     * @param string $name Property to check if set.
     355     * @return bool Whether the property is set.
    356356     */
    357357    public function __isset( $name ) {
     
    360360            return property_exists( $post, $name );
    361361        }
     362
     363        return false;
    362364    }
    363365
  • trunk/src/wp-includes/class-wp-query.php

    r58180 r59337  
    40124012            return isset( $this->$name );
    40134013        }
     4014
     4015        return false;
    40144016    }
    40154017
Note: See TracChangeset for help on using the changeset viewer.