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.
moodle_content_writer::get_context_path() now includes the context
id in the path to ensure that it will always generate unique paths
even when the context names are not unique.
The tests do not actually do anything, they just make sure that the
method signature is correct on the given PHP version. They are mostly
relevant and useful on 3.3.
There were two major issues with the previous implementation:
* The exported folder name was localised so it was "Files" or "Soubory"
etc depending on the current language. Yet URLs referring to the files
in that folder were always rewritten with hard-coded English "files".
* Files from all fileareas and itemids were all exported to a single
target directory. So if there were two files with the same name being
exported from multiple areas (such as submission_content and
submission_attachment in the workshop module), one would overwrite
another.
The patch addresses these issues as follows:
* To unify the folder name and also to minimise the risk of conflict
with a subcontext folder, we now always export stored files under
"_files" folder.
* Under that folder, there is a subdirectory with the area name and then
eventually another subdirectory with non-zero itemid. And there
finally the stored_file is exported to under its own file path.