silverstripe-autocomplete
silverstripe-autocomplete copied to clipboard
Source fields initializing incorrectly.
There are ~two~ three core issues:
- The source fields parameter in constructor should default to empty array, not
null
. - The check on
isset($this->sourceFields)
in->getSourceFields()
will always returntrue
thus preventing a default from ever being set. - Assuming
->getSourceFields()
returned a default, the field name is for the current field, not the field you're searching. So, as it's currently written, it could easily result in a database query error.
Impact: The end result is that it's not possible to leave that field blank, even though the way it's written, it implies it is optional. Leaving this blank results in an error deep in the framework ultimately caused by the filter in this module defining a ->filterAny()
entry with a key exactly equal to :PartialMatch
(due to the $sourceField
being null and coercing to an empty string).
Affects: Appears to affect 3.5.2
and 4.x
(or dev-master
).
Updated above to reflect that there are three issues, not two (third issue being DB query error if you actually did default the source field on the source DataObject
to the current field's name (likely on another DataObject
).