A Label which consists of HTML-tag strings only (eg. <hr/>) isn't displayed on a course topic field.
Notice: Undefined index: 847 in C:\xampplite\htdocs\mech\moodle\course\lib.php on line 1344
Notice: Trying to get property of non-object in C:\xampplite\htdocs\mech\moodle\course\lib.php on line 1344
The cause of this problem is that the name field of the label in mdl_label is blank.
In mod/label/lib.php, HTML tags of the label content is eliminated by strip_tags() to generate a name of the label.
If the content of the label consisted of HTML-tag only, the name of the label would be blank.
I propose a patch as follows.
------------------------
function label_add_instance($label) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
/// will create a new instance and return the id number
/// of the new instance.
$textlib = textlib_get_instance();
$label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true)));
// (Shirai): Add from here
if (strlen($label->name) == 0) $label->name = 'noname';
// (Shirai): Add to here
if ($textlib->strlen($label->name) > LABEL_MAX_NAME_LENGTH)
$label->timemodified = time();
return insert_record("label", $label);
}
function label_update_instance($label) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
/// will update an existing instance with new data.
$textlib = textlib_get_instance();
$label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true)));
// (Shirai): Add from here
if (strlen($label->name) == 0) $label->name = 'noname';
// (Shirai): Add to here
if ($textlib->strlen($label->name) > LABEL_MAX_NAME_LENGTH) { $label->name = $textlib->substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."..."; }
$label->timemodified = time();
$label->id = $label->instance;
return update_record("label", $label);
}
- duplicates
-
MDL-15304 Labels with nothing but tags in them don't work
-
- Closed
-