Moodle
  1. Moodle
  2. MDL-31734

invalid course format "site" when visiting recent activites page

    Details

    • Rank:
      38329

      Description

      We have used something like

      $sectiontitle = get_string('sectionname', 'format_'.$COURSE->format);
      

      in course/recent_form.php
      This works all good as long as we are visiting the recent activity page for a specific course, but when moodle/course/recent.php?id=1 (all recent activities page) it generates following error

      invalid get_string() identifier: 'sectionname' or component 'format_site'. Perhaps you are missing $string['sectionname'] = ''; in moodle/course/format/site/lang/en/format_site.php?
      

      Thanks

        Issue Links

          Activity

          Hide
          Michael de Raadt added a comment -

          I was able to reproduce that.

          Here is the full stack trace.

          Invalid get_string() identifier: 'sectionname' or component 'format_site'. Perhaps you are missing $string['sectionname'] = ''; in D:\xampp\htdocs\moodle_testing/course/format/site/lang/en/format_site.php?
          
              line 6398 of \lib\moodlelib.php: call to debugging()
              line 7022 of \lib\moodlelib.php: call to core_string_manager->get_string()
              line 104 of \course\recent_form.php: call to get_string()
              line 169 of \lib\formslib.php: call to recent_form->definition()
              line 59 of \course\recent.php: call to moodleform->moodleform()
          
          Show
          Michael de Raadt added a comment - I was able to reproduce that. Here is the full stack trace. Invalid get_string() identifier: 'sectionname' or component 'format_site'. Perhaps you are missing $string['sectionname'] = ''; in D:\xampp\htdocs\moodle_testing/course/format/site/lang/en/format_site.php? line 6398 of \lib\moodlelib.php: call to debugging() line 7022 of \lib\moodlelib.php: call to core_string_manager->get_string() line 104 of \course\recent_form.php: call to get_string() line 169 of \lib\formslib.php: call to recent_form->definition() line 59 of \course\recent.php: call to moodleform->moodleform()
          Hide
          Iurii Kucherov added a comment - - edited

          Hi
          If you want to see "Full report of recent activity..." from site home it tries to show 'site' activity.
          But there is no 'site' activity available.
          I think it can be changed to 'weeks' activity. Or is it better to add 'site' activity?
          Here is a patch.

          diff --git a/course/recent_form.php b/course/recent_form.php
          index b79e443..2d5de5f 100755
          --- a/course/recent_form.php
          +++ b/course/recent_form.php
          @@ -101,7 +101,8 @@ class recent_form extends moodleform {
                       $mform->setAdvanced('user');
                   }
           
          -        $sectiontitle = get_string('sectionname', 'format_'.$COURSE->format);
          +        $format = ($COURSE->format == 'site') ? 'weeks' : $COURSE->format;
          +        $sectiontitle = get_string('sectionname', 'format_'.$format);
           
                   $options = array(''=>get_string('allactivities'));
                   $modsused = array();
          
          Show
          Iurii Kucherov added a comment - - edited Hi If you want to see "Full report of recent activity..." from site home it tries to show 'site' activity. But there is no 'site' activity available. I think it can be changed to 'weeks' activity. Or is it better to add 'site' activity? Here is a patch. diff --git a/course/recent_form.php b/course/recent_form.php index b79e443..2d5de5f 100755 --- a/course/recent_form.php +++ b/course/recent_form.php @@ -101,7 +101,8 @@ class recent_form extends moodleform { $mform->setAdvanced('user'); } - $sectiontitle = get_string('sectionname', 'format_'.$COURSE->format); + $format = ($COURSE->format == 'site') ? 'weeks' : $COURSE->format; + $sectiontitle = get_string('sectionname', 'format_'.$format); $options = array(''=>get_string('allactivities')); $modsused = array();
          Show
          Iurii Kucherov added a comment - added link to github https://github.com/yuyokk/moodle/commit/207dbb36162a6fb5066741d94ad932d1f230143e
          Hide
          Rajesh Taneja added a comment -

          Thanks for the patch Iurii, it seems we are not using $sectiontitle. So rather then adding format check, I have removed this string.

          Also, in such cases we prefer to check course->id === SITEID (https://github.com/yuyokk/moodle/blob/207dbb36162a6fb5066741d94ad932d1f230143e/course/recent_form.php#L67) which helps not to break things later.

          Show
          Rajesh Taneja added a comment - Thanks for the patch Iurii, it seems we are not using $sectiontitle. So rather then adding format check, I have removed this string. Also, in such cases we prefer to check course->id === SITEID ( https://github.com/yuyokk/moodle/blob/207dbb36162a6fb5066741d94ad932d1f230143e/course/recent_form.php#L67 ) which helps not to break things later.
          Hide
          Ankit Agarwal added a comment -

          Hi guys,
          The patch looks good.
          $sectiontitle is not used anywhere in the current file or any of the files it includes ($CFG->dirroot/mod/$modname/lib.php)

          Should be safe to delete it.
          Thanks

          Show
          Ankit Agarwal added a comment - Hi guys, The patch looks good. $sectiontitle is not used anywhere in the current file or any of the files it includes ($CFG->dirroot/mod/$modname/lib.php) Should be safe to delete it. Thanks
          Hide
          Rajesh Taneja added a comment -

          Thanks Ankit,

          Pushing for integration review.

          Show
          Rajesh Taneja added a comment - Thanks Ankit, Pushing for integration review.
          Hide
          Dan Poltawski added a comment -

          I've integrated this, thanks guys!

          Show
          Dan Poltawski added a comment - I've integrated this, thanks guys!
          Hide
          Adrian Greeve added a comment -

          Tested on 2.2, 2.3 and master.
          The invalid get_string() call no longer is displayed as it was before.
          Test passed

          Show
          Adrian Greeve added a comment - Tested on 2.2, 2.3 and master. The invalid get_string() call no longer is displayed as it was before. Test passed
          Hide
          Eloy Lafuente (stronk7) added a comment -

          YEAR!*

          CAF*, TOT!*

          • Your effort amazingly resulted. (unbelievable :-P)
          • Closing as fixed.
          • Tons of thanks.
          Show
          Eloy Lafuente (stronk7) added a comment - YEAR!* CAF*, TOT!* Your effort amazingly resulted. (unbelievable :-P) Closing as fixed. Tons of thanks.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: