Changing chapter name in XML breaks preview button in Studio
Steps to Reproduce
1. Go to unit (this an MITx test course): https://studio.edge.edx.org/container/block-v1:MITx+S101+2015_T1+type@vertical+block@e9ec465f8bc949ae930ad5d8047e6e81
2. Press Preview
Expected behavior: would see content
Actual Behavior: page not found
To create in a fresh course:
1.) Export course
2.) Change chapter file name ex. (0c1ec994774145e1a11d82d108e68203.xml to changed.xml)
3.) Change course.xml reference ex. (url_name="0c1ec994774145e1a11d82d108e68203" to url_name="changed")
4.) Import course
5.) Go to Studio and click on preview
LMS is fine, and you can navigate to the unit on preview.edx.org.
Reason for Variance
User Impact Summary
I have updated the PR#9862 with `mongo` implementation as well. Mongo uses cache, so I have added a method to check if the selected parent is valid or not (going to the top of the course root). If any orphan found do not fetch the parent from they cache but check it from the `collection`. Any xblock is not an orphan If parents are `None` and `block_type` is in `['course', 'library']`.
Worked for mongo module store.
The Mongo has slightly a different way of dealing when you try to fetch the parents of item. The method uses cache. If an component has been updated with orphan parent, the cache is updated and it only returns a single parent (Which possibly can be an orphan).
I tried one solution where i checked the selected parent from cache is in course orphans or not, but i think that would be an expensive call because we would be checking alot more non-orphan parents.
Still not sure on what bases I need to unset the cache for that particular component because there are components like overview , info etc which does not have a parents. I will discuss this within team tomorrow and checkout whats the better way of dealing with it.
I have changed the logic for filtering out the orphans. Previously I tried of getting the course_orphan & filtering orphan parents & grand-parents. Now using a recursive method, it verifies that if an xblock has a path to the root or not. It return Boolean whether or not a xblock has path to the course root.