Skip to content

Commit

Permalink
MDL-29807 Fixed invalid add_record_snapshot references and also inexi…
Browse files Browse the repository at this point in the history
…stent check of empty short names
  • Loading branch information
jleyva committed Mar 17, 2014
1 parent 0a8ab74 commit eb625bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 6 additions & 3 deletions admin/webservice/forms.php
Expand Up @@ -158,9 +158,12 @@ function validation($data, $files) {
$errors = parent::validation($data, $files);

// Add field validation check for duplicate shortname.
if ($service = $DB->get_record('external_services', array('shortname' => $data['shortname']), '*', IGNORE_MULTIPLE)) {
if (empty($data['id']) || $service->id != $data['id']) {
$errors['shortname'] = get_string('shortnametaken', 'webservice', $service->name);
// Allow duplicated "empty" shortnames.
if (!empty($data['shortname'])) {
if ($service = $DB->get_record('external_services', array('shortname' => $data['shortname']), '*', IGNORE_MULTIPLE)) {
if (empty($data['id']) || $service->id != $data['id']) {
$errors['shortname'] = get_string('shortnametaken', 'webservice', $service->name);
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions admin/webservice/service.php
Expand Up @@ -84,7 +84,6 @@
'objectid' => $servicedata->id
);
$event = \core\event\webservice_service_created::create($params);
$event->add_record_snapshot('external_services', $servicedata);
$event->trigger();

//redirect to the 'add functions to service' page
Expand All @@ -99,7 +98,6 @@
'objectid' => $servicedata->id
);
$event = \core\event\webservice_service_updated::create($params);
$event->add_record_snapshot('external_services', $servicedata);
$event->trigger();
}

Expand Down

0 comments on commit eb625bc

Please sign in to comment.