moodle-filter_filtercodes
moodle-filter_filtercodes copied to clipboard
Bug: the plugin mutates global variable `$USER` when filtering texts with tags
Prerequisites
- [X] I'm reporting the issue to the correct repository.
- [X] I am running the latest version of this plugin (if not, please upgrade first).
- [X] I checked the README.md and Wiki documentation but did not find my answer.
- [X] I searched to make sure that this issue had not already been reported.
- [X] I have, or I know someone who has, the ability and willingness to test the fix on a Moodle LMS-based site.
- [X] I am submitting no more than one bug report per issue ticket (please do not submit multiple bugs in one issue ticket).
- [X] I understand that support is provided by volunteer(s).
What happened?
It's been found that global variable $USER is ameded with fullname
property on a string convertion. This seems to be a regression of https://github.com/michael-milette/moodle-filter_filtercodes/commit/3806e4b786d70e5554569a971ef57b9b1eec7f66 where $u = $USER;
should be $u = clone $USER;
to prevent $USER
mutation.
What do you think should have happened?
I expected global variable USER is not changed when filter is applied to a string
Steps to reproduce
- Login as admin user;
- Turn
filter_filtercodes
on site level; - Create a test course with a label with a random tag in its text;
- View the course and the label;
- Debug any request and confirm that
$USER
now hasfullname
property added.
If debugging is not your thingy the following can be done:
- Purge sessions (remove all files in
/var/lib/sitedata/sessions/
or whatever storage is used) - Log out as admin
- Log in as admin
- Search by
fullname
in the session data, eggrep -lr 'fullname' /var/lib/sitedata/sessions/
- Confirm that new session doesn't have it
- Access the course and view the label with the tag
- Search through the session files again
- Confirm that after viewing the label
fullname
is now added to global USER
Screenshots
No response
Moodle version
Moodle 4.4
Installed Moodle UI Language packs.
- [ ] English only
- [ ] One or more other languages/regional dialects (specify below)
- [ ] Other
If other language(s), please specify
No response
Workaround
No response
Additional information
No response
System information
N/A
Code of Conduct
- [X] I have read and agree to the project's code of conduct.