Permalink
Browse files

MDL-38500 repository: Instance names must be unique

  • Loading branch information...
1 parent d8d636d commit 7b6ed67e0a877b94f45348fed545ede036c3caba @FMCorz FMCorz committed May 1, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 repository/lib.php
View
@@ -2698,8 +2698,9 @@ public function validation($data, $files) {
$sql = "SELECT count('x')
FROM {repository_instances} i, {repository} r
- WHERE r.type=:plugin AND r.id=i.typeid AND i.name=:name";
- if ($DB->count_records_sql($sql, array('name' => $data['name'], 'plugin' => $data['plugin'])) > 1) {
+ WHERE r.type=:plugin AND r.id=i.typeid AND i.name=:name AND i.contextid=:contextid";
+ $params = array('name' => $data['name'], 'plugin' => $this->plugin, 'contextid' => $this->contextid);
+ if ($DB->count_records_sql($sql, $params) > 0) {
$errors['name'] = get_string('erroruniquename', 'repository');
}

0 comments on commit 7b6ed67

Please sign in to comment.