Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot enable a disabled filter before viewing Manage Filters page #418

Open
michael-milette opened this issue Oct 21, 2022 · 0 comments
Open

Comments

@michael-milette
Copy link
Contributor

I think Moosh is a great tool and really appreciate the time and effort you put into developing and making it available to the Moodle community. Unfortunately, I have come across an issue that I am really hoping you will be able to address soon.

Issue summary

I wrote a bash script that automates the installation of Moodle 3.11.7 using the CLI. The script uses Moosh v1.7 to enable plugins and pre-set many settings before the administrator logs in for the first time. I use Moosh for many things but am having trouble getting it to enable a disabled filter.

After completing the installation of Moodle, I tried to enable the Glossary Auto-Linking filter using the following Moosh command:

moosh -n filter-set glossary 1

This results in the following error message:

Invalid filter name: 'glossary''. Possible values: displayh5p,emoticon,urltolink,mediaplugin,activitynames,mathjaxloader.

The same happens whenever I try to enable any disabled filter.

What is happening

I did a bit of investigation and discovered that the issue occurs on the following lines of Moosh’s /Moosh/Command/Moodle39/Filter/FilterSet.php file.

This line properly identifies that the Glossary Auto-Linking filter is available:

Line 40: $plugininfos = core_plugin_manager::instance()->get_plugins_of_type('filter');

However, this line seems to create an array of objects that only includes filters which are currently enabled:

Line 42: $states = filter_get_global_states();

Since $states does not include any filters that are disabled, the code execution does not itterate through the foreach loop:

Line 43 foreach ($states as $state) {

This results in the following error being displayed:

Invalid filter name: 'glossary''. Possible values: displayh5p,emoticon,urltolink,mediaplugin,activitynames,mathjaxloader.

Workaround

The only way to get the moosh command to enable a disabled filer is to:

  1. Login as an administrator.
  2. Navigate to Site Administration > Plugins > Filters > Manage Filters.
  3. Execute the above-mentioned Moosh command.

The simple act of viewing the Manage Filters page does something which results in the moosh command working perfectly. Just to be clear, all I did was login and navigate to that page. I did not change any settings along the way.

What I expected

I expected to be able to enable a disabled filter without having to log into Moodle and view the Manage Filters page first.

I would be so thankful if you could please make it possible to enable filters right after a CLI installation and before anyone logs in and views pages.

Let me know if you have any questions.

Best regards,

Michael Milette

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant