From 9da861ea63c39a7538f92fbbed200801643251fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Mon, 22 Mar 2021 15:27:09 +0100 Subject: [PATCH 1/2] MDL-71169 external: Use execute as the default external method name If the 'methodname' is not explicitly specified in db/services.php, expect it to be 'execute'. --- lib/upgrade.txt | 2 ++ lib/upgradelib.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 3033d267e30..24ba02be6a7 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -112,6 +112,8 @@ information provided here is intended especially for developers. * The behat transformation 'string time to timestamp' no longer supports datetime format. If provided, the format must be strftime compatible. Example: - I should see "##tomorrow noon##%A, %d %B %Y, %I:%M %p##" +* External functions implementation classes should use 'execute' as the method name, in which case the + 'methodname' property should not be specified in db/services.php file. === 3.10 === * PHPUnit has been upgraded to 8.5. That comes with a few changes: diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 4b3ee394aa5..d16b9884a5d 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -1211,6 +1211,7 @@ function external_update_descriptions($component) { $function = $functions[$dbfunction->name]; unset($functions[$dbfunction->name]); $function['classpath'] = empty($function['classpath']) ? null : $function['classpath']; + $function['methodname'] = $function['methodname'] ?? 'execute'; $update = false; if ($dbfunction->classname != $function['classname']) { @@ -1260,7 +1261,7 @@ function external_update_descriptions($component) { $dbfunction = new stdClass(); $dbfunction->name = $fname; $dbfunction->classname = $function['classname']; - $dbfunction->methodname = $function['methodname']; + $dbfunction->methodname = $function['methodname'] ?? 'execute'; $dbfunction->classpath = empty($function['classpath']) ? null : $function['classpath']; $dbfunction->component = $component; $dbfunction->capabilities = array_key_exists('capabilities', $function)?$function['capabilities']:''; From 4983142e5a3b163a2c3011a6a6fecb2c10d2d076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Mon, 22 Mar 2021 15:49:59 +0100 Subject: [PATCH 2/2] MDL-71169 external: Do not explicitly specify the default methodname --- grade/grading/form/guide/db/services.php | 2 -- grade/grading/form/rubric/db/services.php | 2 -- lib/db/services.php | 18 ------------------ media/player/videojs/db/services.php | 1 - mod/glossary/db/services.php | 3 --- mod/h5pactivity/db/services.php | 7 ------- payment/gateway/paypal/db/services.php | 2 -- 7 files changed, 35 deletions(-) diff --git a/grade/grading/form/guide/db/services.php b/grade/grading/form/guide/db/services.php index 88ea5fda701..545558c96f7 100644 --- a/grade/grading/form/guide/db/services.php +++ b/grade/grading/form/guide/db/services.php @@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die; $functions = [ 'gradingform_guide_grader_gradingpanel_fetch' => [ 'classname' => 'gradingform_guide\\grades\\grader\\gradingpanel\\external\\fetch', - 'methodname' => 'execute', 'description' => 'Fetch the data required to display the grader grading panel, ' . 'creating the grade item if required', 'type' => 'write', @@ -35,7 +34,6 @@ $functions = [ ], 'gradingform_guide_grader_gradingpanel_store' => [ 'classname' => 'gradingform_guide\\grades\\grader\\gradingpanel\\external\\store', - 'methodname' => 'execute', 'description' => 'Store the grading data for a user from the grader grading panel.', 'type' => 'write', 'ajax' => true, diff --git a/grade/grading/form/rubric/db/services.php b/grade/grading/form/rubric/db/services.php index 08b90a960f9..7cdd0bda39c 100644 --- a/grade/grading/form/rubric/db/services.php +++ b/grade/grading/form/rubric/db/services.php @@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die; $functions = [ 'gradingform_rubric_grader_gradingpanel_fetch' => [ 'classname' => 'gradingform_rubric\\grades\\grader\\gradingpanel\\external\\fetch', - 'methodname' => 'execute', 'description' => 'Fetch the data required to display the grader grading panel, ' . 'creating the grade item if required', 'type' => 'write', @@ -35,7 +34,6 @@ $functions = [ ], 'gradingform_rubric_grader_gradingpanel_store' => [ 'classname' => 'gradingform_rubric\\grades\\grader\\gradingpanel\\external\\store', - 'methodname' => 'execute', 'description' => 'Store the grading data for a user from the grader grading panel.', 'type' => 'write', 'ajax' => true, diff --git a/lib/db/services.php b/lib/db/services.php index adec2e98912..8580d22fbea 100644 --- a/lib/db/services.php +++ b/lib/db/services.php @@ -289,7 +289,6 @@ $functions = array( ], 'core_calendar_get_calendar_export_token' => [ 'classname' => 'core_calendar\external\export\token', - 'methodname' => 'execute', 'description' => 'Return the auth token required for exporting a calendar.', 'type' => 'read', 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), @@ -816,14 +815,12 @@ $functions = array( ), 'core_files_delete_draft_files' => array( 'classname' => 'core_files\external\delete\draft', - 'methodname' => 'execute', 'description' => 'Delete the indicated files (or directories) from a user draft file area.', 'type' => 'write', 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), 'core_files_get_unused_draft_itemid' => array( 'classname' => 'core_files\external\get\unused_draft', - 'methodname' => 'execute', 'description' => 'Generate a new draft itemid for the current user.', 'type' => 'write', 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), @@ -839,7 +836,6 @@ $functions = array( ), 'core_form_dynamic_form' => array( 'classname' => 'core_form\external\dynamic_form', - 'methodname' => 'execute', 'description' => 'Process submission of a dynamic (modal) form', 'type' => 'write', 'ajax' => true, @@ -907,7 +903,6 @@ $functions = array( ), 'core_grades_grader_gradingpanel_point_fetch' => [ 'classname' => 'core_grades\\grades\\grader\\gradingpanel\\point\\external\\fetch', - 'methodname' => 'execute', 'description' => 'Fetch the data required to display the grader grading panel for simple grading, ' . 'creating the grade item if required', 'type' => 'write', @@ -916,7 +911,6 @@ $functions = array( ], 'core_grades_grader_gradingpanel_point_store' => [ 'classname' => 'core_grades\\grades\\grader\\gradingpanel\\point\\external\\store', - 'methodname' => 'execute', 'description' => 'Store the data required to display the grader grading panel for simple grading', 'type' => 'write', 'ajax' => true, @@ -924,7 +918,6 @@ $functions = array( ], 'core_grades_grader_gradingpanel_scale_fetch' => [ 'classname' => 'core_grades\\grades\\grader\\gradingpanel\\scale\\external\\fetch', - 'methodname' => 'execute', 'description' => 'Fetch the data required to display the grader grading panel for scale-based grading, ' . 'creating the grade item if required', 'type' => 'write', @@ -933,7 +926,6 @@ $functions = array( ], 'core_grades_grader_gradingpanel_scale_store' => [ 'classname' => 'core_grades\\grades\\grader\\gradingpanel\\scale\\external\\store', - 'methodname' => 'execute', 'description' => 'Store the data required to display the grader grading panel for scale-based grading', 'type' => 'write', 'ajax' => true, @@ -1557,7 +1549,6 @@ $functions = array( ), 'core_output_load_fontawesome_icon_system_map' => array( 'classname' => 'core\external\output\icon_system\load_fontawesome_map', - 'methodname' => 'execute', 'description' => 'Load the mapping of moodle pix names to fontawesome icon names', 'type' => 'read', 'loginrequired' => false, @@ -1748,7 +1739,6 @@ $functions = array( ), 'core_user_search_identity' => array( 'classname' => '\core_user\external\search_identity', - 'methodname' => 'execute', 'description' => 'Return list of users identities matching the given criteria in their name or other identity fields.', 'type' => 'read', 'capabilities' => 'moodle/user:viewalldetails', @@ -2634,7 +2624,6 @@ $functions = array( 'core_block_fetch_addable_blocks' => array( 'classname' => 'core_block\external\fetch_addable_blocks', - 'methodname' => 'execute', 'description' => 'Returns all addable blocks in a given page.', 'type' => 'read', 'capabilities' => 'moodle/site:manageblocks', @@ -2710,7 +2699,6 @@ $functions = array( ], 'core_table_get_dynamic_table_content' => [ 'classname' => 'core_table\external\dynamic\get', - 'methodname' => 'execute', 'description' => 'Get the dynamic table content raw html', 'type' => 'read', 'ajax' => true, @@ -2718,7 +2706,6 @@ $functions = array( ], 'core_xapi_statement_post' => [ 'classname' => 'core_xapi\external\post_statement', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Post an xAPI statement.', 'type' => 'write', @@ -2728,7 +2715,6 @@ $functions = array( ], 'core_contentbank_delete_content' => [ 'classname' => 'core_contentbank\external\delete_content', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Delete a content from the content bank.', 'type' => 'write', @@ -2737,7 +2723,6 @@ $functions = array( ], 'core_contentbank_rename_content' => [ 'classname' => 'core_contentbank\external\rename_content', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Rename a content in the content bank.', 'type' => 'write', @@ -2746,7 +2731,6 @@ $functions = array( ], 'core_contentbank_set_content_visibility' => [ 'classname' => 'core_contentbank\external\set_content_visibility', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Set the visibility of a content in the content bank.', 'type' => 'write', @@ -2755,7 +2739,6 @@ $functions = array( ], 'core_create_userfeedback_action_record' => [ 'classname' => 'core\external\record_userfeedback_action', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Record the action that the user takes in the user feedback notification for future use.', 'type' => 'write', @@ -2764,7 +2747,6 @@ $functions = array( ], 'core_payment_get_available_gateways' => [ 'classname' => 'core_payment\external\get_available_gateways', - 'methodname' => 'execute', 'description' => 'Get the list of payment gateways that support the given component/area', 'type' => 'read', 'ajax' => true, diff --git a/media/player/videojs/db/services.php b/media/player/videojs/db/services.php index e96d97f2a4d..56339a4d8fd 100644 --- a/media/player/videojs/db/services.php +++ b/media/player/videojs/db/services.php @@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die; $functions = [ 'media_videojs_get_language' => [ 'classname' => 'media_videojs\external\get_language', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'get language.', 'type' => 'read', diff --git a/mod/glossary/db/services.php b/mod/glossary/db/services.php index 1584e012a48..2614b9143c5 100644 --- a/mod/glossary/db/services.php +++ b/mod/glossary/db/services.php @@ -164,7 +164,6 @@ $functions = array( 'mod_glossary_delete_entry' => [ 'classname' => 'mod_glossary\external\delete_entry', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Delete the given entry from the glossary.', 'type' => 'write', @@ -173,7 +172,6 @@ $functions = array( 'mod_glossary_update_entry' => [ 'classname' => 'mod_glossary\external\update_entry', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Updates the given glossary entry.', 'type' => 'write', @@ -182,7 +180,6 @@ $functions = array( 'mod_glossary_prepare_entry_for_edition' => [ 'classname' => 'mod_glossary\external\prepare_entry', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Prepares the given entry for edition returning draft item areas and file areas information.', 'type' => 'read', diff --git a/mod/h5pactivity/db/services.php b/mod/h5pactivity/db/services.php index 46d45b1bdea..4da90f53536 100644 --- a/mod/h5pactivity/db/services.php +++ b/mod/h5pactivity/db/services.php @@ -28,7 +28,6 @@ defined('MOODLE_INTERNAL') || die; $functions = [ 'mod_h5pactivity_get_h5pactivity_access_information' => [ 'classname' => 'mod_h5pactivity\external\get_h5pactivity_access_information', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Return access information for a given h5p activity.', 'type' => 'read', @@ -37,7 +36,6 @@ $functions = [ ], 'mod_h5pactivity_view_h5pactivity' => [ 'classname' => 'mod_h5pactivity\external\view_h5pactivity', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Trigger the course module viewed event and update the module completion status.', 'type' => 'write', @@ -46,7 +44,6 @@ $functions = [ ], 'mod_h5pactivity_get_attempts' => [ 'classname' => 'mod_h5pactivity\external\get_attempts', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Return the information needed to list a user attempts.', 'type' => 'read', @@ -55,7 +52,6 @@ $functions = [ ], 'mod_h5pactivity_get_results' => [ 'classname' => 'mod_h5pactivity\external\get_results', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Return the information needed to list a user attempt results.', 'type' => 'read', @@ -64,7 +60,6 @@ $functions = [ ], 'mod_h5pactivity_get_h5pactivities_by_courses' => [ 'classname' => 'mod_h5pactivity\external\get_h5pactivities_by_courses', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Returns a list of h5p activities in a list of provided courses, if no list is provided all h5p activities @@ -75,7 +70,6 @@ $functions = [ ], 'mod_h5pactivity_log_report_viewed' => [ 'classname' => 'mod_h5pactivity\external\log_report_viewed', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Log that the h5pactivity was viewed.', 'type' => 'write', @@ -83,7 +77,6 @@ $functions = [ ], 'mod_h5pactivity_get_user_attempts' => [ 'classname' => 'mod_h5pactivity\external\get_user_attempts', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Return the information needed to list all enrolled user attempts.', 'type' => 'read', diff --git a/payment/gateway/paypal/db/services.php b/payment/gateway/paypal/db/services.php index f1986c6ba44..0d2a3abddb8 100644 --- a/payment/gateway/paypal/db/services.php +++ b/payment/gateway/paypal/db/services.php @@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die(); $functions = [ 'paygw_paypal_get_config_for_js' => [ 'classname' => 'paygw_paypal\external\get_config_for_js', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Returns the configuration settings to be used in js', 'type' => 'read', @@ -35,7 +34,6 @@ $functions = [ ], 'paygw_paypal_create_transaction_complete' => [ 'classname' => 'paygw_paypal\external\transaction_complete', - 'methodname' => 'execute', 'classpath' => '', 'description' => 'Takes care of what needs to be done when a PayPal transaction comes back as complete.', 'type' => 'write',