Skip to content

Fix observer: check against empty course preferences field - #46

Merged
TamaroWalter merged 1 commit into
mainfrom
fix/observer
Oct 16, 2026
Merged

TamaroWalter merged 1 commit into
mainfrom
fix/observer

Conversation

@TamaroWalter

@TamaroWalter TamaroWalter commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

🔀 Purpose of this PR:

  • Fixes a bug
  • Updates for a new Moodle version
  • Adds a new feature of functionality
  • Improves or enhances existing features
  • Refactoring: restructures code for better performance or maintainability
  • Testing: add missing or improve existing tests
  • Miscellaneous: code cleaning (without functional changes), documentation, configuration, ...

📝 Description:

The course_deleted observer did not check if the courses field of the preferences is empty, which cause property_exist() to throw an error.

This is now fixed with an is_object() check. DB performance was improved by pre-filtering all records that may have the courseid in the preference field.

The unit test were improved to cover this case.


📋 Checklist

Please confirm the following (check all that apply):

  • I have phpunit and/or behat tests that cover my changes or additions.
  • Code passes the code checker without errors and warnings.
  • Code passes the moodle-ci/cd pipeline on all supported Moodle versions or the ones the plugin supports.

The course_deleted observer did not check if the courses field of the
preferences is empty, which cause property_exist() to throw an error.

This is now fixed with an is_object() check. DB performance was improved
by pre-filtering all records that may have the courseid in the preference
field.
@TamaroWalter TamaroWalter changed the title Fix observer: check against empty course preferences Fix observer: check against empty course preferences field Oct 16, 2026
@TamaroWalter TamaroWalter self-assigned this Oct 16, 2026
@TamaroWalter
TamaroWalter requested review from bluetom and removed request for bluetom October 16, 2026 07:59
@TamaroWalter
TamaroWalter merged commit 3202a21 into main Oct 16, 2026
42 checks passed
@TamaroWalter
TamaroWalter deleted the fix/observer branch October 16, 2026 09:27
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

Successfully merging this pull request may close these issues.

1 participant