From fa35ed9955209be31c8d5d3a19741eb7e4b242f3 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 30fbe90a769..ed9a4d4cd22 100644 --- a/admin/tool/uploaduser/locallib.php +++ b/admin/tool/uploaduser/locallib.php @@ -412,9 +412,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'); @@ -427,6 +424,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.')'; @@ -438,4 +438,4 @@ function uu_check_custom_profile_data(&$data) { } } return $noerror; -} \ No newline at end of file +}