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:
Eloy Lafuente (stronk7)
2023-09-02 09:22:13 +02:00
parent 8996ee0eaa
commit d2b6a1b7f3
3 changed files with 14 additions and 6 deletions
+6 -2
View File
@@ -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);