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

HTML Block on category page doesn't show embedded images for not-logged-in users

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.1, 2.2.1
    • Fix Version/s: 2.2.6, 2.3.3
    • Component/s: Blocks
    • Labels:
    • Testing Instructions:
      Hide

      Test 1
      As Admin:

      1. Access the course category page (site admin > courses > add/edit courses > select a categories
      2. Add HTML block, embedded an image for the content and save it
      3. Copy the site url

      On different browser (to make testing easier)

      1. Make sure you are not login to the system
      2. Paste the site url
        Make sure you are able to see the embedded image within the HTML block.

      Test 2
      As Admin:

      1. Access the course category page (site admin > courses > add/edit courses
      2. Add HTML block, embedded an image for the content and save it
        Make sure you are able to see the embedded image within the HTML block.
      Show
      Test 1 As Admin: Access the course category page (site admin > courses > add/edit courses > select a categories Add HTML block, embedded an image for the content and save it Copy the site url On different browser (to make testing easier) Make sure you are not login to the system Paste the site url Make sure you are able to see the embedded image within the HTML block. Test 2 As Admin: Access the course category page (site admin > courses > add/edit courses Add HTML block, embedded an image for the content and save it Make sure you are able to see the embedded image within the HTML block.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull Master Branch:
      wip-mdl-29762

      Description

      Hints for solution:
      /pluginfile.php fetches context information from given context ID - line 55:
      list($context, $course, $cm) = get_context_info_array($contextid);
      Unfortunately, $course is null when viewing a block on a category page.

      Later, /pluginfile.php calls block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $args, $forcedownload) in /blocks/html/lib.php.
      There, login is required for the given course - line 32:
      require_course_login($course);
      Unfortunately, as $course is null, login requirement always fails for non-logged-in users and image isn't shown.

      A quick and dirty fix would be to replace line 32 in /blocks/html/lib.php

      require_course_login($course);

      with

      if ($course != null)
      require_course_login($course);

      But I'm quite sure that this would provoke some security issues so I would be grateful if you could provide a better fix

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    12/Nov/12