diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index c67a3c9a2e1..aba44002cbe 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -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]; diff --git a/lib/dml/oci_native_moodle_database.php b/lib/dml/oci_native_moodle_database.php index d3d77175690..b8d55f3d1e0 100644 --- a/lib/dml/oci_native_moodle_database.php +++ b/lib/dml/oci_native_moodle_database.php @@ -361,6 +361,10 @@ class oci_native_moodle_database extends moodle_database { * @return array ($sql, $params) updated query and parameters */ protected function tweak_param_names($sql, array $params) { + global $CFG; + + require_once($CFG->libdir . '/ddllib.php'); + if (empty($params)) { return array($sql, $params); } @@ -368,8 +372,8 @@ class oci_native_moodle_database extends moodle_database { $newparams = array(); $searcharr = array(); // search => replace pairs foreach ($params as $name => $value) { - // Keep the name within the 30 chars limit always (prefixing/replacing) - if (strlen($name) <= 28) { + // Keep the name within the xmldb_field::NAME_MAX_LENGTH chars limit always (prefixing/replacing). + if (strlen($name) <= (xmldb_field::NAME_MAX_LENGTH - 2)) { $newname = 'o_' . $name; } else { $newname = 'o_' . substr($name, 2); diff --git a/lib/xmldb/xmldb.xsd b/lib/xmldb/xmldb.xsd index 5d119a6b3ee..016d391a2f6 100644 --- a/lib/xmldb/xmldb.xsd +++ b/lib/xmldb/xmldb.xsd @@ -10,13 +10,13 @@ - + - +