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

No response receieved from web service function core_group_get_groups, 500 internal server error received, call to undefined function in error log

XMLWordPrintable

    • MOODLE_23_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • MDL-37552-master
    • Hide

      Copy the attached test.php file into your Moodle site.
      Run it without the fix, you see:

      Fatal error: Call to undefined function file_rewrite_pluginfile_urls() in /Users/jerome/Sites/master/lib/externallib.php on line 697

      Run it with the fix, you see no errors.

      Show
      Copy the attached test.php file into your Moodle site. Run it without the fix, you see: Fatal error: Call to undefined function file_rewrite_pluginfile_urls() in /Users/jerome/Sites/master/lib/externallib.php on line 697 Run it with the fix, you see no errors.

      Having setup and configured a web service for groups, calling the web service function core_group_get_groups returned no response or exception but we got a response code and status of 500: Internal Server Error.

      Switched the debugging onto developer in Moodle and received the below line in the error log.
      Call to undefined function file_rewrite_pluginfile_urls() in <moodle_dir>/lib/externallib.php on line 690

      Looked in the externallib.php file and found this section of code where the error occurs:

      function external_format_text($text, $textformat, $contextid, $component, $filearea, $itemid) {
          global $CFG;
          
          // Get settings (singleton).
          $settings = external_settings::get_instance();
       
          if ($settings->get_fileurl()) {
              $text = file_rewrite_pluginfile_urls($text, $settings->get_file(), $contextid, $component, $filearea, $itemid);
          }
       
          if (!$settings->get_raw()) {
              $textformat = FORMAT_HTML; // Force format to HTML when not raw.
              $text = format_text($text, $textformat,
                      array('noclean' => true, 'para' => false, 'filter' => $settings->get_filter()));
          }
       
          return array($text, $textformat);
      }

      adding the line:

      require_once("$CFG->libdir/filelib.php");

      and modifying the function call to:

      $text = file_rewrite_pluginfile_urls($text, $settings->get_file(), $contextid, $component, $filearea, $itemid, null);

      shown modified below:

      function external_format_text($text, $textformat, $contextid, $component, $filearea, $itemid) {
          global $CFG;
          require_once("$CFG->libdir/filelib.php");
          // Get settings (singleton).
          $settings = external_settings::get_instance();
       
          if ($settings->get_fileurl()) {
              $text = file_rewrite_pluginfile_urls($text, $settings->get_file(), $contextid, $component, $filearea, $itemid, null);
          }
       
          if (!$settings->get_raw()) {
              $textformat = FORMAT_HTML; // Force format to HTML when not raw.
              $text = format_text($text, $textformat,
                      array('noclean' => true, 'para' => false, 'filter' => $settings->get_filter()));
          }
       
          return array($text, $textformat);
      }

      seems to fix this issue, and a test of calling the core_group_get_groups web service method resulted in a response with the correct data for the group being read and a 200 response code.

        1. test.php
          0.2 kB
          Jérôme Mouneyrac

            jerome Jérôme Mouneyrac
            apf_psydev Adam Fredericks
            Ankit Agarwal Ankit Agarwal
            Damyon Wiese Damyon Wiese
            Damyon Wiese Damyon Wiese
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.