Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#46923 new defect (bug)

$wpdb->get_var() — empty sting becomes a NULL

Reported by: tkama's profile Tkama Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.1.1
Component: Database Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Because of the following condition, we get NULL, even if a real field value is an empty string!

<?php
return ( isset( $values[ $x ] ) && $values[ $x ] !== '' ) ? $values[ $x ] : null;

See `wp-db.php` Line 2477

I think it is better to delete $values[ $x ] !== '' check and return field value as it is if it exists - what is usually meant by NULL in PHP (empty string is not null!).

Change History (1)

#1 @SergeyBiryukov
5 years ago

  • Component changed from General to Database
  • Description modified (diff)
Note: See TracTickets for help on using tickets.