From a94e5a405d60b9dc455cd9bb799e204da8f2fbd2 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 21 Apr 2015 11:34:00 +0800 Subject: [PATCH] MDL-40811 uploaduser: Optimise testuser code --- admin/tool/uploaduser/locallib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/tool/uploaduser/locallib.php b/admin/tool/uploaduser/locallib.php index 1b5afd58481..4b7589cccec 100644 --- a/admin/tool/uploaduser/locallib.php +++ b/admin/tool/uploaduser/locallib.php @@ -413,9 +413,6 @@ function uu_check_custom_profile_data(&$data) { foreach ($data as $key => $value) { if (preg_match('/^profile_field_/', $key)) { $shortname = str_replace('profile_field_', '', $key); - $testuser = new stdClass(); - $testuser->{$key} = $value; - $testuser->id = $testuserid; if ($fields = $DB->get_records('user_info_field', array('shortname' => $shortname))) { foreach ($fields as $field) { require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php'); @@ -428,6 +425,9 @@ function uu_check_custom_profile_data(&$data) { } // Check for duplicate value. if (method_exists($formfield, 'edit_validate_field') ) { + $testuser = new stdClass(); + $testuser->{$key} = $value; + $testuser->id = $testuserid; $err = $formfield->edit_validate_field($testuser); if (!empty($err[$key])) { $data['status'][] = $err[$key].' ('.$key.')'; @@ -439,4 +439,4 @@ function uu_check_custom_profile_data(&$data) { } } return $noerror; -} \ No newline at end of file +}