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

Failed to pre-fetch template

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 3.4.6, 3.5.3, 3.6
    • Fix Version/s: None
    • Component/s: HTML and CSS
    • Labels:
    • Testing Instructions:
      Hide

      1. Login as an admin and go to site home.

      2. Use boost theme

      3. Copy attached modal.mustache file over theme/boost/templates/core/modal.mustache

      4. turn editing on.

      5. Reload the page 10 times

      6. Verify you do not see 'Failed to pre-fetch the template'

      7. Go to a course home page

      8. Delete an activity. 

      9. Verify you see a modal dialog to confirm that you want to delete the activity.

      Show
      1. Login as an admin and go to site home. 2. Use boost theme 3. Copy attached modal.mustache file over theme/boost/templates/core/modal.mustache 4. turn editing on. 5. Reload the page 10 times 6. Verify you do not see 'Failed to pre-fetch the template' 7. Go to a course home page 8. Delete an activity.  9. Verify you see a modal dialog to confirm that you want to delete the activity.
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
    • Pull from Repository:
    • Pull 3.5 Branch:
    • Pull Master Branch:
      MDL-64164-master

      Description

      This was partially fixed by MDL-63667 - but I am still seeing it randomly when looking at the course page.

       

      History of these issues.

      When mustache was added, it was supported for php and javascript. The javascript version uses http://github.com/janl/mustache.js. When the renderer encounters a tag that requires another template, it calls a function which has to return the HTML for the template. It does not handle getting a promise - the function must return the HTML immediately. To do this we added a "pre-render" step which parses the HTML, finds all tags that include another template, generates a promise for each one to load the template via AJAX, waits for all the promises to resolve and then renders the template (and once the template is loaded it recursively does the same thing).

      The first version did not handle recursive templates rendered in javascript, it would hang for ever waiting for it's chain of promises to return.

      Process 1: wait for A raw -> wait for B raw -> wait for C raw -> wait for A raw (loop continues forever).

      We added a fix for this, but the fix is not perfect and when the same template is rendered twice in javascript at the same time and the template includes another template, the first call to render will wait correctly, but the second one will not wait for all the included templates to be ready.

      Process 1: wait for A raw -> wait for B raw -> render A
      Process 2: wait for A raw -> render A (did not wait for B!)

      A real fix for this is in MDL-64181

       The workaround on this issue is to inject a call to get the B (core/modal) template before trying to render A.

      Process 1: wait for B raw -> wait for A raw -> wait for B raw but its already there -> render A

      Process 2: wait for B raw -> wait for A raw -> wait for B raw but its already there -> render A

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                damyon Damyon Wiese
                Reporter:
                damyon Damyon Wiese
                Peer reviewer:
                Andrew Nicols
                Participants:
                Component watchers:
                Amy Groshek, David Scotson, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: