Repository navigation
fix(course-structure): prune deleted lessons from outline saves - #8260
Draft
faisalahammad wants to merge 1 commit into
Draft
faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
A lesson deleted or trashed while still in the course outline made the course-structure save fail with 403 (or 400 when nested in a module) because map_meta_cap denies edit_post for a missing post and sanitize_item rejected the id. The stale block then lingered in the editor. Skip nonexistent lessons in the permission callback, prune them in sanitize_item so the rest of the structure saves, and treat the save response as authoritative so the editor drops the stale block. Fixes Automattic#8183
Author
|
Two GitHub restrictions on my account that maintainers may need to fix up:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #8183
Proposed Changes
sanitize_item()prunes them so the rest of the structure still saves. Lessons the user genuinely may not edit still return 403.The 403 came from
map_meta_cap():current_user_can( 'edit_post', $id )returnsdo_not_allowwhenget_post()is null, so a single deleted lesson id failed the whole request. A stale lesson nested in a module skipped the permission loop and failed later insanitize_item()withsensei_course_structure_missing_lesson(400).Screenshots
None, no visual changes.
Testing Instructions
New/Updated Hooks
None.
Deprecated Code
None.
Changelog entry
Changelog Entry Details
Significance
Type
Message
Fix a deleted or trashed lesson blocking the course outline from being saved and lingering in the editor.
Note: the
changelog/fix-deleted-lesson-blocks-course-savefile is committed on this branch because it comes from a fork, so CI cannot push the entry.Out of scope, worth a separate issue
current_user_can( 'edit_post' )incan_user_save_structure(); the loop only walks top-level items. A module lesson another teacher owns can still be retitled and reassigned throughsave_module(). This gap is pre-existing and unchanged by this PR.sensei_course_structure_missing_module.