MDL-76459 dml: Remove other remaining harcoded uses of old 28 & 30
Let's require lib/ddllib.php and use the constant properly, so we don't need to go searching for cases in future changes. They are a hand of files, but already are included often each time the database manager is included. Possible alternative for this, if we want to reduce the number of included files is to move the constants to xmldb_constants and only include that file, but I don't think that makes much sense. Also, fix the xmldb schema definition to validate table and column names with the new allowed lengths.
This commit is contained in:
@@ -891,6 +891,10 @@ abstract class moodle_database {
|
||||
* @return array (sql, params, type of params)
|
||||
*/
|
||||
public function fix_sql_params($sql, array $params=null) {
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->libdir . '/ddllib.php');
|
||||
|
||||
$params = (array)$params; // mke null array if needed
|
||||
$allowed_types = $this->allowed_param_types();
|
||||
|
||||
@@ -974,9 +978,9 @@ abstract class moodle_database {
|
||||
if (!array_key_exists($key, $params)) {
|
||||
throw new dml_exception('missingkeyinsql', $key, '');
|
||||
}
|
||||
if (strlen($key) > 30) {
|
||||
if (strlen($key) > xmldb_field::NAME_MAX_LENGTH) {
|
||||
throw new coding_exception(
|
||||
"Placeholder names must be 30 characters or shorter. '" .
|
||||
"Placeholder names must be " . xmldb_field::NAME_MAX_LENGTH . " characters or shorter. '" .
|
||||
$key . "' is too long.", $sql);
|
||||
}
|
||||
$finalparams[$key] = $params[$key];
|
||||
|
||||
Reference in New Issue
Block a user