Fix module order reset when Editor saves a lesson#7910
Conversation
Remove module ownership filters (filter_module_terms, filter_course_selected_terms) before reading and saving the course structure in save_lesson_order(). Without this, non-admin users only retrieve their own modules, causing all other modules to be disassociated from the course on save. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression where saving a lesson as a non-admin (e.g., Editor) could unintentionally drop modules they don’t own from a course and reset the course’s module order, due to module ownership filters affecting the read/save cycle.
Changes:
- Temporarily removes module ownership term filters during
Sensei_Admin::save_lesson_order()so the full course structure is read/saved. - Adds a unit test to ensure module order is preserved when an Editor saves a lesson.
- Adds a changelog entry documenting the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/unit-tests/test-class-lesson.php | Adds coverage to ensure Editor lesson saves do not reset _module_order or disassociate modules. |
| includes/class-sensei-admin.php | Removes/re-adds module ownership filters around course structure read/save to prevent module loss/order reset. |
| changelog/fix-broken-module-order-for-editors | Documents the bugfix in the changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
filter_module_terms,filter_course_selected_terms) strip modules the Editor doesn't own during the read/save cycle insave_lesson_order().Fixes #7889
Test plan
npm run test-php:wp-env -- --filter testAddLessonToCourseOrder_AsEditor_PreservesModuleOrder— should passnpm run test-php:wp-env— only pre-existingSensei_Class_Feature_Flags_Testfailures expected🤖 Generated with Claude Code