[wp-trac] [WordPress Trac] #15178: Empty endpoint same as missing endpoint: empty vs isset query_var.

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 7 17:13:11 UTC 2011


#15178: Empty endpoint same as missing endpoint: empty vs isset query_var.
------------------------------------+--------------------------
 Reporter:  5ubliminal              |       Owner:  johnbillion
     Type:  defect (bug)            |      Status:  closed
 Priority:  normal                  |   Milestone:
Component:  Query                   |     Version:  3.0.1
 Severity:  normal                  |  Resolution:  duplicate
 Keywords:  has-patch dev-feedback  |
------------------------------------+--------------------------
Changes (by nacin):

 * status:  accepted => closed
 * resolution:   => duplicate
 * milestone:  Awaiting Review =>


Comment:

 otto42 and I recently conducted a thought experiment on all of this as
 well. #10710 did actually make this much easier. Previously, the value
 didn't exist in WP_Query->query_vars at all. Now it does, it's just empty.
 You can check for isset() against it and it works just fine.

 The problem is with WP_Query::get(), which returns `''` instead of false
 when nothing is set.

 I'd be willing to modify that to be false. Because it's a query variable,
 it normally will always return a string, so I doubt the change will hurt
 any existing code.

 The other option is a WP_Query::exists() method, which simply returns the
 results of isset(). Unfortunately this would not work easily for core
 query variables, as those are set to empty (but not null) values in
 fill_query_vars(). At that point we'd probably want to set all string-
 based QVs to null instead, and then keep a list of array-based QVs to then
 return the results of empty() on, or something.

 I don't think another rewrite rule is necessary. Additionally, it'd end up
 with 'true' as a string, rather than a boolean. And a string of '1' might
 conflict with situations where you do have the ability to specify a
 endpoint values in addition to leaving it blank. Because this was actually
 fixed in some regard, I'm going to close it again. Feel free to open a new
 ticket to address the ::get() issue, but at the very least, you now have a
 workaround.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15178#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list