diff --git a/admin/tool/uploaduser/index.php b/admin/tool/uploaduser/index.php
index ad36657a213..e687fe32214 100644
--- a/admin/tool/uploaduser/index.php
+++ b/admin/tool/uploaduser/index.php
@@ -232,8 +232,8 @@ if ($formdata = $mform2->is_cancelled()) {
if (isset($USER->$key) and is_array($USER->$key)) {
// this must be some hacky field that is abusing arrays to store content and format
$user->$key = array();
- $user->$key['text'] = $value;
- $user->$key['format'] = FORMAT_MOODLE;
+ $user->{$key['text']} = $value;
+ $user->{$key['format']} = FORMAT_MOODLE;
} else {
$user->$key = trim($value);
}
diff --git a/admin/tests/behat/upload_users.feature b/admin/tool/uploaduser/tests/behat/upload_users.feature
similarity index 58%
rename from admin/tests/behat/upload_users.feature
rename to admin/tool/uploaduser/tests/behat/upload_users.feature
index 0c4b1dafe07..32aa9631c35 100644
--- a/admin/tests/behat/upload_users.feature
+++ b/admin/tool/uploaduser/tests/behat/upload_users.feature
@@ -1,4 +1,4 @@
-@core @core_admin @_file_upload
+@tool @tool_uploaduser @_file_upload
Feature: Upload users
In order to add users to the system
As an admin
@@ -39,3 +39,25 @@ Feature: Upload users
And I follow "Groups"
And I set the field "groups" to "Section 1 (1)"
And the "members" select box should contain "Tom Jones"
+
+ @javascript
+ Scenario: Upload users with custom profile fields
+ # Create user profile field.
+ Given I log in as "admin"
+ And I navigate to "User profile fields" node in "Site administration > Users > Accounts"
+ And I set the field "datatype" to "Text area"
+ And I set the following fields to these values:
+ | Short name | superfield |
+ | Name | Super field |
+ And I click on "Save changes" "button"
+ # Upload users.
+ When I navigate to "Upload users" node in "Site administration > Users > Accounts"
+ And I upload "lib/tests/fixtures/upload_users_profile.csv" file to "File" filemanager
+ And I press "Upload users"
+ And I press "Upload users"
+ # Check that users were created and the superfield is filled.
+ And I navigate to "Browse list of users" node in "Site administration > Users > Accounts"
+ And I follow "Tom Jones"
+ And I should see "Super field"
+ And I should see "The big guy"
+ And I log out
diff --git a/lib/jabber/XMPP/XMLStream.php b/lib/jabber/XMPP/XMLStream.php
index 73ab3fe9ec6..5c71426200f 100644
--- a/lib/jabber/XMPP/XMLStream.php
+++ b/lib/jabber/XMPP/XMLStream.php
@@ -564,7 +564,7 @@ class XMPPHP_XMLStream {
if ($searchxml !== null) {
if($handler[2] === null) $handler[2] = $this;
$this->log->log("Calling {$handler[1]}", XMPPHP_Log::LEVEL_DEBUG);
- $handler[2]->$handler[1]($this->xmlobj[2]);
+ $handler[2]->{$handler[1]}($this->xmlobj[2]);
}
}
}
@@ -578,13 +578,13 @@ class XMPPHP_XMLStream {
if($searchxml !== null and $searchxml->name == $handler[0] and ($searchxml->ns == $handler[1] or (!$handler[1] and $searchxml->ns == $this->default_ns))) {
if($handler[3] === null) $handler[3] = $this;
$this->log->log("Calling {$handler[2]}", XMPPHP_Log::LEVEL_DEBUG);
- $handler[3]->$handler[2]($this->xmlobj[2]);
+ $handler[3]->{$handler[2]}($this->xmlobj[2]);
}
}
foreach($this->idhandlers as $id => $handler) {
if(array_key_exists('id', $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs['id'] == $id) {
if($handler[1] === null) $handler[1] = $this;
- $handler[1]->$handler[0]($this->xmlobj[2]);
+ $handler[1]->{$handler[0]}($this->xmlobj[2]);
#id handlers are only used once
unset($this->idhandlers[$id]);
break;
@@ -640,7 +640,7 @@ class XMPPHP_XMLStream {
if($handler[2] === null) {
$handler[2] = $this;
}
- $handler[2]->$handler[1]($payload);
+ $handler[2]->{$handler[1]}($payload);
}
}
foreach($this->until as $key => $until) {
diff --git a/lib/jabber/readme_moodle.txt b/lib/jabber/readme_moodle.txt
index f8328fbbb73..205c214f61c 100644
--- a/lib/jabber/readme_moodle.txt
+++ b/lib/jabber/readme_moodle.txt
@@ -1,3 +1,4 @@
Description of XMPPHP (aka jabber) version 0.1rc2-r77 library import into Moodle
MDL-20876 - replaced deprecated split() with explode()
+MDL-52335 - PHP7 variable syntax changes
diff --git a/lib/tests/fixtures/upload_users_profile.csv b/lib/tests/fixtures/upload_users_profile.csv
new file mode 100644
index 00000000000..b15db768103
--- /dev/null
+++ b/lib/tests/fixtures/upload_users_profile.csv
@@ -0,0 +1,3 @@
+username,password,firstname,lastname,email,profile_field_superfield
+jonest,verysecret,Tom,Jones,jonest@someplace.edu,The big guy
+reznort,somesecret,Trent,Reznor,reznort@someplace.edu,Loves cats
diff --git a/mod/data/field/textarea/field.class.php b/mod/data/field/textarea/field.class.php
index a6e1b4cf925..ddf54861871 100644
--- a/mod/data/field/textarea/field.class.php
+++ b/mod/data/field/textarea/field.class.php
@@ -199,7 +199,7 @@ class data_field_textarea extends data_field_base {
// the value will be retrieved by file_get_submitted_draft_itemid, do not need to save in DB
return true;
} else {
- $content->$names[2] = clean_param($value, PARAM_NOTAGS); // content[1-4]
+ $content->{$names[2]} = clean_param($value, PARAM_NOTAGS); // content[1-4]
}
} else {
$content->content = clean_param($value, PARAM_CLEAN);
diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php
index 2306de3d4c3..9840dba6181 100644
--- a/mod/lti/locallib.php
+++ b/mod/lti/locallib.php
@@ -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('
' , ' ', $value);
$value = str_replace('
' , ' ', $value);
$value = format_string($value);
diff --git a/mod/lti/tests/locallib_test.php b/mod/lti/tests/locallib_test.php
index 6b185aa1688..350e5aa43bb 100644
--- a/mod/lti/tests/locallib_test.php
+++ b/mod/lti/tests/locallib_test.php
@@ -63,8 +63,11 @@ require_once($CFG->dirroot . '/mod/lti/servicelib.php');
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'));
@@ -76,6 +79,12 @@ class mod_lti_locallib_testcase extends advanced_testcase {
$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));
}
/**