Skip to content

Commit

Permalink
MDL-52335 mod_lti: php7 compatibility in variable syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Dec 3, 2015
1 parent 545d2c9 commit 6698b06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mod/lti/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ function lti_parse_custom_parameter($toolproxy, $tool, $params, $value, $islti2)
$value = $params[$val];
} else {
$valarr = explode('->', substr($val, 1), 2);
$value = "{${$valarr[0]}->$valarr[1]}";
$value = "{${$valarr[0]}->{$valarr[1]}}";
$value = str_replace('<br />' , ' ', $value);
$value = str_replace('<br>' , ' ', $value);
$value = format_string($value);
Expand Down
9 changes: 9 additions & 0 deletions mod/lti/tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@
class mod_lti_locallib_testcase extends advanced_testcase {

public function test_split_custom_parameters() {
$this->resetAfterTest();

$tool = new stdClass();
$tool->enabledcapability = '';
$tool->parameter = '';
$this->assertEquals(lti_split_custom_parameters(null, $tool, array(), "x=1\ny=2", false),
array('custom_x' => '1', 'custom_y' => '2'));

Expand All @@ -76,6 +79,12 @@ public function test_split_custom_parameters() {
$this->assertEquals(lti_split_custom_parameters(null, $tool, array(),
'Complex!@#$^*(){}[]KEY=Complex!@#$^*;(){}[]½Value', false),
array('custom_complex____________key' => 'Complex!@#$^*;(){}[]½Value'));

// Test custom parameter that returns $USER property.
$user = $this->getDataGenerator()->create_user(array('middlename' => 'SOMETHING'));
$this->setUser($user);
$this->assertEquals(array('custom_x' => '1', 'custom_y' => 'SOMETHING'),
lti_split_custom_parameters(null, $tool, array(), "x=1\ny=\$Person.name.middle", false));
}

/**
Expand Down

0 comments on commit 6698b06

Please sign in to comment.