mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-32112 validate field name restrictions in sql_generator
This commit is contained in:
parent
c856a1f60b
commit
6cfade8f5a
2 changed files with 56 additions and 1 deletions
|
@ -701,7 +701,16 @@ class xmldb_field extends xmldb_object {
|
|||
*/
|
||||
function validateDefinition(xmldb_table $xmldb_table=null) {
|
||||
if (!$xmldb_table) {
|
||||
return 'Invalid xmldb_field->validateDefinition() call, $xmldb_table si required.';
|
||||
return 'Invalid xmldb_field->validateDefinition() call, $xmldb_table is required.';
|
||||
}
|
||||
|
||||
$name = $this->getName();
|
||||
if (strlen($name) > 30) {
|
||||
return 'Invalid field name in table {'.$xmldb_table->getName().'}: field "'.$this->getName().'" name is too long.'
|
||||
.' Limit is 30 chars.';
|
||||
}
|
||||
if (!preg_match('/^[a-z][a-z0-9_]*$/', $name)) {
|
||||
return 'Invalid field name in table {'.$xmldb_table->getName().'}: field "'.$this->getName().'" name includes invalid characters.';
|
||||
}
|
||||
|
||||
switch ($this->getType()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue