Project: moodle
Issue MDL-43367: get_child_contexts() returns invalid contexts when context path missing
This problem was reported by partner. The trouble is that for various reasons the context path may be missing which results in invalid SQL like path selector in get_child_contexts() - we need to verify the path is valid before using it. The problem is that the get_child_contexts() may be used when deleting data which resulted in deletion of all contexts in several existing sites when using some add-ons... Short term solution: # print debugging message when get_child_contexts() on contexts that do not have path or depth and return empty array # prevent deleting of system context Long term solution (new issue to be created): * prevent deleting of invalid contexts in UI * add CLI tool for diagnostics and rebuilding of context paths * add more debugging notices to inform admins that there is something wrong with contexts * add more debugging info for admins that try to insert data directly to database tables without rebuilding the contexts * maybe add workaround code for invalid contexts that tries to lookup children using some other info
Story points: 4