Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-3212

mismatch parameters between function definitions and calls

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.5, 2.1, 2.1.1, 2.1.2
    • Fix Version/s: None
    • Component/s: Module: Certificate
    • Labels:
      None
    • Workaround:
      Hide

      As I think certificate code uses globals when it shouldn't, I suggest to change lines

      /************************************************************************

      • Inserts final user data when a certificate is created. *
        ************************************************************************/
        function certificate_issue($course, $certrecord, $cm) {
        global $USER, $DB, $certificate;

      to :

      /************************************************************************

      • Inserts final user data when a certificate is created. *
        ************************************************************************/
        function certificate_issue($course, $certificate, $certrecord, $cm) {
        global $USER, $DB;

      in the mod/certificate/lib.php file and to make no change to mod/certificate/view.php

      Show
      As I think certificate code uses globals when it shouldn't, I suggest to change lines /************************************************************************ Inserts final user data when a certificate is created. * ************************************************************************/ function certificate_issue($course, $certrecord, $cm) { global $USER, $DB, $certificate; to : /************************************************************************ Inserts final user data when a certificate is created. * ************************************************************************/ function certificate_issue($course, $certificate, $certrecord, $cm) { global $USER, $DB; in the mod/certificate/lib.php file and to make no change to mod/certificate/view.php
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE

      Description

      The function named certificate_issue is defined at line 850 of mod/certificate/lib.php

      function certificate_issue($course, $certrecord, $cm) {

      And it is called 2 times in differents places of mod/certificate/view.php :

      Line 84: certificate_issue($course, $certificate, $certrecord, $cm); // update certrecord as issued
      Line 122: certificate_issue($course, $certificate, $certrecord, $cm); // update certrecord as issued

      You see the problem : the function is defined with 3 parameters but is called with 4, so $cm parameter is not passed correctly and as it is used to get the context an error is displayed

        Attachments

          Activity

            People

            Assignee:
            markn Mark Nelson
            Reporter:
            jmvedrine Jean-Michel Vedrine
            Participants:
            Component watchers:
            Mark Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: