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

JavaScript broken after clearing JS cache with an empty AMD module

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.1.4, 4.1.5, 4.2.2, 4.3
    • JavaScript
    • MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
    • MDL-79465_master
    • Hide

      Just Reloading the page should fix this until the Moodle JS cache is cleared the next time.

      Removing the empty AMD module files would also fix this.

      Show
      Just Reloading the page should fix this until the Moodle JS cache is cleared the next time. Removing the empty AMD module files would also fix this.
    • Hide

      With output buffering

      1. Install mod_verbalfeedback
      2. Make sure JavaScript caching is enabled (admin setting "cachejs")
      3. Make sure PHP output_buffering is enabled in php.ini

        output_buffering = 4096
        

      4. Clear JS cache through CLI:

        php admin/cli/purge_caches.php --js
        

      5. Open any page
        => JavaScript works

      Without output buffering

      1. Install mod_verbalfeedback
      2. Make sure JavaScript caching is enabled (admin setting "cachejs")
      3. Make sure PHP output_buffering is disabled in php.ini

        output_buffering = Off
        

      4. Clear JS cache through CLI:

        php admin/cli/purge_caches.php --js
        

      5. Open browser's developer tools
      6. Go to network tab
      7. Filter by "first.js"
      8. Open any page
        => Request to load "first.js" contains the correct response headers
      Show
      With output buffering Install mod_verbalfeedback Make sure JavaScript caching is enabled (admin setting "cachejs") Make sure PHP output_buffering is enabled in php.ini output_buffering = 4096 Clear JS cache through CLI: php admin /cli/purge_caches .php --js Open any page => JavaScript works Without output buffering Install mod_verbalfeedback Make sure JavaScript caching is enabled (admin setting "cachejs") Make sure PHP output_buffering is disabled in php.ini output_buffering = Off Clear JS cache through CLI: php admin /cli/purge_caches .php --js Open browser's developer tools Go to network tab Filter by "first.js" Open any page => Request to load "first.js" contains the correct response headers

      Since MDL-78157 we've been experiencing this problem. When you have a plugin installed that contains an empty AMD module and Moodle's JavaScript Cache gets cleared (e.g. when performing any upgrade) the first time you load a page afterwards the JavaScript doesn't work. MDL-78379 hasn't fixed it in our case.

      One plugin that causes this for us is mod_verbalfeedback where report.js is empty.

      To reproduce:

      1. Install mod_verbalfeedback
      2. Make sure JavaScript caching is enabled (admin setting "cachejs")
      3. Make sure PHP output_buffering is enabled in php.ini

        output_buffering = 4096
        

      4. Clear JS cache through CLI:

        php admin/cli/purge_caches.php --js
        

      5. Open any page
        => You get an error in the JavaScript console:
        => JavaScript doesn't work

      P.S.: If you disable PHP output buffering, this problem doesn't occur. But the request for first.js returns the wrong headers.

            tschroeder Tim Schroeder
            tschroeder Tim Schroeder
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

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