moodle-plugin-ci
moodle-plugin-ci copied to clipboard
Adjust filter plugin validation requirements to comply with Moodle 4.5
This patch is addressing filter plugin validation compliance with 4.5 raised at #321. Filter API have been updated to use the standard Moodle Class Autoloading infrastructure (https://moodledev.io/docs/4.5/devupdate#filter-plugins), this introduced requirement for backward compatibility in addition to new filter class location.
Possible Moodle version compatibility options for plugins now become:
- 4.4 and below → expect file
filter.phpcontaining classfilter_[pluginname]. - 4.5 → expect file
classes/text_filter.phpcontaining classtext_filter. - 4.5 and below → expect file
classes/text_filter.phpcontaining classtext_filterand filefilter.phpcontainingclass_alias.
Possible Moodle versions test scenarios matrix:
- Moodle 4.5, plugin compatibility 4.5 → pass
- Moodle 4.5, plugin compatibility 4.4 and below → fail
- Moodle 4.4, plugin compatibility 4.4 and below → pass
- Moodle 4.4, plugin compatibility 4.5 and below → pass
- Moodle 4.4, plugin compatibility 4.5 → fail
The patch implements validation logic listed above and introduces 2 new methods:
getRequiredFunctionCallsin plugin type specific Requirements class to validate that file contains function call.FileTokens::notFoundHintcan be used to give some context for validation error to improve developer experience.
Currently this tool does not support the determine version compatibility declared in version.php ($plugin->supported), for this simple scenario I use file existence check as indicator of backward compatibility implemented in plugin, in future the tool would possibly benefit from using information from $plugin->supported property.
Changeset has been tested locally with https://github.com/gjbarnard/moodle-filter_synhi plugin:
4.5, filter_synhi main:
RUN Validating filter_synhi
> Found required file: version.php
> Found required file: lang/en/filter_synhi.php
> Found required file: classes/text_filter.php
! Skipping validation of missing or optional file: db/upgrade.php
> In classes/text_filter.php, found class filter_synhi\text_filter
> In lang/en/filter_synhi.php, found language filtername
! Skipping validation of missing or optional file: db/install.xml
> In filter.php, found function call class_alias
4.5, filter_synhi main, filter.php deleted:
RUN Validating filter_synhi
> Found required file: version.php
> Found required file: lang/en/filter_synhi.php
> Found required file: classes/text_filter.php
! Skipping validation of missing or optional file: db/upgrade.php
> In classes/text_filter.php, found class filter_synhi\text_filter
> In lang/en/filter_synhi.php, found language filtername
! Skipping validation of missing or optional file: db/install.xml
! Skipping validation of missing or optional file: filter.php
4.5, filter_synhi V402.1.0:
RUN Validating filter_synhi
> Found required file: version.php
> Found required file: lang/en/filter_synhi.php
X Failed to find required file: classes/text_filter.php
! Skipping validation of missing or optional file: db/upgrade.php
! Skipping validation of missing or optional file: classes/text_filter.php
> In lang/en/filter_synhi.php, found language filtername
! Skipping validation of missing or optional file: db/install.xml
X In filter.php, failed to find function call class_alias
X Hint: https://moodledev.io/docs/4.5/devupdate#filter-plugins
4.4, filter_synhi V402.1.0:
RUN Validating filter_synhi
> Found required file: version.php
> Found required file: lang/en/filter_synhi.php
> Found required file: filter.php
! Skipping validation of missing or optional file: db/upgrade.php
> In filter.php, found class filter_synhi
> In lang/en/filter_synhi.php, found language filtername
! Skipping validation of missing or optional file: db/install.xml
4.4, filter_synhi main:
RUN Validating filter_synhi
> Found required file: version.php
> Found required file: lang/en/filter_synhi.php
> Found required file: filter.php
! Skipping validation of missing or optional file: db/upgrade.php
> In classes/text_filter.php, found class filter_synhi\text_filter
> In lang/en/filter_synhi.php, found language filtername
! Skipping validation of missing or optional file: db/install.xml
> In filter.php, found function call class_alias
4.4, filter_synhi main, filter.php deleted:
RUN Validating filter_synhi
> Found required file: version.php
> Found required file: lang/en/filter_synhi.php
X Failed to find required file: filter.php
! Skipping validation of missing or optional file: db/upgrade.php
> In classes/text_filter.php, found class filter_synhi\text_filter
> In lang/en/filter_synhi.php, found language filtername
! Skipping validation of missing or optional file: db/install.xml
! Skipping validation of missing or optional file: filter.php