Documentation-Issue-Tracker icon indicating copy to clipboard operation
Documentation-Issue-Tracker copied to clipboard

get_var() returns NULL when empty string has been found

Open flymikeGit opened this issue 1 year ago • 1 comments
trafficstars

Issue Description

Description of Return values is "string|null Database query result (as string), or null on failure.". But, per https://core.trac.wordpress.org/ticket/30257, NULL will also be returned if the successful result is an empty string.

URL of the Page with the Issue]

https://developer.wordpress.org/reference/classes/wpdb/get_var/

Section of Page with the issue

Return values

Why is this a problem?

When my code found a return value of NULL, it triggered my error processing logic - instead of returning a successful result of an empty string.

Suggested Fix

Make clear that a NULL return may indicate an error, but could also be the successful result of an empty string.

flymikeGit avatar Aug 01 '24 15:08 flymikeGit