Skip to content

Commit

Permalink
MDL-84337 ai: revert external set_action parameter renaming.
Browse files Browse the repository at this point in the history
This preserves backwards compatibility pre 368114c and fixes the
placement table.
  • Loading branch information
paulholden committed Feb 3, 2025
1 parent 07881a5 commit c8473ff
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .upgradenotes/MDL-84337-2025020308374868.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
issueNumber: MDL-84337
notes:
core_ai:
- message: >-
The `plugin` parameter of the `core_ai_set_action` external method now
expects a `<plugin>-<action>` pair as it's value
type: changed
2 changes: 1 addition & 1 deletion ai/amd/build/aiprovider_action_management_table.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ai/amd/build/aiprovider_action_management_table.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ai/amd/src/aiprovider_action_management_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ export default class extends PluginManagementTable {
* Set the plugin state (enabled or disabled).
*
* @param {string} methodname The web service to call.
* @param {string} pluginaction The name of the plugin and action to set the state for.
* @param {string} plugin The name of the plugin and action to set the state for.
* @param {number} state The state to set.
* @returns {Promise}
*/
setPluginState(methodname, pluginaction, state) {
setPluginState(methodname, plugin, state) {
const providerid = this.providerid;
return fetchMany([{
methodname,
args: {
pluginaction,
plugin,
state,
providerid,
},
Expand Down
12 changes: 6 additions & 6 deletions ai/classes/external/set_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class set_action extends external_api {
*/
public static function execute_parameters(): external_function_parameters {
return new external_function_parameters([
'pluginaction' => new external_value(
'plugin' => new external_value(
PARAM_TEXT,
'The name of the plugin and the action to change state for',
VALUE_REQUIRED,
Expand All @@ -59,23 +59,23 @@ public static function execute_parameters(): external_function_parameters {
/**
* Set the providers action state.
*
* @param string $pluginaction The name of the plugin and the action to change state for.
* @param string $plugin The name of the plugin and the action to change state for.
* @param int $state The target state.
* @param int $providerid The provider id.
* @return array
*/
public static function execute(
string $pluginaction,
string $plugin,
int $state,
int $providerid = 0
): array {
// Parameter validation.
[
'pluginaction' => $pluginaction,
'plugin' => $plugin,
'state' => $state,
'providerid' => $providerid,
] = self::validate_parameters(self::execute_parameters(), [
'pluginaction' => $pluginaction,
'plugin' => $plugin,
'state' => $state,
'providerid' => $providerid,
]);
Expand All @@ -84,7 +84,7 @@ public static function execute(
self::validate_context($context);
require_capability('moodle/site:config', $context);

[$plugin, $action] = explode('-', $pluginaction);
[$plugin, $action] = explode('-', $plugin);
$actionname = get_string("action_$action", 'core_ai');

if (!empty($state)) {
Expand Down

0 comments on commit c8473ff

Please sign in to comment.