Skip to content

Commit

Permalink
MDL-33682 backup: cope with sections called '0'
Browse files Browse the repository at this point in the history
It was not previously possible to have a section called 0 because of
bugs in the standard course formats, but we hit this with the OU course
format. You got an exception because backup settings tested to see if
their lable was empty, which means a section name of '0' was fatal.
Should work now.
  • Loading branch information
timhunt committed Jun 12, 2012
1 parent bb410a1 commit ff5d6f8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backup/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
case backup::TYPE_1SECTION :
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/backup:backupsection', $coursecontext);
if (!empty($section->name)) {
if ((string)$section->name !== '') {
$sectionname = format_string($section->name, true, array('context' => $coursecontext));
$heading = get_string('backupsection', 'backup', $sectionname);
$PAGE->navbar->add($sectionname);
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ public function process_section($data) {
// Section exists, update non-empty information
} else {
$section->id = $secrec->id;
if (empty($secrec->name)) {
if ((string)$secrec->name === '') {
$section->name = $data->name;
}
if (empty($secrec->summary)) {
Expand Down
2 changes: 1 addition & 1 deletion backup/util/factories/backup_factory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static function get_backup_section_task($format, $sectionid) {
throw new backup_task_exception('section_task_section_not_found', $sectionid);
}

return new backup_section_task(empty($section->name) ? $section->section : $section->name, $sectionid);
return new backup_section_task((string)$section->name !== '' ? $section->section : $section->name, $sectionid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion backup/util/ui/backup_ui_setting.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function get_static_value() {
* @param string $label
*/
public function set_label($label) {
if (empty($label) || $label !== clean_param($label, PARAM_TEXT)) {
if ((string)$label === '' || $label !== clean_param($label, PARAM_TEXT)) {
throw new base_setting_ui_exception('setting_invalid_ui_label');
}
$this->label = $label;
Expand Down

0 comments on commit ff5d6f8

Please sign in to comment.