Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/wp-includes/class-wp-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ public static function get_data_by( $field, $value ) {
$field = 'id';
}

if ( ! $value ) {
return false;
}

Comment on lines +206 to +209
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this is fine and required.

Removing the lower one has the potential of breaking things.

Example: ! ' 0' is false, while ! trim( ' 0' ) is true

So removing lines 219-222 could potentially change the result of get_data_by()

if ( 'id' === $field ) {
// Make sure the value is numeric to avoid casting objects, for example, to int 1.
if ( ! is_numeric( $value ) ) {
Expand All @@ -216,10 +220,6 @@ public static function get_data_by( $field, $value ) {
$value = trim( $value );
}

if ( ! $value ) {
return false;
}

switch ( $field ) {
case 'id':
$user_id = $value;
Expand Down
Loading