Moodle

Label on startpage containing only an image <img ... /> does not display the image

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.9
  • Fix Version/s: None
  • Component/s: General
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE

Description

In Moodle version 1.9 + (Build: 20080509) a label on the startpage containing only an image <img ... /> does not display the image. When I add text then text and image are shown.

This behavior is new. Version 1.9 + (Build: 20080324) didn't have this issue.

Debug notices:
( ! ) Notice: Undefined index: 116 in course/lib.php on line 1344
Call Stack

  1. Time Memory Function Location
    1 0.0018 159192 {main}( ) ../index.php:0
    2 0.8704 19092708 print_section( ) ../index.php:175

    ( ! ) Notice: Trying to get property of non-object in course/lib.php on line 1344
    Call Stack
    # Time Memory Function Location
    1 0.0018 159192 {main}( ) ../index.php:0
    2 0.8704 19092708 print_section( ) ../index.php:175

Activity

Hide
Raül Fernández added a comment -

Today, in Moodle 1.9.1+ (Build: 20080521) version, the problem is not resolved.

Show
Raül Fernández added a comment - Today, in Moodle 1.9.1+ (Build: 20080521) version, the problem is not resolved.
Hide
Joan Queralt added a comment -

If you write a blank space before the label <img...>the problem seems to desapear. But this is not the solution, of course.

Show
Joan Queralt added a comment - If you write a blank space before the label <img...>the problem seems to desapear. But this is not the solution, of course.
Hide
Albert Gasset added a comment -

I think I've found the solution.

The name of a label is taken from its content, but striping HTML tags (mod/label/lib.php, line 15 and 31):

$label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true)));

The function "get_fast_modinfo" in course/lib.php skips resources with an empty name (line 1101):

foreach ($info as $mod) {
if (empty($mod->name)) { // something is wrong here continue; }

So labels with only tags (images for example) are skipped and then the function "print_section" (course/lib.php, line 1256) can't print them.

Deleting the check for empty names seems to work for me (in Moodle 1.8 there was no such check).

Show
Albert Gasset added a comment - I think I've found the solution. The name of a label is taken from its content, but striping HTML tags (mod/label/lib.php, line 15 and 31): $label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true))); The function "get_fast_modinfo" in course/lib.php skips resources with an empty name (line 1101): foreach ($info as $mod) { if (empty($mod->name)) { // something is wrong here continue; } So labels with only tags (images for example) are skipped and then the function "print_section" (course/lib.php, line 1256) can't print them. Deleting the check for empty names seems to work for me (in Moodle 1.8 there was no such check).
Hide
Raül Fernández added a comment -

Hi, this problem is solved yet in the 1.9.2+ version!

Show
Raül Fernández added a comment - Hi, this problem is solved yet in the 1.9.2+ version!

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated: