Bug #22951 Bug Fixed

search:field_name parameter doesn’t work with unchecked checkbox and ‘not’

Version: 3.5.1 Reporter: James Catt

This is an archived bug report. If you are experiencing a similar issue, upgrade to the latest release and if that does not solve the problem, submit a new bug report

I have a checkbox field called hide_from_search (field_id_334) in my pages channel with a value of ‘yes’. If I run a channel:entries call like so:

{exp:channel:entries channel="pages" search:hide_from_search="not yes"}

…entries where the checkbox is unchecked will not be returned. I’ve done some digging and found that it’s essentially an SQL problem—EE sets the field to NULL in the database when the box is unchecked, but when it runs the search it uses the following query:

SELECT t.entry_id FROM exp_channel_titles AS t
       LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id LEFT JOIN exp_channel_data AS wd ON wd.entry_id = t.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id WHERE t.entry_id !='' AND t.site_id IN ('1')  AND t.entry_date < 1486583648  AND (t.expiration_date = 0 OR t.expiration_date > 1486583648) AND t.channel_id IN (3) AND t.status = 'open' AND ( (wd.site_id=1 AND wd.field_id_334 NOT LIKE "%yes%") )ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc LIMIT 0, 10000

…but field_id_334 NOT LIKE "%yes%" won’t’ match NULL values.

I haven’t tested under 3.5.2, but I didn’t see anything in the release notes that sounded like it would affect this.

Also note that this problem didn’t occur under EE 2 (I believe it was setting the unchecked field to blank instead of NULL).

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases