From 355e943c4b5b67f3398eaa9abb19d334808a45e9 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 12 Aug 2015 11:48:43 +0800 Subject: [PATCH] MDL-50892 mod: allow activity to have name '0' --- course/recent.php | 2 +- course/rest.php | 2 +- grade/grading/lib.php | 2 +- lib/classes/event/calendar_event_created.php | 2 +- lib/classes/event/calendar_event_deleted.php | 2 +- lib/classes/event/calendar_event_updated.php | 2 +- lib/grade/grade_item.php | 2 +- lib/modinfolib.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/course/recent.php b/course/recent.php index 72bb761bad06d..9738ac447bd55 100644 --- a/course/recent.php +++ b/course/recent.php @@ -212,7 +212,7 @@ echo $OUTPUT->spacer(array('height'=>30, 'br'=>true)); // should be done with CSS instead } echo $OUTPUT->box_start(); - if (!empty($activity->name)) { + if (strval($activity->name) !== '') { echo html_writer::tag('h2', $activity->name); } $inbox = true; diff --git a/course/rest.php b/course/rest.php index eed9a3da393ee..675f3671e961a 100644 --- a/course/rest.php +++ b/course/rest.php @@ -173,7 +173,7 @@ $module->name = clean_param($title, PARAM_CLEANHTML); } - if (!empty($module->name)) { + if (strval($module->name) !== '') { $DB->update_record($cm->modname, $module); $cm->name = $module->name; \core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger(); diff --git a/grade/grading/lib.php b/grade/grading/lib.php index 215d346bd93a2..46fd52a83c0e9 100644 --- a/grade/grading/lib.php +++ b/grade/grading/lib.php @@ -185,7 +185,7 @@ public function get_component_title() { } else if ($this->get_context()->contextlevel >= CONTEXT_COURSE) { list($context, $course, $cm) = get_context_info_array($this->get_context()->id); - if (!empty($cm->name)) { + if (strval($cm->name) !== '') { $title = $cm->name; } else { debugging('Gradable areas are currently supported at the course module level only', DEBUG_DEVELOPER); diff --git a/lib/classes/event/calendar_event_created.php b/lib/classes/event/calendar_event_created.php index 28c47a07e714e..98fa0f4c89568 100644 --- a/lib/classes/event/calendar_event_created.php +++ b/lib/classes/event/calendar_event_created.php @@ -104,7 +104,7 @@ protected function validate_data() { if (!isset($this->other['repeatid'])) { throw new \coding_exception('The \'repeatid\' value must be set in other.'); } - if (empty($this->other['name'])) { + if (!isset($this->other['name'])) { throw new \coding_exception('The \'name\' value must be set in other.'); } if (!isset($this->other['timestart'])) { diff --git a/lib/classes/event/calendar_event_deleted.php b/lib/classes/event/calendar_event_deleted.php index 933f0b075dc98..cdd013bf09925 100644 --- a/lib/classes/event/calendar_event_deleted.php +++ b/lib/classes/event/calendar_event_deleted.php @@ -85,7 +85,7 @@ protected function validate_data() { if (!isset($this->other['repeatid'])) { throw new \coding_exception('The \'repeatid\' value must be set in other.'); } - if (empty($this->other['name'])) { + if (!isset($this->other['name'])) { throw new \coding_exception('The \'name\' value must be set in other.'); } if (!isset($this->other['timestart'])) { diff --git a/lib/classes/event/calendar_event_updated.php b/lib/classes/event/calendar_event_updated.php index 0a810c297c495..86971414725b8 100644 --- a/lib/classes/event/calendar_event_updated.php +++ b/lib/classes/event/calendar_event_updated.php @@ -103,7 +103,7 @@ protected function validate_data() { if (!isset($this->other['repeatid'])) { throw new \coding_exception('The \'repeatid\' value must be set in other.'); } - if (empty($this->other['name'])) { + if (!isset($this->other['name'])) { throw new \coding_exception('The \'name\' value must be set in other.'); } if (!isset($this->other['timestart'])) { diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php index d0e11c14613bb..6e23c3b2878f7 100644 --- a/lib/grade/grade_item.php +++ b/lib/grade/grade_item.php @@ -1290,7 +1290,7 @@ public static function fix_duplicate_sortorder($courseid) { * @return string name */ public function get_name($fulltotal=false) { - if (!empty($this->itemname)) { + if (strval($this->itemname) !== '') { // MDL-10557 return format_string($this->itemname); diff --git a/lib/modinfolib.php b/lib/modinfolib.php index e8a3b9f37c3f2..c377faf904d73 100644 --- a/lib/modinfolib.php +++ b/lib/modinfolib.php @@ -492,7 +492,7 @@ public function __construct($course, $userid) { // Loop through each piece of module data, constructing it static $modexists = array(); foreach ($coursemodinfo->modinfo as $mod) { - if (empty($mod->name)) { + if (strval($mod->name) === '') { // something is wrong here continue; }