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

Allow web services to accept/return null for external_single_structure and external_multiple_structure

XMLWordPrintable

    • MOODLE_402_STABLE
    • MOODLE_403_STABLE
    • Hide

      This change is fully covered by tests, we already allow NULLs to be returned when scalar is expected, so this should not cause any problem when encoding the result in different WS servers.

      Show
      This change is fully covered by tests, we already allow NULLs to be returned when scalar is expected, so this should not cause any problem when encoding the result in different WS servers.

      At present it is not possible to return NULL from WS method becauseĀ 
      external_api::clean_returnvalue() does not allow it forĀ  single and multiple structure.

      This is a problem because in cases such as \core_message_external::get_conversation_between_users() where developers incorrectly throw exception instead of returning NULL indicating that no data was found.

      if ($conversation) {
          return $conversation;
      } else {
          // We have to throw an exception here because the external functions annoyingly
          // don't accept null to be returned for a single structure.
          throw new \moodle_exception('errorconversationdoesnotexist', 'message');
      } 

      At the same time we could optionally allow NULLs in WS parameters instead of single and multiple structure.

      This should be fully backwards compatible.

            skodak Petr Skoda
            skodak Petr Skoda
            Farhan Karmali Farhan Karmali
            Andrew Lyons Andrew Lyons
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m

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