diff --git a/customfield/classes/handler.php b/customfield/classes/handler.php index f2c28aaed71..2d81404bb1c 100644 --- a/customfield/classes/handler.php +++ b/customfield/classes/handler.php @@ -652,7 +652,7 @@ abstract class handler { } $data->instance_form_definition($mform); $field = $data->get_field()->to_record(); - if (strlen($field->description)) { + if (strlen((string)$field->description)) { // Add field description. $context = $this->get_configuration_context(); $value = file_rewrite_pluginfile_urls($field->description, 'pluginfile.php', diff --git a/customfield/field/text/tests/plugin_test.php b/customfield/field/text/tests/plugin_test.php index 9898aee15af..dc686ad0f86 100644 --- a/customfield/field/text/tests/plugin_test.php +++ b/customfield/field/text/tests/plugin_test.php @@ -47,7 +47,7 @@ class plugin_test extends \advanced_testcase { $this->cfields[1] = $this->get_generator()->create_field( ['categoryid' => $this->cfcat->get('id'), 'shortname' => 'myfield1', 'type' => 'text', - 'configdata' => ['maxlength' => 30, 'displaysize' => 50]]); + 'configdata' => ['maxlength' => 30, 'displaysize' => 50], 'description' => null]); $this->cfields[2] = $this->get_generator()->create_field( ['categoryid' => $this->cfcat->get('id'), 'shortname' => 'myfield2', 'type' => 'text', 'configdata' => ['required' => 1, 'maxlength' => 30, 'displaysize' => 50]]); diff --git a/customfield/tests/generator/lib.php b/customfield/tests/generator/lib.php index 06cfe479f97..35815a9e053 100644 --- a/customfield/tests/generator/lib.php +++ b/customfield/tests/generator/lib.php @@ -97,7 +97,7 @@ class core_customfield_generator extends component_generator_base { if (!isset($record->shortname)) { $record->shortname = "fld$i"; } - if (!isset($record->description)) { + if (!property_exists($record, 'description')) { $record->description = "Field $i description"; } if (!isset($record->descriptionformat)) {