Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-27757

Load missing data if required in completion_info::is_enabled()

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.3
    • Fix Version/s: 2.0.4
    • Component/s: Course completion
    • Labels:

      Description

      If an instance of the completion_info class is created with only a placeholder course object (e.g. with only 'id' => 2), the is_enabled() function will throw a notice when trying to access the course's "enablecompletion" property. Here is a patch to lazy load that field if it is missing and is needed.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              salvetore Michael de Raadt added a comment -

              Hi, Aaron.

              This is your baby, so I assume you know what you mean, but it would be good to add a few details to this issue, if nothing else, so we can keep an eye on it at HQ.

              Michael;

              Show
              salvetore Michael de Raadt added a comment - Hi, Aaron. This is your baby, so I assume you know what you mean, but it would be good to add a few details to this issue, if nothing else, so we can keep an eye on it at HQ. Michael;
              Hide
              sry_not4sale Aaron Barnes added a comment -

              @Michael

              All done, thanks.

              Show
              sry_not4sale Aaron Barnes added a comment - @Michael All done, thanks.
              Hide
              samhemelryk Sam Hemelryk added a comment -

              Thanks Aaron - this has been integrated now.
              Cheers
              Sam

              Show
              samhemelryk Sam Hemelryk added a comment - Thanks Aaron - this has been integrated now. Cheers Sam
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Passing test: I've executed this in one forum/view.php hacked file:

              $co = new stdclass();
              $co->id = $course->id;
              $completion = new completion_info($co);
              print_object($co);
              $completion->is_enabled();
              print_object($co);

              And lazy load worked as expected, without outputting any notice at all with results:

              stdClass Object
              (
                  [id] => 9
                  [enablecompletion] => 1
              )

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Passing test: I've executed this in one forum/view.php hacked file: $co = new stdclass(); $co->id = $course->id; $completion = new completion_info($co); print_object($co); $completion->is_enabled(); print_object($co); And lazy load worked as expected, without outputting any notice at all with results: stdClass Object ( [id] => 9 [enablecompletion] => 1 )
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Upstream, upstream, this is part of upstream, upstream... thanks!

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Upstream, upstream, this is part of upstream, upstream... thanks!

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    1/Aug/11