mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-56459 competency: Invalid use of indirect property key
This change ensures that PHP7 and earlier work the same way. Before the patch PHP < 7 would not expand the property as we expected it. More information here: http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.variable-handling.indirect
This commit is contained in:
parent
b4d6669dd0
commit
0eda810d17
2 changed files with 6 additions and 3 deletions
2
competency/classes/external/exporter.php
vendored
2
competency/classes/external/exporter.php
vendored
|
@ -158,7 +158,7 @@ abstract class exporter {
|
||||||
} else if ($definition['type'] === PARAM_TEXT) {
|
} else if ($definition['type'] === PARAM_TEXT) {
|
||||||
if (!empty($definition['multiple'])) {
|
if (!empty($definition['multiple'])) {
|
||||||
foreach ($data->$property as $key => $value) {
|
foreach ($data->$property as $key => $value) {
|
||||||
$data->$property[$key] = external_format_string($value, $context->id);
|
$data->{$property}[$key] = external_format_string($value, $context->id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$data->$property = external_format_string($data->$property, $context->id);
|
$data->$property = external_format_string($data->$property, $context->id);
|
||||||
|
|
|
@ -111,6 +111,9 @@ class core_competency_exporter_testcase extends advanced_testcase {
|
||||||
$output = $PAGE->get_renderer('tool_lp');
|
$output = $PAGE->get_renderer('tool_lp');
|
||||||
|
|
||||||
$result = $exporter->export($output);
|
$result = $exporter->export($output);
|
||||||
|
|
||||||
|
$this->assertSame('Another string', $result->otherstring);
|
||||||
|
$this->assertSame(array('String a', 'String b'), $result->otherstrings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,8 +133,8 @@ class core_competency_testable_exporter extends \core_competency\external\export
|
||||||
|
|
||||||
protected function get_other_values(renderer_base $output) {
|
protected function get_other_values(renderer_base $output) {
|
||||||
return array(
|
return array(
|
||||||
'otherstring' => 'An other string',
|
'otherstring' => 'Another <strong>string</strong>',
|
||||||
'otherstrings' => array('String a', 'String b')
|
'otherstrings' => array('String a', 'String <strong>b</strong>')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue