[wp-trac] [WordPress Trac] #27272: WP meta queries comparing apples to oranges
WordPress Trac
noreply at wordpress.org
Mon Oct 20 16:15:33 UTC 2014
#27272: WP meta queries comparing apples to oranges
------------------------------------------+-----------------------------
Reporter: Denis-de-Bernardy | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Query | Version: 3.8.1
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+-----------------------------
Comment (by Denis-de-Bernardy):
Replying to [comment:11 boonebgorges]:
> That said, it's possible that I'm missing something. Can we get a unit
test that demonstrates how the suggested casting makes a difference in
results?
See comment-6 further up:
1. insert post meta where value = 2
2. test that a query where value >= 1 yields the row
3. test that a query where value >= 10 does NOT yield the row
The test currently fails miserably at step 3, because the SQL it produces
is like:
{{{
CAST(wp_postmeta.meta_value AS SIGNED) <= '10'
}}}
The left-hand side cast is basically ignored, because 10 got sanitized as
a string.
Therefor my initial suggestion: rather than introduce potential for
problems by not systematically sanitizing things, just cast both sides of
the operator when a plugin is explicitly requesting a typed meta query.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27272#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list