MDL-33681 course: cannot have a section called '0'.
authorTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 12 Jun 2012 16:45:40 +0000 (17:45 +0100)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 12 Jun 2012 16:45:40 +0000 (17:45 +0100)
No reason to prevent this. It is just a matter of doing a proper test,
rather than the sloppy PHP !empty().

course/format/topics/lib.php
course/format/weeks/lib.php

index e8632fc..3728ab2 100644 (file)
@@ -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');
index a1e1ea9..fe6fd6b 100644 (file)
@@ -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) {