Moodle
  1. Moodle
  2. MDL-43367

get_child_contexts() returns invalid contexts when context path missing

    Details

    • Story Points (Obsolete):
      4
    • Sprint:
      BACKEND Sprint 8

      Description

      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:

      1. print debugging message when get_child_contexts() on contexts that do not have path or depth and return empty array
      2. 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

        Gliffy Diagrams

          Activity

          Hide
          Rajesh Taneja added a comment -

          Thanks for fixing this Petr,

          Patch looks spot-on, you might want to add component in git commit message before pushing it for integration.

          Show
          Rajesh Taneja added a comment - Thanks for fixing this Petr, Patch looks spot-on, you might want to add component in git commit message before pushing it for integration.
          Hide
          Petr Skoda added a comment -

          Thanks for the review. Submit for integration.

          Show
          Petr Skoda added a comment - Thanks for the review. Submit for integration.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Note this issue is going to receive a comment from the, still experimental, pre-checker of issues awaiting integration, so accept the results knowing that there are aspects (false positives, the comment contents...) to be improved before this gets final status.

          For any comment, suggestion... MDLSITE-2662 is the issue where these initial runs are being discussed.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Note this issue is going to receive a comment from the, still experimental, pre-checker of issues awaiting integration, so accept the results knowing that there are aspects (false positives, the comment contents...) to be improved before this gets final status. For any comment, suggestion... MDLSITE-2662 is the issue where these initial runs are being discussed. Ciao
          Hide
          CiBoT added a comment -

          Results for MDL-43367

          Show
          CiBoT added a comment - Results for MDL-43367 Branch w51_ MDL-43367 _m24_contextpath to be integrated into upstream MOODLE_24_STABLE Executed job http://ci.stronk7.com/job/Precheck%20remote%20branch/716 Execution status: 0 Details: http://ci.stronk7.com/job/Precheck%20remote%20branch/716/artifact/work/smurf.html Branch w51_ MDL-43367 _m25_contextpath to be integrated into upstream MOODLE_25_STABLE Executed job http://ci.stronk7.com/job/Precheck%20remote%20branch/719 Execution status: 0 Details: http://ci.stronk7.com/job/Precheck%20remote%20branch/719/artifact/work/smurf.html Branch w51_ MDL-43367 _m26_contextpath to be integrated into upstream MOODLE_26_STABLE Executed job http://ci.stronk7.com/job/Precheck%20remote%20branch/721 Execution status: 0 Details: http://ci.stronk7.com/job/Precheck%20remote%20branch/721/artifact/work/smurf.html Branch w51_ MDL-43367 _m27_contextpath to be integrated into upstream master Executed job http://ci.stronk7.com/job/Precheck%20remote%20branch/722 Execution status: 0 Details: http://ci.stronk7.com/job/Precheck%20remote%20branch/722/artifact/work/smurf.html
          Hide
          Sam Hemelryk added a comment -

          Thanks Petr - this has been integrated now.

          Show
          Sam Hemelryk added a comment - Thanks Petr - this has been integrated now.
          Hide
          Sam Hemelryk added a comment -

          Tested and passed during integration review - thanks Petr.

          Show
          Sam Hemelryk added a comment - Tested and passed during integration review - thanks Petr.
          Hide
          Sam Hemelryk added a comment -

          Thank you, your code has landed just in time for 2013.
          Merry Christmas and may your 2014 be even better than 2013.

          Kind regards with much holiday spirit
          Sam

          Show
          Sam Hemelryk added a comment - Thank you, your code has landed just in time for 2013. Merry Christmas and may your 2014 be even better than 2013. Kind regards with much holiday spirit Sam

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Agile