MDL-75977 xmldb: Avoid using null params on built-in DB functions
This changes a couple of cases, in postgres and oracle where we were trying to calculate strlen() on null values (that causes a PHP 8.1 warning). Also, at the same time, fixing another case in xmldb_field, it was detected that it had a bug around precision (being set to the value of type), being used as object property, when it's not, so it was also fixed by moving the code logic a little bit. Note that the bug has been there since inception because there isn't any code in Moodle using that ->precision property. It was just detected thanks to PHP 8.2, but that's another story. :-) Verified that with the patch: - All DBs can be installed (phpunit install) - Both DDL and DML pass without any ddl/dml warning (in all DBs).
This commit is contained in:
@@ -545,7 +545,7 @@ class pgsql_native_moodle_database extends moodle_database {
|
||||
$tablename = $this->prefix.$table;
|
||||
|
||||
$sql = "SELECT a.attnum, a.attname AS field, t.typname AS type, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef,
|
||||
CASE WHEN a.atthasdef THEN pg_catalog.pg_get_expr(d.adbin, d.adrelid) END AS adsrc
|
||||
CASE WHEN a.atthasdef THEN pg_catalog.pg_get_expr(d.adbin, d.adrelid) ELSE '' END AS adsrc
|
||||
FROM pg_catalog.pg_class c
|
||||
JOIN pg_catalog.pg_namespace as ns ON ns.oid = c.relnamespace
|
||||
JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
|
||||
|
||||
Reference in New Issue
Block a user