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

Incorrect use of PARAM_NUMBER for integers in webservices

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.6
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      Hide

      Test for core_cohort_update_cohorts:

      1. Run phpunit tests

      Test for core_cohort_get_cohorts:

      1. Create a cohort, assign some users to the cohort make note of the DB id of the cohort on the edit page
      2. Run the webservice core_cohort_get_cohorts with an array containing the DB id of the cohort you created: $params = array('cohortids' => array(COHORTIDHERE));
      3. VERIFY: the webservice returns correctly and the cohort is displayed
      4. On Home /  ▶ Site administration /  ▶ Plugins /  ▶ Web services /  ▶ API Documentation
      5. Browse to core_cohort_get_cohorts, VERIFY: that the documentation of the response suggests id is an int and NOT a double

      Test for core_enrol_get_enrolled_users_with_capability:

      1. Enrol a user into a course as a student, make note of the course id (this test assumes you haven't messed with capability definitions, check that if problems)
      2. Run the webservice core_enrol_get_enrolled_users_with_capability with the courseid you recorded: $params = array('coursecapabilities' => array(array('courseid' => COURSEIDHERE, 'capabilities' => array('mod/assign:view'))));
        # VERIFY: the webservice returns correctly and the user is returened
      3. On Home /  ▶ Site administration /  ▶ Plugins /  ▶ Web services /  ▶ API Documentation
      4. Browse to core_enrol_get_enrolled_users_with_capability
      5. VERIFY: that the documentation of the response suggests 'id of the user' is an int and NOT a double
      Show
      Test for core_cohort_update_cohorts: Run phpunit tests Test for core_cohort_get_cohorts: Create a cohort, assign some users to the cohort make note of the DB id of the cohort on the edit page Run the webservice core_cohort_get_cohorts with an array containing the DB id of the cohort you created: $params = array('cohortids' => array(COHORTIDHERE)); VERIFY: the webservice returns correctly and the cohort is displayed On Home /  ▶ Site administration /  ▶ Plugins /  ▶ Web services /  ▶ API Documentation Browse to core_cohort_get_cohorts, VERIFY: that the documentation of the response suggests id is an int and NOT a double Test for core_enrol_get_enrolled_users_with_capability: Enrol a user into a course as a student, make note of the course id (this test assumes you haven't messed with capability definitions, check that if problems) Run the webservice core_enrol_get_enrolled_users_with_capability with the courseid you recorded: $params = array('coursecapabilities' => array(array('courseid' => COURSEIDHERE, 'capabilities' => array('mod/assign:view')))); # VERIFY: the webservice returns correctly and the user is returened On Home /  ▶ Site administration /  ▶ Plugins /  ▶ Web services /  ▶ API Documentation Browse to core_enrol_get_enrolled_users_with_capability VERIFY: that the documentation of the response suggests 'id of the user' is an int and NOT a double
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull Master Branch:
      MDL-40666-master
    • Sprint:
      BACKEND Sprint 2

      Description

      While I was writing MDL-39956 I discovered a bug caused by webservices changing an int to a floating point number.

      PARAM_NUMBER is a float and should only be used for floating point numbers, here are some other incorrectly specified params:

      cohort/externallib.php:                    'id' => new external_value(PARAM_NUMBER, 'ID of the cohort'),
      cohort/externallib.php:                            'id' => new external_value(PARAM_NUMBER, 'ID of the cohort'),
      enrol/externallib.php:                    'id'    => new external_value(PARAM_NUMBER, 'ID of the user'),
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  18/Nov/13