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

REST protocol doesn't handle empty array (client to server way)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Deferred
    • Affects Version/s: 2.0, Future Dev
    • Fix Version/s: None
    • Component/s: Web Services
    • Labels:
    • Affected Branches:
      MOODLE_20_STABLE

      Description

      Empty array aren't send to the REST server, find a way to send them.

      The following description will break because no $options array is recieved by the REST server (the REST client didn't send empty array):

      /**
           * Returns description of method parameters
           * @return external_function_parameters
           */
          public static function get_courses_parameters() {
              return new external_function_parameters(
                                  array(
                                          'search' => new external_value(PARAM_TEXT, 'string to search'),
                                          'downloadable' => new external_value(PARAM_BOOL, 'course can be downloadable'),
                                          'enrollable' => new external_value(PARAM_BOOL, 'course can be enrollable'),
                                          'options' => new external_single_structure(
                                              array(
                                                      'ids' => new external_multiple_structure(new external_value(PARAM_INTEGER, 'id of a course in the hub course directory'), 'ids of course', VALUE_OPTIONAL),
                                                      'sitecourseids' => new external_multiple_structure(new external_value(PARAM_INTEGER, 'id of a course in the site'), 'ids of course in the site', VALUE_OPTIONAL),
                                                      'coverage' => new external_value(PARAM_TEXT, 'coverage', VALUE_OPTIONAL),
                                                      'licenceshortname' => new external_value(PARAM_ALPHANUMEXT, 'licence short name', VALUE_OPTIONAL),
                                                      'subject' => new external_value(PARAM_ALPHANUM, 'subject', VALUE_OPTIONAL),
                                                      'audience' => new external_value(PARAM_ALPHA, 'audience', VALUE_OPTIONAL),
                                                      'educationallevel' => new external_value(PARAM_ALPHA, 'educational level', VALUE_OPTIONAL),
                                                      'language' => new external_value(PARAM_ALPHANUMEXT, 'language', VALUE_OPTIONAL),
                                                      'allsitecourses' => new external_value(PARAM_INTEGER,
                                                              'if 1 return all not visible and visible courses whose siteid is the site
                                                                  matching token. And course of this site only. In case of public token access, this param option is ignored', VALUE_DEFAULT, 0),
                                              ), 'course info')
                      )
              );
          }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jerome Jérôme Mouneyrac
              Reporter:
              jerome Jérôme Mouneyrac
              Participants:
              Component watchers:
              Juan Leyva, Jake Dallimore, Jun Pataleta
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: