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

$CFG->svgicons set to false can cause images to fail

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.8.8, 2.9
    • Fix Version/s: 2.8.9, 2.9.3
    • Component/s: Themes
    • Labels:
    • Testing Instructions:
      Hide

      Owing to the nature of this failure, I would recommend testing this issue both with, and without the patch applied.

      1. Ensure that you are not in developer mode, and that you have not set the themerev in a hard-coded fashion
      2. set $CFG->svgicons = false; in your config.php
      3. Open the front page
        1. Confirm that all icons are shown
      4. Purge caches
      5. Refresh the page
        1. Confirm that all icons are shown
      6. Choose a single icon from the front page - e.g. the icon for site news (http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon for me)
      7. Open a terminal window:
      8. Change directory into your moodledata directory
      9. Change directory into localcache/theme/<themerevision>/clean/pix
      10. Ensure that there is no existing cache for this icon

        rm -rf forum
        

      11. Now try to fetch the non-SVG copy of the image

        curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon
        

        1. Confirm that the content returned was a load of binary data
        2. Confirm that both the SVG and PNG versions of the image were stored in the cache:

          ls -Al forum
          

      12. Make a note of the file mtimes in the above output
      13. Wait for 1 minute
      14. Repeat the curl
        1. Confirm that the file mtimes have not changed
      15. Remove the PNG version from the cache
      16. Repeat the curl
        1. Confirm that the content returned was a load of binary data
        2. Confirm that both the SVG and PNG versions of the image were stored in the cache:
        3. Confirm that the date on the SVG version was not updated
      17. Remove the directory again:

        rm -rf forum
        

      18. Modify your curl to fetch the SVG version only - when using slasharguments, remove _s from the URL, or remove &svg=0 from the URL if not using slasharguments
      19. Run your new modified curl:

        curl http://loganberry.local/sm/theme/image.php/clean/forum/1444868761/icon
        

        1. Confirm that the content returned was not a load of binary data, but instead an XML-structure of SVG goodness
        2. Confirm that _only) the SVG version of the image was stored in the cache:

          ls -Al forum
          

      20. Make a note of the file mtime in the above output
      21. Wait for 1 minute
      22. Repeat the curl
        1. Confirm that the file mtime has not changed
      23. Request the original Curl:
      24. curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon
        

        1. Confirm that the content returned was a load of binary data
        2. Confirm that both the SVG and PNG versions of the image were stored in the cache:

          ls -Al forum
          

        3. Confirm that the timestamp for the SVG had not changed
      25. Remove the directory again:

        rm -rf forum
        

      26. In your moodle dirroot, run:

        rm mod/forum/pix/icon.png
        

      27. Attempt to curl the SVG version again:

        curl http://loganberry.local/sm/theme/image.php/clean/forum/1444868761/icon
        

        1. Confirm that the content returned was not a load of binary data, but instead an XML-structure of SVG goodness
        2. Confirm that only the SVG version of the image was stored in the cache:

          ls -Al forum
          

      28. Request the non-SVG version again:

        curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon
        

        1. Confirm that you got a "Image not found" type message
        2. Confirm that there was no .error file in the cache directory
      29. Attempt to curl the SVG version again:

        curl http://loganberry.local/sm/theme/image.php/clean/forum/1444868761/icon
        

        1. Confirm that the content returned was not a load of binary data, but instead an XML-structure of SVG goodness
        2. Confirm that the mtime on the cache file did not change
      30. Remove the directory again:

        rm -rf forum
        

      31. Back in your dirroot, restore the .png version of the icon and remove the .svg version:

        git checkout mod/forum/pix/icon.png
        rm mod/forum/pix/icon.svg
        

        Run your curl for the SVG copy again:

        curl http://loganberry.local/sm/theme/image.php/clean/forum/1444868761/icon
        

        1. Confirm that the content returned was a load of binary data
        2. Confirm that only the PNG version of the image was stored in the cache:

          ls -Al forum
          

          # Wait 1 minute

      32. Run it again
        1. Confirm that the content returned was a load of binary data
        2. Confirm that the mtime on the cache file did not change
      33. Request the non-SVG version again:

        curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon
        

        1. Confirm that the content returned was a load of binary data
        2. Confirm that the mtime on the cache file did not change
      34. Modify the filename in the curl to request a file which does not exist at all:
      35. curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/notfound
        

        1. Confirm that you got a "Image not found" type message
        2. Confirm that there is an .error file in the cache directory
      Show
      Owing to the nature of this failure, I would recommend testing this issue both with, and without the patch applied. Ensure that you are not in developer mode, and that you have not set the themerev in a hard-coded fashion set $CFG->svgicons = false; in your config.php Open the front page Confirm that all icons are shown Purge caches Refresh the page Confirm that all icons are shown Choose a single icon from the front page - e.g. the icon for site news ( http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon for me) Open a terminal window: Change directory into your moodledata directory Change directory into localcache/theme/<themerevision>/clean/pix Ensure that there is no existing cache for this icon rm -rf forum Now try to fetch the non-SVG copy of the image curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon Confirm that the content returned was a load of binary data Confirm that both the SVG and PNG versions of the image were stored in the cache : ls -Al forum Make a note of the file mtimes in the above output Wait for 1 minute Repeat the curl Confirm that the file mtimes have not changed Remove the PNG version from the cache Repeat the curl Confirm that the content returned was a load of binary data Confirm that both the SVG and PNG versions of the image were stored in the cache : Confirm that the date on the SVG version was not updated Remove the directory again: rm -rf forum Modify your curl to fetch the SVG version only - when using slasharguments, remove _s from the URL, or remove &svg=0 from the URL if not using slasharguments Run your new modified curl: curl http://loganberry.local/sm/theme/image.php/clean/forum/1444868761/icon Confirm that the content returned was not a load of binary data, but instead an XML-structure of SVG goodness Confirm that _only) the SVG version of the image was stored in the cache : ls -Al forum Make a note of the file mtime in the above output Wait for 1 minute Repeat the curl Confirm that the file mtime has not changed Request the original Curl: curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon Confirm that the content returned was a load of binary data Confirm that both the SVG and PNG versions of the image were stored in the cache : ls -Al forum Confirm that the timestamp for the SVG had not changed Remove the directory again: rm -rf forum In your moodle dirroot, run: rm mod/forum/pix/icon.png Attempt to curl the SVG version again: curl http://loganberry.local/sm/theme/image.php/clean/forum/1444868761/icon Confirm that the content returned was not a load of binary data, but instead an XML-structure of SVG goodness Confirm that only the SVG version of the image was stored in the cache : ls -Al forum Request the non-SVG version again: curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon Confirm that you got a "Image not found" type message Confirm that there was no .error file in the cache directory Attempt to curl the SVG version again: curl http://loganberry.local/sm/theme/image.php/clean/forum/1444868761/icon Confirm that the content returned was not a load of binary data, but instead an XML-structure of SVG goodness Confirm that the mtime on the cache file did not change Remove the directory again: rm -rf forum Back in your dirroot, restore the .png version of the icon and remove the .svg version: git checkout mod/forum/pix/icon.png rm mod/forum/pix/icon.svg Run your curl for the SVG copy again: curl http://loganberry.local/sm/theme/image.php/clean/forum/1444868761/icon Confirm that the content returned was a load of binary data Confirm that only the PNG version of the image was stored in the cache : ls -Al forum # Wait 1 minute Run it again Confirm that the content returned was a load of binary data Confirm that the mtime on the cache file did not change Request the non-SVG version again: curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/icon Confirm that the content returned was a load of binary data Confirm that the mtime on the cache file did not change Modify the filename in the curl to request a file which does not exist at all: curl http://loganberry.local/sm/theme/image.php/_s/clean/forum/1444868761/notfound Confirm that you got a "Image not found" type message Confirm that there is an .error file in the cache directory
    • Affected Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull Master Branch:
      MDL-51759-master-2

      Description

      In some circumstance when $CFG->svgicons is set to false images will not load.

      This turned out to be caused by a confusing situation in theme/image.php:

      1. where the image is not already cached;
      2. and the browser did not request svgicons (e.g. svgicons = false);
      3. then find the first imagefile matching the details, prioritising svgicons
      4. and cache it

      The rationale is that the first time a file is fetched, we must cache all versions of it.
      However, if you are not fetching svgicons on that first request, then we wouldn't ordinarily be caching that svg icon, so we must do extra work to cache it.

      Unfortunately, that additional cache behaviour was broken, and although it was fetching the first version of the icon, it was not trying to return non-svg icons when there is also an SVG.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Nov/15