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

    Details

    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull Master Branch:
      MDL-37552-master

      Description

      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    13/May/13