Moodle
  1. Moodle
  2. MDL-37961

XML-RPC and SOAP error while using False as VALUE_DEFAULT

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.4, 2.4.1, 2.5
    • Fix Version/s: 2.3.5, 2.4.2
    • Component/s: Web Services
    • Labels:
      None
    • Testing Instructions:
      Hide
      1. Test the web services using SOAP, XML-RPC and REST.
      2. Make sure they all work.
      3. Use a function with a default boolean parameter
        • Master: message::search_contacts()
        • 2.3, 2.4: course::delete_categories_parameters() change recursive to false first!
      4. Confirm that the default value is respected.
      Show
      Test the web services using SOAP, XML-RPC and REST. Make sure they all work. Use a function with a default boolean parameter Master: message::search_contacts() 2.3, 2.4: course::delete_categories_parameters() change recursive to false first! Confirm that the default value is respected.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-37961-master

      Description

      There is an eval() error when creating the definition of the functions when a webservice function uses a PARAM_BOOL as PARAM_DEFAULT, and set the default to false.

      Ie:

          public static function search_contacts_parameters() {
              return new external_function_parameters(
                  array(
                      'searchtext' => new external_value(PARAM_CLEAN, 'String the user\'s fullname has to match to be found'),
                      'onlymycourses' => new external_value(PARAM_BOOL, 'Limit search to the user\'s courses',
                          VALUE_DEFAULT, false)
                  )
              );
          }
      

      Will cause this to be generated:

      public function core_message_search_contacts($searchtext, $onlymycourses=) {
      

      The problem being here:

      # webservice/lib.php:1193
                                  case PARAM_BOOL:
                                      $paramanddefault .= '='.$keydesc->default; break;
      

        Gliffy Diagrams

          Activity

          Hide
          Jérôme Mouneyrac added a comment -

          Thanks Fred, we really need to have https://tracker.moodle.org/browse/MDL-27779 done so we could have detected the issue easily.

          Show
          Jérôme Mouneyrac added a comment - Thanks Fred, we really need to have https://tracker.moodle.org/browse/MDL-27779 done so we could have detected the issue easily.
          Hide
          Frédéric Massart added a comment -

          This can certainly be backported, but the method that caused the problem in master was only introduced in master, so it's probably also safe not to backport it. Jerome?

          Show
          Frédéric Massart added a comment - This can certainly be backported, but the method that caused the problem in master was only introduced in master, so it's probably also safe not to backport it. Jerome?
          Hide
          Jérôme Mouneyrac added a comment -

          I'm pretty confident into this fix => backport it + add few test instruction just mention how to test it it should be enough.

          Show
          Jérôme Mouneyrac added a comment - I'm pretty confident into this fix => backport it + add few test instruction just mention how to test it it should be enough.
          Hide
          Frédéric Massart added a comment -

          Thanks Jerome. Pushing for integration!

          Show
          Frédéric Massart added a comment - Thanks Jerome. Pushing for integration!
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (23, 24 & master), thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (23, 24 & master), thanks!
          Hide
          Rajesh Taneja added a comment -

          Thanks Fred,

          Works great.

          Show
          Rajesh Taneja added a comment - Thanks Fred, Works great.
          Hide
          Damyon Wiese added a comment -

          Congratulations this fix has been added to Moodle!

          You may want to dedicate this issue to someone special on this Valentines day.

          Thanks!

          Show
          Damyon Wiese added a comment - Congratulations this fix has been added to Moodle! You may want to dedicate this issue to someone special on this Valentines day. Thanks!

            People

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

              Dates

              • Created:
                Updated:
                Resolved: