All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.
At the same time, fix a few wrong function names,
provider data and param types, return statements...
In MDL-62853 a new clean_param(PARAM_PATH) was added to the
moodle_content_writer->get_path() method. And this caused some
Windows tests to start failing.
The problem is that clean_param(PARAM_PATH) does normalise directory
separators to be always forward backslashes and that's normally ok
but the get_path() method has some DIRECTORY_SEPARATOR dependent code
that stopped working under windows.
After analysing various solutions, and trying to keep the behavior
EXACTLY like it was before MDL-62853, but with the cleaning included
we have applied 2 changes:
b) Move the clean_param() to later within the array_map() function,
that way the code there, that uses DIRECTORY_SEPARATOR will continue
working the same.
b) As far as there are more DIRECTORY_SEPARATOR dependent code later
in the function, also perform a str_replace() to convert back to the
OS directory separator.
Those 2 points together (a and b) make the behavior to be 100% the
original one, with separators being kept and the paths being cleaned.
This solution corresponds 100% with the proposed fixes named 3) and
4) in the issue.
Final note... all that DIRECTORY_SEPARATOR maybe needs a review because
it really shouldn't be used unless strictly needed. But that falls out
from this issue which goal was to keep things safely working like they
were before the regression (but with the cleaning applied).
Before the patch, queries like:
SELECT 1 FROM dual UNION SELECT 2 FROM dual
were failing badly, with everything but the first numeric element
being ignored by the optimization.
So, being conservative, now we reduce the query being analysed,
ignoring any subquery, inline view (anything within parenthesis
in general) and, in the remaining query, if a boolean query (UNION,
MINUS, INTERSECT...) is found, we don't apply any optimization.
* We need to use is_numeric() in this case as is_int() would never
return true.
* Extend the supported cases, add support for SQL consisting just of
numerical value or selectinga numerical constant.
* Do not rely on any particulat letter case in provided SQL.
* Add unit tests for the new method. Even when it is a protected one, it
is an essential unit to be tested on its own.