mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-24322 detecting duplicate keys/fields and indexes - this prevents infinite looks later in code
This commit is contained in:
parent
f2a9be5f8a
commit
6496a019c9
@ -48,6 +48,11 @@ class xmldb_table extends xmldb_object {
|
||||
*/
|
||||
function addField(&$field, $after=NULL) {
|
||||
|
||||
/// Detect duplicates first
|
||||
if ($this->getField($field->getName())) {
|
||||
throw new coding_exception('Duplicate field '.$field->getName().' specified in table '.$this->getName());
|
||||
}
|
||||
|
||||
/// Calculate the previous and next fields
|
||||
$prevfield = NULL;
|
||||
$nextfield = NULL;
|
||||
@ -95,6 +100,11 @@ class xmldb_table extends xmldb_object {
|
||||
*/
|
||||
function addKey(&$key, $after=NULL) {
|
||||
|
||||
/// Detect duplicates first
|
||||
if ($this->getKey($key->getName())) {
|
||||
throw new coding_exception('Duplicate key '.$key->getName().' specified in table '.$this->getName());
|
||||
}
|
||||
|
||||
/// Calculate the previous and next keys
|
||||
$prevkey = NULL;
|
||||
$nextkey = NULL;
|
||||
@ -140,6 +150,11 @@ class xmldb_table extends xmldb_object {
|
||||
*/
|
||||
function addIndex(&$index, $after=NULL) {
|
||||
|
||||
/// Detect duplicates first
|
||||
if ($this->getIndex($index->getName())) {
|
||||
throw new coding_exception('Duplicate index '.$index->getName().' specified in table '.$this->getName());
|
||||
}
|
||||
|
||||
/// Calculate the previous and next indexes
|
||||
$previndex = NULL;
|
||||
$nextindex = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user