Moodle
  1. Moodle
  2. MDL-26757

glossary_print_recent_activity() function causes PHP fatal error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.9.11
    • Fix Version/s: 1.9.12
    • Component/s: Glossary
    • Labels:
    • Environment:
      FreeBSD 8.1-RELEASE, PHP 5.3.5, Apache 2.2, MySQL 5.1.54
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      16683

      Description

      We have a course with a glossary, but when producing the "New glossary entries:" section of the "Recent Activity" box on the front page of the course, PHP logs an error and aborts.

      The error logged is:

      [10-Mar-2011 11:23:57] PHP Catchable fatal error: Object of class moodle_url could not be converted to string in /usr/local/www/moodle/mod/glossary/lib.php on line 314

      Line 314 reads:

      echo '<div class="info"><a href="'.$link.'">'.format_text($entry->concept, true).'</a></div>';

      The $link variable was instantiated a few lines prior to that as a moodle_url object:

      $link = new moodle_url($CFG->wwwroot.'/mod/glossary/view.php' , $urlparams);

      My response to the error message is to use $link->out() instead of $link (see attached patch), and that seems to work. Is there a better way to fix the problem?

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment -

          Weird, there should not be any moodle_url class in 1.9.11. In 2.0 it should be using audtomatic toString conversion method.

          Show
          Petr Škoda added a comment - Weird, there should not be any moodle_url class in 1.9.11. In 2.0 it should be using audtomatic toString conversion method.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Raising to blocker, this is one regression introduced by MDL-22970. Assigning to Aparup, in charge of the original issue.

          Note we must not use moodle_url under 1.9. Just plain, old-style, links.

          Thanks for spotting and reporting this, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Raising to blocker, this is one regression introduced by MDL-22970 . Assigning to Aparup, in charge of the original issue. Note we must not use moodle_url under 1.9. Just plain, old-style, links. Thanks for spotting and reporting this, ciao
          Hide
          Aparup Banerjee added a comment -

          thanks for report , fixed and filed pull request, hopefully it gets in in next integration.

          Show
          Aparup Banerjee added a comment - thanks for report , fixed and filed pull request, hopefully it gets in in next integration.
          Show
          Aparup Banerjee added a comment - https://github.com/nebgor/moodle/compare/MOODLE_19_STABLE...MDL-26757
          Hide
          David Siebörger added a comment -

          I've removed my patch from our Moodle installation and applied Aparup's patch, and it looks like it's working fine here.

          Thanks, everyone!

          Show
          David Siebörger added a comment - I've removed my patch from our Moodle installation and applied Aparup's patch, and it looks like it's working fine here. Thanks, everyone!
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Thanks Apu, and thanks David for reporting & feedback!

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Thanks Apu, and thanks David for reporting & feedback! Ciao
          Hide
          Dongsheng Cai added a comment -

          closing, thanks.

          Show
          Dongsheng Cai added a comment - closing, thanks.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: