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

Deprecate file_encode_url function

    • MOODLE_22_STABLE
    • MDL-31071_deprecate-file_encode_url-function
    • Hide

      Automated tests

      The changes in there areas are covered by CI (Unit and/or Behat):

      • blocks/private_files
      • blog
      • question
      • mod/forum
      • mod/glossary

      Testing Webservice

      This tests the changes in the following areas:

      • mod/folder
      • mod/page
      • mod/file

      For testing this issue:

      1. You need to have access to a console on your system
      2. Curl, wget and jq should be installed on your system
      3. Have basic understanding of JSON

      Prerequisite

      1. Login as admin
      2. Create a course and note its courseid from the URL. Use it to replace the string <COURSE_ID> in the web service calls below.
      3. Add the Folder activity to the course and add a file to it
      4. Add the Page activity to the course and add a file to it
      5. Add the File activity to the course and add a file to it
      6. Go to Site administration > Advanced features and set Enable web services to Yes
      7. Go to Site administration > Server > Web services > Manage protocols and enable REST protocol
      8. Go to Site administration > Server > Web services > External services and Add an External service
        Set the following fields:
        • Name: Test Service
        • Enabled: Yes
        • Can download files: Yes
      9. Add functions to the service "Test Service" and choose the function with the name core_course_get_contents
      10. Go to Site administration > Server > Web services > Manage tokens
      11. Click "Create a token"
      12. Create a token for the admin user, select the service "Test Service"
      13. Save the token and use it to replace the string <WEBSERVICE_TOKEN> in the web service calls below.

      Testing mod/folder

      1. Run the following command in your console:

        moodle_site=<YOUR_MOODLE_SITE>
        ws_token=<WEBSERVICE_TOKEN>
        cid=<COURSE_ID>
        curl -s "http://$moodle_site/webservice/rest/server.php?moodlewsrestformat=json" \
            --data "wstoken=$ws_token&wsfunction=core_course_get_contents&courseid=$cid&options[0][name]=modname&options[0][value]=folder" \
            | jq '.[].modules[].contents[].fileurl' -r \
            | sed "s/\$/\&token=$ws_token/" \
            | wget --quiet --content-disposition --input-file -

      2. Verify it downloads the file you added to the Folder activity
         

        Testing mod/page

      1. Run the following command in your console:

        moodle_site=<YOUR_MOODLE_SITE>
        ws_token=<WEBSERVICE_TOKEN>
        cid=<COURSE_ID>
        curl -s "http://$moodle_site/webservice/rest/server.php?moodlewsrestformat=json" \
            --data "wstoken=$ws_token&wsfunction=core_course_get_contents&courseid=$cid&options[0][name]=modname&options[0][value]=page" \
            | jq '.[].modules[].contents[].fileurl' -r \
            | sed "s/\$/\&token=$ws_token/" \
            | wget --quiet --content-disposition --input-file -

      2. Verify it downloads the file you added to the Page activity
      3. Verfiy it downlaods an additional index.html
         

        Testing mod/file

      1. Run the following command in your console:

        moodle_site=<YOUR_MOODLE_SITE>
        ws_token=<WEBSERVICE_TOKEN>
        cid=<COURSE_ID>
        curl -s "http://$moodle_site/webservice/rest/server.php?moodlewsrestformat=json" \
            --data "wstoken=$ws_token&wsfunction=core_course_get_contents&courseid=$cid&options[0][name]=modname&options[0][value]=resource" \
            | jq '.[].modules[].contents[].fileurl' -r \
            | sed "s/\$/\&token=$ws_token/" \
            | wget --quiet --content-disposition --input-file -

      2. Verify it downloads the file you added to the FIle activity
      Show
      Automated tests The changes in there areas are covered by CI (Unit and/or Behat): blocks/private_files blog question mod/forum mod/glossary Testing Webservice This tests the changes in the following areas: mod/folder mod/page mod/file For testing this issue: You need to have access to a console on your system Curl, wget and jq should be installed on your system Have basic understanding of JSON Prerequisite Login as admin Create a course and note its courseid from the URL. Use it to replace the string <COURSE_ID> in the web service calls below. Add the Folder activity to the course and add a file to it Add the Page activity to the course and add a file to it Add the File activity to the course and add a file to it Go to Site administration > Advanced features and set Enable web services to Yes Go to Site administration > Server > Web services > Manage protocols and enable REST protocol Go to Site administration > Server > Web services > External services and Add an External service Set the following fields: Name: Test Service Enabled: Yes Can download files: Yes Add functions to the service " Test Service " and choose the function with the name core_course_get_contents Go to Site administration > Server > Web services > Manage tokens Click " Create a token" Create a token for the admin user, select the service " Test Service " Save the token and use it to replace the string <WEBSERVICE_TOKEN> in the web service calls below. Testing mod/folder Run the following command in your console: moodle_site=<YOUR_MOODLE_SITE> ws_token=<WEBSERVICE_TOKEN> cid=<COURSE_ID> curl -s "http://$moodle_site/webservice/rest/server.php?moodlewsrestformat=json" \ --data "wstoken=$ws_token&wsfunction=core_course_get_contents&courseid=$cid&options[0][name]=modname&options[0][value]=folder" \ | jq '.[].modules[].contents[].fileurl' -r \ | sed "s/\$/\&token=$ws_token/" \ | wget --quiet --content-disposition --input-file - Verify it downloads the file you added to the Folder activity   Testing mod/page Run the following command in your console: moodle_site=<YOUR_MOODLE_SITE> ws_token=<WEBSERVICE_TOKEN> cid=<COURSE_ID> curl -s "http://$moodle_site/webservice/rest/server.php?moodlewsrestformat=json" \ --data "wstoken=$ws_token&wsfunction=core_course_get_contents&courseid=$cid&options[0][name]=modname&options[0][value]=page" \ | jq '.[].modules[].contents[].fileurl' -r \ | sed "s/\$/\&token=$ws_token/" \ | wget --quiet --content-disposition --input-file - Verify it downloads the file you added to the Page activity Verfiy it downlaods an additional index.html   Testing mod/file Run the following command in your console: moodle_site=<YOUR_MOODLE_SITE> ws_token=<WEBSERVICE_TOKEN> cid=<COURSE_ID> curl -s "http://$moodle_site/webservice/rest/server.php?moodlewsrestformat=json" \ --data "wstoken=$ws_token&wsfunction=core_course_get_contents&courseid=$cid&options[0][name]=modname&options[0][value]=resource" \ | jq '.[].modules[].contents[].fileurl' -r \ | sed "s/\$/\&token=$ws_token/" \ | wget --quiet --content-disposition --input-file - Verify it downloads the file you added to the FIle activity
    • Hide

      Code verified against automated checks.

      Checked MDL-31071 using repository: https://github.com/ziegenberg/moodle

      More information about this report

      Built on: Mon Apr 14 08:23:04 UTC 2025

      Show
      Code verified against automated checks. Checked MDL-31071 using repository: https://github.com/ziegenberg/moodle main (0 errors / 0 warnings) [branch: MDL-31071_deprecate-file_encode_url-function | CI Job ] More information about this report Built on: Mon Apr 14 08:23:04 UTC 2025
    • Show
      Launching automatic jobs for branch MDL-31071 _deprecate-file_encode_url-function https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/18765/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64282/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64283/ Behat (Firefox - boost) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64284/ Behat (Firefox - classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64285/ App tests (stable app version) Built on: Mon Mar 24 12:25:44 UTC 2025

      I created this issue for the todo item during working on the MDL-30971 docblock improvement project.

      we should use moodle_url class to replace it.

            Daniel Ziegenberg Daniel Ziegenberg
            dongsheng Dongsheng Cai
            Meirza Meirza
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 12 minutes
                12m

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