[wp-trac] [WordPress Trac] #30257: wpdb::get_var() returns NULL for existing values that are empty strings

WordPress Trac noreply at wordpress.org
Wed Nov 5 15:20:28 UTC 2014


#30257: wpdb::get_var() returns NULL for existing values that are empty strings
--------------------------+------------------------------
 Reporter:  tyxla         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Database      |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by tyxla):

 Modifying the `get_var()` will not affect the `get_row()` calls that
 @jdgrimes has indicated - these calls will keep working the same way as
 they have nothing to do with `get_var()`.

 I've gone through the entire core and searched for any occurrences of
 `get_var()`, and I did not find any single call that depends on the fact
 that empty strings are considered `NULL`.

 Taking as granted the fact that in PHP `NULL == ''` is `true`, the only
 way to take advantage of the current way `get_var()` is working is to test
 its result by using the value and type comparison operator (`!==` or
 `===`).

 I was able to find only one occurrence of such check in the core:
 https://core.trac.wordpress.org/browser/trunk/src/wp-includes/link-
 template.php#L1574 but will continue working the same way, as it simply
 modifies `NULL` with `''`, so the result is `''`, it will keep working the
 same way like it does now.

 Finally, considering all of the above notes I can conclude that I did not
 find any plausible downsides of having this modification implemented into
 the core.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30257#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list