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

Web services: override_webservice_execution callback not always honoured

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.8.6, 3.9.3
    • 3.8.4, 3.8.5
    • Web Services
    • MOODLE_38_STABLE
    • MOODLE_38_STABLE, MOODLE_39_STABLE
    • MDL-69663-master
    • Hide
      1. Download sabotage-add-activity-no-versions.patch and apply it to your Moodle instance.

        git apply /path/to/sabotage-add-activity-no-versions.patch
        

        This updates html block and forum to add webservice overrides.

      2. Purge caches (e.g. via mdk purge)
      3. Go to any course page and turn editing on.
      4. Click the 'Add an activity or resource' button
      5. Confirm that the dialogue comes up with NO activity options to add (it has been successfully sabotaged)
      For 38
      1. As a student enrolled in a course C1, access C1's course page
      2. Go to the Dashboard and check the "Recently accessed courses" block. You should see C1 on there.
      3. Replace "mod_forum_override_webservice_execution()"'s content in "mod/forum/lib.php" with the following code:

         // Check if it's the function we want to override.
            if ($function->name !== 'core_course_get_recent_courses') {
                return false;
            }
            return [];
        

        (This is the code being added by sabotage-add-activity-no-versions.patch . We're just updating it to adapt for 38 since the WS function core_course_get_course_content_items has only been introduced in 39.)

      4. Refresh the dashboard.
      5. Confirm that the recently accessed courses block is now empty.

      Note: At the end of the test, make sure to reset your instance to undo the changes from sabotage-add-activity-no-versions.patch. e.g.

      git reset --hard origin/[BRANCH_NAME]
      

      Show
      Download sabotage-add-activity-no-versions.patch and apply it to your Moodle instance. git apply /path/to/sabotage-add-activity-no-versions.patch This updates html block and forum to add webservice overrides. Purge caches (e.g. via mdk purge ) Go to any course page and turn editing on. Click the 'Add an activity or resource' button Confirm that the dialogue comes up with NO activity options to add (it has been successfully sabotaged) For 38 As a student enrolled in a course C1, access C1's course page Go to the Dashboard and check the " Recently accessed courses " block. You should see C1 on there. Replace " mod_forum_override_webservice_execution() "'s content in " mod/forum/lib.php " with the following code: // Check if it's the function we want to override. if ($function->name !== 'core_course_get_recent_courses') { return false; } return []; (This is the code being added by sabotage-add-activity-no-versions.patch . We're just updating it to adapt for 38 since the WS function core_course_get_course_content_items has only been introduced in 39.) Refresh the dashboard. Confirm that the recently accessed courses block is now empty. Note: At the end of the test, make sure to reset your instance to undo the changes from sabotage-add-activity-no-versions.patch . e.g. git reset --hard origin/[BRANCH_NAME]

      The override_webservice_execution callback is broken if there are multiple implementors in different types of plugin.

      Specifically the problem is this code:

                  foreach ($callbacks as $plugintype => $plugins) {
                      foreach ($plugins as $plugin => $callback) {
                          $result = $callback($externalfunctioninfo, $params);
                          if ($result !== false) {
                              break;
                          }
                      }
                  }
      

      Note that the 'break' line only breaks out of the inner loop.

      An example scenario is:

      • A theme implements a callback function, checks the function name is core_xxx, if so does something, if not returns false
      • A local plugin implements a callback function, checks the function name is core_yyy, if so does something, if not returns false
      • Webservice call occurs with function core_xxx. The theme callback returns a modified result, but the code then goes on to call the local plugin which returns false, and therefore the 'original' standard function call is used.

            quen Sam Marshall
            quen Sam Marshall
            Tim Hunt Tim Hunt
            Jun Pataleta Jun Pataleta
            Janelle Barcega Janelle Barcega
            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 - 3 hours
                3h

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