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

Default name for the method implementing the external function

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Install the attached tool_demo.zip plugin which provides a simple external function without specifying its methodname in db/services.php
      2. TEST Run the demo plugin's tests and make sure they pass (i.e. external function was correctly registered using default methodname).

        vendor/bin/phpunit -c admin/tool/demo/
        

      3. Modify the file admin/tool/demo/db/services.php and use some explicitly declared methodname, e.g.:

            'tool_demo_get_current_time' => [
                'classname' => '\tool_demo\external\get_current_time',
                'methodname' => 'run',
                // ...
        

      4. Modify the file demo/classes/external/get_current_time.php and change the name of all three methods accordingly. In this example, we would replace 'execute' prefix with 'run'.
      5. Increase the version number in the tool_demo plugin's version.php and upgrade the site.
      6. TEST Run the demo plugin's tests again and make sure they still pass (i.e. developers can still provide explicit custom name).
      7. Modify the file admin/tool/demo/db/services.php and remove the methodname property that you added.
      8. Modify the file demo/classes/external/get_current_time.php and revert the method names back to using the "execute" prefix.
      9. Increase the version number in the tool_demo plugin's version.php and upgrade the site.
      10. TEST Run the demo plugin's tests again and make sure they still pass (i.e. the methodname can be removed from the file if the class uses default names).
      Show
      Install the attached tool_demo.zip plugin which provides a simple external function without specifying its methodname in db/services.php TEST Run the demo plugin's tests and make sure they pass (i.e. external function was correctly registered using default methodname). vendor/bin/phpunit -c admin/tool/demo/ Modify the file admin/tool/demo/db/services.php and use some explicitly declared methodname, e.g.: 'tool_demo_get_current_time' => [ 'classname' => '\tool_demo\external\get_current_time', 'methodname' => 'run', // ... Modify the file demo/classes/external/get_current_time.php and change the name of all three methods accordingly. In this example, we would replace 'execute' prefix with 'run'. Increase the version number in the tool_demo plugin's version.php and upgrade the site. TEST Run the demo plugin's tests again and make sure they still pass (i.e. developers can still provide explicit custom name). Modify the file admin/tool/demo/db/services.php and remove the methodname property that you added. Modify the file demo/classes/external/get_current_time.php and revert the method names back to using the "execute" prefix. Increase the version number in the tool_demo plugin's version.php and upgrade the site. TEST Run the demo plugin's tests again and make sure they still pass (i.e. the methodname can be removed from the file if the class uses default names).
    • Affected Branches:
      MOODLE_311_STABLE
    • Fixed Branches:
      MOODLE_311_STABLE
    • Pull from Repository:
    • Pull 3.11 Branch:
      MDL-71169-311-execute
    • Pull Master Branch:
      MDL-71169-master-execute

      Description

      As a follow-up of MDLSITE-6096, let's make execute the default name of the method that implements the external function.

      It has been promoted and recommended as a de-facto standard for all new external functions. Supporting it as a default name will help to make it commonly adopted pattern and it can eventually lead to making it a requested standard.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mudrd8mz David Mudrák (@mudrd8mz)
              Reporter:
              mudrd8mz David Mudrák (@mudrd8mz)
              Peer reviewer:
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Integrator:
              Andrew Lyons Andrew Lyons
              Tester:
              Dongsheng Cai Dongsheng Cai
              Participants:
              Component watchers:
              Adrian Greeve, Andrew Lyons, Eloy Lafuente (stronk7), Juan Leyva, Jun Pataleta, Sander Bangma, Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                17/May/21

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 30 minutes
                  3h 30m