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

Label caches embedded content incorrectly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • 3.11.7, 4.0.1
    • Caching, Filters
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • mdl75042-master
    • Hide
      1. Create a test course with 1 participant - note down the URL
      2. Create a label activity in this course
      3. In the label activity editor, drop down the toolbar to show the HTML editor.
      4. Enable HTML editing
      5. Enter the following HTML, replacing the [COURSE URL] with the URL of the course created in step 1:
        1. <p dir="ltr" style="text-align: left;"><br>
              <iframe src="[COURSE URL]" style="width: 100%"></iframe>
          </p>

      1. Save and return to course
      2. Confirm the label activity does show the embedded course page when viewed from the main course page
      3. Open a new browser
      4. Log in as the ADMIN user
      5. Navigate to the participant profile page
      6. Click 'log in as' user
      7. Navigate to the course page
      8. Confirm the label activity does not show the embedded course page when viewed from the main course page
      9. Run the command to purge the caches:
        1. php admin/cli/purge_caches.php

      1. In the browser window logged in as the participant, refresh the page
      2. Confirm then label activity does not show the embedded course page when viewed from the main course page
      3. In the browser window logged in the admin user, refresh the page
      4. Confirm the label activity does show the embedded course page
      Show
      Create a test course with 1 participant - note down the URL Create a label activity in this course In the label activity editor, drop down the toolbar to show the HTML editor. Enable HTML editing Enter the following HTML, replacing the [COURSE URL] with the URL of the course created in step 1: <p dir= "ltr" style= "text-align: left;" ><br>     <iframe src= "[COURSE URL]" style= "width: 100%" ></iframe> </p> Save and return to course Confirm the label activity does show the embedded course page when viewed from the main course page Open a new browser Log in as the ADMIN user Navigate to the participant profile page Click 'log in as' user Navigate to the course page Confirm the label activity does not show the embedded course page when viewed from the main course page Run the command to purge the caches: php admin/cli/purge_caches.php In the browser window logged in as the participant, refresh the page Confirm then label activity does not show the embedded course page when viewed from the main course page In the browser window logged in the admin user, refresh the page Confirm the label activity does show the embedded course page

    Description

      We found an embedded H5P content is sometimes not shown in the label activity.
      Once the issue happens, we can fix the issue by saving label without any changes.
      I investigated the issue, and found there is a cache for label, and showing the cached label.

      This is not limited to H5P content, it applies to anything inside an iFrame inside the label HTML.

       
      Reproduction steps:

      1. Have a test course with 1 participant
      2. Create a Page activity with any content. Note down the URL of this page
      1. Create a label activity
      2. In the label text select the Arrow dropdown to show the extra editing tools then select HTML to edit the raw html

              5. Embed the page activity from step 2 in an iframe e.g.:
      <p dir="ltr" style="text-align: left;"><br>
          <iframe src="<URL FROM STEP 2>" style="width: 100%"></iframe>
      </p>
       
      6. In another tab / browser, 'Log in as' the participant in the course
      7. Because you are logged in, embedded iFrames are disabled
      8. Purge the caches php admin/cli/purge_caches.php
      9. Refresh the page in the 'Log in as' tab, the iFrame will not display (as intended)
      11. Switch to the normal tab, reload
      12. The iFrame will not show either, because it has been cached as not visible (this is a bug)
      13. Purge the caches again
      14. On normal tab, reload and the iFrame will now be displayed

      I have tested this same behaviour in other places such as Course section description, mod_assign intro and they do not exhibit this bug. It seems to only be in the moduleinfo, usually in an activity's intro html/text.

      This is because mod_label is calling format_module_intro which is calling format_text and since you are in 'log in as' mode, $CFG->forceclean is true so it cleans the HTML, then caches it. The HTML is cleaned later on anyway, so the likely fix is to disable forceclean pre-cache then clean it AFTER caching it.

       

      Attachments

        Issue Links

          Activity

            People

              matthewhilton Matthew Hilton
              tomotsuyuki Tomo Tsuyuki
              Tomo Tsuyuki Tomo Tsuyuki
              Andrew Lyons Andrew Lyons
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 2 hours, 30 minutes
                  1d 2h 30m

                  Clockify

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