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

Exporters read structure for format fields produces invalid 'required'

    XMLWordPrintable

Details

    Description

      The read structure of an exporter does not produce the expected `required` field for optional formatted fields. The optional property of the formatted property is not applied to the format.

      public static function define_properties() {
          return [
              'content' => [
                  'type' => PARAM_RAW,
                  'optional' => true,
              ],
              'contentformat' => [
                  'type' => PARAM_INT,
                  'optional' => true,
              ]
          ];
      }

      In the above example, the `contentformat` property will be marked as required. This is incorrect, it should be marked optional either from its own optional definition, or from its associated property.

      Attached is a patch that demonstrates the issue, and offers a fix by referring to the parent property.

      Attachments

        Activity

          People

            Unassigned Unassigned
            fred Frédéric Massart
            Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: