moodle/.upgradenotes/MDL-83859-2024120511024767.yml
Mark Johnson 1613a98102
MDL-83859 core_question: Update filter condition API
This corrects some definitions of the methods in the base condition
class to make things more obvious to developers implementing new
filters.

Previously if your filter wanted to use the default
`core/datafilter/filtertype` class, you still had to implement
`get_filter_class` to return `null`, since it was declared as abstract.
This change defines it as returning `null` by default, so this is no
longer necessary.

Also, this removes the default definitions for `get_condition_key` and
`build_query_from_functions`, and declares them abstract. Currently it
is necessary to override these to implement a functional filter so it
doesn't make sense to have a useless default definition.

This will not cause any breakages with existing filters. All filters
must already be defining the methods that are now abstract, otherwise
they will not function. Any filter that is now overriding
`get_filter_class` to return `null` will continue to work as before,
even though this is no longer necessary.
2024-12-05 11:30:32 +00:00

21 lines
915 B
YAML

issueNumber: MDL-83859
notes:
core_question:
- message: >
The definition of the abstract `core_question\local\bank\condition`
class has changed to make it clearer which methods are required
in child classes.
The `get_filter_class` method is no longer declared as abstract, and
will return `null` by default to use the base
`core/datafilter/filtertype` class. If you have defined this method
to return `null` in your own class, it will continue to work, but
it is no longer necessary.
`build_query_from_filter` and `get_condition_key` are now declared as
abstract, since all filter condition classes must define these
(as well as existing abstract methods) to function. Again, exsiting
child classes will continue to work if they did before, as they
already needed these methods.
type: changed