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

PAGE->require->js handles moodle_urls differently

XMLWordPrintable

    • MOODLE_311_STABLE
    • MOODLE_402_STABLE
    • m42_MDL-72461_Moodle_JS_Files_Should_Be_Always_Served_By_JS_Handler
    • Easy
    • Hide

      Testing is covered by specific new unit tests. A full run of the Moodle PHPUnit test suite should be required to exclude regressions - they should be DB independent.
      You can use the Moodle Docker Toolbox to execute them.

      Prepare the "local" test environment

      Code changes are DB invariant:

      # export MOODLE_DOCKER_WWWROOT=/path/to/moodle/branch
      # export MOODLE_DOCKER_DB=mysql
      # cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php
      # bin/moodle-docker-compose up -d
      # bin/moodle-docker-wait-for-db
      

      Launch the specific tests

      No error should be reported like in the run below:

      # bin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/init.php
      # bin/moodle-docker-compose exec webserver php vendor/bin/phpunit --filter weblib_test
      Moodle 4.2dev (Build: 20221128), a0038c48ee9ea313d00153a9269ba849914befbe
      Php: 7.4.32, mysqli: 5.7.40, OS: Linux 3.10.0-1160.80.1.el7.x86_64 x86_64
      PHPUnit 9.5.25 #StandWithUkraine
       
      ................................................................. 65 / 87 ( 74%)
      ......................                                            87 / 87 (100%)
       
      Time: 00:02.924, Memory: 304.00 MB
       
      OK (87 tests, 293 assertions)
      # bin/moodle-docker-compose exec webserver php vendor/bin/phpunit --filter outputrequirementslib_test
      Moodle 4.2dev (Build: 20221128), a0038c48ee9ea313d00153a9269ba849914befbe
      Php: 7.4.32, mysqli: 5.7.40, OS: Linux 3.10.0-1160.80.1.el7.x86_64 x86_64
      PHPUnit 9.5.25 #StandWithUkraine
       
      .................................                                 33 / 33 (100%)
       
      Time: 00:01.835, Memory: 302.00 MB
       
      OK (33 tests, 49 assertions)
      

      Dispose the test environment

      # bin/moodle-docker-compose down -v
      

      Show
      Testing is covered by specific new unit tests. A full run of the Moodle PHPUnit test suite should be required to exclude regressions - they should be DB independent. You can use the Moodle Docker Toolbox to execute them. Prepare the "local" test environment Code changes are DB invariant: # export MOODLE_DOCKER_WWWROOT=/path/to/moodle/branch # export MOODLE_DOCKER_DB=mysql # cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php # bin/moodle-docker-compose up -d # bin/moodle-docker-wait-for-db Launch the specific tests No error should be reported like in the run below: # bin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/init.php # bin/moodle-docker-compose exec webserver php vendor/bin/phpunit --filter weblib_test Moodle 4.2dev (Build: 20221128), a0038c48ee9ea313d00153a9269ba849914befbe Php: 7.4.32, mysqli: 5.7.40, OS: Linux 3.10.0-1160.80.1.el7.x86_64 x86_64 PHPUnit 9.5.25 #StandWithUkraine   ................................................................. 65 / 87 ( 74%) ...................... 87 / 87 (100%)   Time: 00:02.924, Memory: 304.00 MB   OK (87 tests, 293 assertions) # bin/moodle-docker-compose exec webserver php vendor/bin/phpunit --filter outputrequirementslib_test Moodle 4.2dev (Build: 20221128), a0038c48ee9ea313d00153a9269ba849914befbe Php: 7.4.32, mysqli: 5.7.40, OS: Linux 3.10.0-1160.80.1.el7.x86_64 x86_64 PHPUnit 9.5.25 #StandWithUkraine   ................................. 33 / 33 (100%)   Time: 00:01.835, Memory: 302.00 MB   OK (33 tests, 49 assertions) Dispose the test environment # bin/moodle-docker-compose down -v

      These should be treated identically but one not:

      $PAGE->requires->js(new moodle_url('/mod/test/vendor/js/example.js')); // Bad!

      $PAGE->requires->js('/mod/test/vendor/js/example.js'); // Good!

      The first one doesn't go through lib/javascript.php so doesn't get caching headers

            matteo Matteo Scaramuccia
            brendanheywood Brendan Heywood
            Brendan Heywood Brendan Heywood
            Andrew Lyons Andrew Lyons
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 5 minutes
                4h 5m

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