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

Incorrect use of PARAM_NUMBER for integers in webservices

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.6
    • 2.5
    • Web Services
    • MOODLE_25_STABLE
    • MOODLE_26_STABLE
    • MDL-40666-master
    • 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
    • BACKEND Sprint 2

      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'),
      

            poltawski Dan Poltawski
            poltawski Dan Poltawski
            Frédéric Massart Frédéric Massart
            Sam Hemelryk Sam Hemelryk
            Jérôme Mouneyrac Jérôme Mouneyrac
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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