self.instance_variable_get("@#{ar_field}")
if (dynamic_boost && boost_value = self.send(dynamic_boost))
field_data = Ferret::Field.new(field_data)
field_data.boost = boost_value.to_i
end
field_data
end
On line three, the expression
self.send(ar_field)
returns false if the field is boolean and its value is false. But instead of false being assigned as the value of field_data, the other half of the condition is run to check for an instance variable with that field name. None exists, so the expression returns nil. So field_data is assigned nil, not false as it should be.
We use a boolean 'deleted' field to indicate whether a user has been removed from the system and search only for users that have not. The impact of this bug is enormous -- since we started using this field, all users are being indexed improperly and thus excluded from search results.
Here's a patch to replace line 3 and fix the bug:
# This is a PatientsLikeMe? patch to acts_as_ferret.
# Issue was that field_data was being set to nil for fields with value=false.
begin
field_data = self.send(ar_field)
rescue
field_data = self.instance_variable_get("@#{ar_field}")
end
Thanks for taking a look at this.
Rich Thornett
PatientsLikeMe?
Change History
Download in other formats:
To edit pages or tickets please login with username/password: aaf/aaf
|