This has been generated running the following Sniffs, all
them part of the Moodle's CodeSniffer standard:
- PSR12.Functions.ReturnTypeDeclaration
- PSR12.Functions.NullableTypeDeclaration
- moodle.Methods.MethodDeclarationSpacing
- Squiz.Whitespace.ScopeKeywordSpacing
All them are, exclusively, about correct spacing, so the changes
are, all them, only white space changes.
Only exceptions to the above are 3 changes what were setting the
return type in a new line, and, when that happens, the closing
parenthesis (bracket) has to go to the same line than the colon.
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.
With Oracle 19 being the minimum version for Moodle >= 4.1, now
we can safely raise the table and column length limits by a
considerable amount.
In both tables and columns the new limit it 63, coming from PostgreSQL,
that is the one now having the more restrictive limit.
1) NP with columns, let's allow up to 63 ascii chars (bytes) there.
2) But, for table names, now we need to specify a maximum prefix length,
to know how many chars we leave remaining for table names (without
prefix). 63 - 10 (max prefix length) = 53 ascii chars (bytes).
So, in this patch, we are introducing a new constant:
xmldb_table::PREFIX_MAX_LENGTH = 10
That will be used to:
- Validate that we aren't using a prefix longer than it.
- Calculate the final table limit that will be 63 minus
the prefix max length.
Details added to 4.2 main upgrade.txt file.
Also, update related to tests to (near) always use the constants
so they won't need modification in the future.
@const is not a valid phpdoc tag and @var should be used to
document both classes properties and constants (no matter how
weird that may sound, heh).
Link to (draft right now) PHP-FIG:
https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc-tags.md#518-var
So, with this commit we are just replacing all uses by the correct
@var one. Note that the type is entirely optional, in fact I think
that there isn't much need of it for constants because it's obvious
for both humans and machines which the type is. But, as far as it's
also correct to specify it, we haven't modified that detail.
The only detail modified are the cases where the constant name was
specified in the phpdoc, that's not needed, hence, the names have
been removed from there when present (a couple of cases).
Default value of the $flag argument changed in PHP 8.1 from ENT_COMPAT to ENT_QUOTES | ENT_SUBSTITUTE
To ensure consistent behavior across different PHP version the second parameter is now required for the functions:
htmlspecialchars(), htmlentities(), htmlspecialchars_decode(), html_entity_decode() and get_html_translation_table()
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).
As discussed in MDLSITE-6397, all Moodle code files should end with
single Unix-style end of line character. Files created and edited
through the XMLDB editor should follow this rule, too.
Starting with Moodle 3.5 the XMLDB->PATH attribute is checked
to be correct and pointing to the correct plugin directory.
It only was used for writing PHP savepoints code, but better we
ask for strict correctness.
With this patch applied, neither the XMLDB Editor neither install
will be able to load a file with wrong PATH anymore.
The patch increases the maximum supported precision (total number of
digits) for numeric (decimal) fields to 38 digits (current limit on
Oracle and MSSQL).
Additionally, we add our own limit for the whole number part of numeric
fields so they are no longer than integer fields (20 digits). This is to
make it easier to eventually convert from one field type to another.
Note that PHP floats commonly support precision of roughly 15 digits
anyway.
We are going to unify the maximum supported precision of all numeric
fields to 38 digits (which are the current Oracle and MSSQL limits). Get
rid of hard-coded exceptions for longer fields.