-
Bug
-
Resolution: Fixed
-
Major
-
3.11.5, 4.0
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
MOODLE_311_STABLE
-
It has been detected that, sometimes, the curl::get() call, when invoking a non-existing URL, can return an empty-string response.
(note that curl returns the error as response when there is any problem, but in this case, both the response and the error are empty).
This happens, for example, when running GHA jobs under windows and there isn't any web server running. The mod_lti generators set the URL to non-existing http://localhost/not/real/tool.php and, when lti_load_cartridge() is called, the curl::get() call returns empty string.
Note that under other environments (linux, macos, local windows with bash...) that doesn't happen and the error is returned as response (as expected):
Failed to connect to localhost port 80: Connection refused
|
But, as said, at very least under GHA Windows environment, empty-string is returned (link to job output with the empty-string failures).
Then, DOMDocument::loadXML($response) is called and that ends with an error, because that function doesn't accept empty contents to be processed.
ValueError: DOMDocument::loadXML(): Argument #1 ($source) must not be empty
|
And the problem is worse with PHP8, because the silent operator (@) is unable to do its work (maybe it was silenced ok with previous PHP versions).
So we need to control that situation in advance, and whenever an empty response is returned... instead of allowing the loadXML() to happen, throw the moodle_exception earlier, without waiting for libxml_get_errors() to do its job some lines later (too late).
- Testing discovered
-
MDL-73834 PHP8 libxml behaviour change: unwanted network requests (was: Slow LTI tests)
- Closed