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

When adding a glossary, "non-object" error in mod/glossary/lib.php on line 389

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.2
    • Fix Version/s: 1.9.3
    • Component/s: Glossary
    • Labels:
      None
    • Environment:
      Windows 2003 IIS 6 (with FastCGI)
      PHP 5.2.6
      MySQL 5.0.51b
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      When adding a Glossary, the following notice is reported by PHP:

      PHP Notice: Trying to get property of non-object in mod/glossary/lib.php on line 389

      384 if(!empty($glossary->cmidnumber))

      { 385 $params = array('itemname'=>$glossary->name, 'idnumber'=>$glossary->cmidnumber); 386 }

      else

      { 387 // MDL-14303 388 $cm = get_coursemodule_from_instance('glossary', $glossary->id); 389 $params = array('itemname'=>$glossary->name, 'idnumber'=>$cm->id); 390 }

      For some reason, $cm comes back empty, so we get the error on line 389. Maybe for a new glossary the cm record hasn't been added yet?

      I don't know how necessary it is to set idnumber, or whether it always needs to be set to the cm->id, but the following at least prevents the error from occurring

      384 $params = array('itemname'=>$glossary->name);
      385 if (array_key_exists('cmidnumber', $glossary))

      { 386 //cmidnumber may not be always present 387 $params['idnumber'] = $glossary->cmidnumber; 388 }

      Also, I was expecting to see an item in the grade book for each glossary, but there doesn't seem to be one. Again, maybe my understanding of how glossaries work may not be correct.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                skodak Petr Skoda
                Reporter:
                xxxxxxx Gordon Bateson
                Tester:
                Dan Poltawski
                Participants:
                Component watchers:
                Adrian Greeve, Mihail Geshoski, Peter Dias
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  15/Oct/08