Moodle
  1. Moodle
  2. MDL-37763

Course asset deletion causes PHP catchable fatal error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.3.4
    • Fix Version/s: None
    • Component/s: Course
    • Labels:
      None
    • Affected Branches:
      MOODLE_23_STABLE
    • Rank:
      47490

      Description

      Teacher is deleting items in the course. Seems to be random, but at some point, in some of our courses, they get a message "Coding error detected, it must be fixed by a programmer: PHP catchable fatal error"

      I found that deleting sectioncache from the course in the database fixes the problem, but I also dug in a bit deeper.

      With debug on:
      Debug info: Argument 2 passed to has_capability() must be an instance of context, boolean given, called in modinfolib.php on line 1097 and defined
      Error code: codingerror

      In debugging the module, modcontext is returning empty causing has_capability to error out.

      I added the following code to modinfolib.php update_user_visible() as a work around, but, I believe the issus is occurring at the time of deletion and not display.

      if ($modcontext != "") {
      if ((!$this->visible or !$this->available) and
      !has_capability('moodle/course:viewhiddenactivities', $modcontext, $userid))

      { $this->uservisible = false; }

      } else

      { $this->uservisible = false; }

      Now the course will open without my intervention.

      I have not been able to 100% pin down a testing method, but it has happend repeatedly this past week (our semester just started), so it might be the upgrade version, it might have been there all along.

      I am running the weekly build Moodle 2.3.4+ (Build: 20130125)

        Issue Links

          Activity

          Hide
          Séverin Terrier added a comment - - edited

          I've got the same error with latest 2.3.4+ installed this morning, reported by user with admin rights.
          Don't know if it's related to this, no users had complained about that with 2.3.4 installed when it was out 14 January 2013.

          Show
          Séverin Terrier added a comment - - edited I've got the same error with latest 2.3.4+ installed this morning, reported by user with admin rights. Don't know if it's related to this, no users had complained about that with 2.3.4 installed when it was out 14 January 2013.
          Hide
          Russell Smith added a comment -

          We are experiencing this failure as well. Investigation so far shows the following;

          mdl_course modinfo column contains information about modules that are not any longer in the database. The current hypothesis is;
          1. You delete some items from the subject.
          2. For some unknown reason, modinfo is not updated in the mdl_table.
          3. People viewing the course or their /my/ page that use that course call fast_get_modinfo() and it ask's the db for context information that no longer exists.

          The difficulty in reproducing this issue is that the failure is a result of the bug, not the cause. So it's hard to nail down what's causing item 2 to break.

          So anybody who knows about modinfolib would be helpful on this bug.

          The workaround proposed feels dangerous to me as it masks the missing items from the user visible function. I don't have enough modinfolib knowledge to understand what other items depend on that information being accurate. It would seem this will create unexplained breakages of Moodle as various points that are hard to debug.

          Investigations into course/view.php made me wonder why there is a rebuild attempt there for rebuild_course_cache in case parts are missing. It's gone in head and there is no comment Justifying it. Petr ported it from 1.9 as a make better check of valid modinfo. However it doesn't account for the case seen here where items are missing.

          So I tried to add a check to cover that off. But the call to fast_get_modinfo fails with the above issue. I could add both the initial workaround and the rebuild_course_cache when there is an issue into the code. But that just seems to add to an already bad kludge to make it all hang together.

          So now we are back to my original question about what is a teacher doing to make the modinfo in the database not match with the context table.

          Show
          Russell Smith added a comment - We are experiencing this failure as well. Investigation so far shows the following; mdl_course modinfo column contains information about modules that are not any longer in the database. The current hypothesis is; 1. You delete some items from the subject. 2. For some unknown reason, modinfo is not updated in the mdl_table. 3. People viewing the course or their /my/ page that use that course call fast_get_modinfo() and it ask's the db for context information that no longer exists. The difficulty in reproducing this issue is that the failure is a result of the bug, not the cause. So it's hard to nail down what's causing item 2 to break. So anybody who knows about modinfolib would be helpful on this bug. The workaround proposed feels dangerous to me as it masks the missing items from the user visible function. I don't have enough modinfolib knowledge to understand what other items depend on that information being accurate. It would seem this will create unexplained breakages of Moodle as various points that are hard to debug. Investigations into course/view.php made me wonder why there is a rebuild attempt there for rebuild_course_cache in case parts are missing. It's gone in head and there is no comment Justifying it. Petr ported it from 1.9 as a make better check of valid modinfo. However it doesn't account for the case seen here where items are missing. So I tried to add a check to cover that off. But the call to fast_get_modinfo fails with the above issue. I could add both the initial workaround and the rebuild_course_cache when there is an issue into the code. But that just seems to add to an already bad kludge to make it all hang together. So now we are back to my original question about what is a teacher doing to make the modinfo in the database not match with the context table.
          Hide
          Russell Smith added a comment -

          Relevant Forum discussion: https://moodle.org/mod/forum/discuss.php?d=220803

          That discussion appear to have gone off the original track in my view. The first stack trace is this issue. Further down the thread it turns into a discussion about $teamsubmission being incorrectly ported into the 2.3 tree. That's not the problem here. And my code review doesn't show me anything about how they could be related.

          Show
          Russell Smith added a comment - Relevant Forum discussion: https://moodle.org/mod/forum/discuss.php?d=220803 That discussion appear to have gone off the original track in my view. The first stack trace is this issue. Further down the thread it turns into a discussion about $teamsubmission being incorrectly ported into the 2.3 tree. That's not the problem here. And my code review doesn't show me anything about how they could be related.
          Hide
          Dan Poltawski added a comment -

          I've not had enough coffee yet, but could this be related to MDL-37939? (Need to check in more detail)

          Show
          Dan Poltawski added a comment - I've not had enough coffee yet, but could this be related to MDL-37939 ? (Need to check in more detail)
          Hide
          Russell Smith added a comment -

          I've had a look at MDL-37939, I've reproduced the symptoms of that, but not fully looked into a relationship. When MDL-37939 is reproduced, it does not trigger this issue. I would proceed on the basis they are not related.

          Show
          Russell Smith added a comment - I've had a look at MDL-37939 , I've reproduced the symptoms of that, but not fully looked into a relationship. When MDL-37939 is reproduced, it does not trigger this issue. I would proceed on the basis they are not related.
          Hide
          Russell Smith added a comment -

          I can now confirm this bug is a duplicate of MDL-37939.

          Replication steps.

          Section 0 has items
          Section 1 has items

          Drag and drop 2 items from section 1 into section 0 at the bottom of section 0.
          Delete the second bottom item from section 0.
          Error will appear, cancel error.
          Refresh course.

          In 2/3 cases so far it produced the error above. In a third test case it produced a different failure case.

          Application of the MDL-37939 fix stops me being able to reproduce this via the steps above.

          Show
          Russell Smith added a comment - I can now confirm this bug is a duplicate of MDL-37939 . Replication steps. Section 0 has items Section 1 has items Drag and drop 2 items from section 1 into section 0 at the bottom of section 0. Delete the second bottom item from section 0. Error will appear, cancel error. Refresh course. In 2/3 cases so far it produced the error above. In a third test case it produced a different failure case. Application of the MDL-37939 fix stops me being able to reproduce this via the steps above.
          Hide
          Russell Smith added a comment -

          bug.png is the error seen when dragging and dropping. Refreshes after this cause the failure in MDL-37763.

          Show
          Russell Smith added a comment - bug.png is the error seen when dragging and dropping. Refreshes after this cause the failure in MDL-37763 .
          Hide
          Dan Poltawski added a comment -

          Thanks for confirming Russsell

          Show
          Dan Poltawski added a comment - Thanks for confirming Russsell

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: