Skip to content

Commit

Permalink
MDL-33681 course: cannot have a section called '0'.
Browse files Browse the repository at this point in the history
No reason to prevent this. It is just a matter of doing a proper test,
rather than the sloppy PHP !empty().
  • Loading branch information
timhunt committed Jun 12, 2012
1 parent f8dfdb5 commit bb410a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion course/format/topics/lib.php
Expand Up @@ -59,7 +59,7 @@ function callback_topics_definition() {

function callback_topics_get_section_name($course, $section) {
// We can't add a node without any text
if (!empty($section->name)) {
if ((string)$section->name !== '') {
return format_string($section->name, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
} else if ($section->section == 0) {
return get_string('section0name', 'format_topics');
Expand Down
2 changes: 1 addition & 1 deletion course/format/weeks/lib.php
Expand Up @@ -66,7 +66,7 @@ function callback_weeks_definition() {
*/
function callback_weeks_get_section_name($course, $section) {
// We can't add a node without text
if (!empty($section->name)) {
if ((string)$section->name !== '') {
// Return the name the user set.
return format_string($section->name, true, array('context' => context_course::instance($course->id)));
} else if ($section->section == 0) {
Expand Down

0 comments on commit bb410a1

Please sign in to comment.