MDL-76953 mod: deprecate libxml library method wrappers.

The `libxml_disable_entity_loader` method is deprecated since PHP8.0,
which is our minimum required version so we no longer need to support
calls to it using the current wrappers.
This commit is contained in:
Paul Holden 2023-06-16 15:11:39 +01:00
parent 1b1a15a308
commit 436a279dec
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
5 changed files with 14 additions and 15 deletions

View File

@ -117,11 +117,9 @@ function imscp_parse_structure($imscp, $context) {
*/
function imscp_parse_manifestfile($manifestfilecontents, $imscp, $context) {
$doc = new DOMDocument();
$oldentities = imscp_libxml_disable_entity_loader(true);
if (!$doc->loadXML($manifestfilecontents, LIBXML_NONET)) {
return null;
}
imscp_libxml_disable_entity_loader($oldentities);
// We put this fake URL as base in order to detect path changes caused by xml:base attributes.
$doc->documentURI = 'http://grrr/';
@ -221,11 +219,9 @@ function imscp_recursive_href($manifestfilename, $imscp, $context) {
}
$doc = new DOMDocument();
$oldentities = imscp_libxml_disable_entity_loader(true);
if (!$doc->loadXML($manifestfile->get_content(), LIBXML_NONET)) {
return null;
}
imscp_libxml_disable_entity_loader($oldentities);
$xmlresources = $doc->getElementsByTagName('resource');
foreach ($xmlresources as $res) {
@ -283,11 +279,11 @@ function imscp_recursive_item($xmlitem, $level, $resources) {
*
* @param bool $value
* @return bool
*
* @deprecated since Moodle 4.3
*/
function imscp_libxml_disable_entity_loader(bool $value): bool {
if (PHP_VERSION_ID < 80000) {
return (bool)libxml_disable_entity_loader($value);
}
debugging(__FUNCTION__ . '() is deprecated, please do not use it any more', DEBUG_DEVELOPER);
return true;
}

View File

@ -1,5 +1,9 @@
This files describes API changes in the imscp code.
=== 4.3 ===
* The `imscp_libxml_disable_entity_loader` method is deprecated, as it is no longer required from PHP 8.0
=== 3.0 ===
* External function mod_imscp_external::get_imscps_by_courses returned parameter "name" has been changed to PARAM_RAW,

View File

@ -4477,7 +4477,6 @@ function lti_load_cartridge($url, $map, $propertiesmap = array()) {
// TODO MDL-46023 Replace this code with a call to the new library.
$origerrors = libxml_use_internal_errors(true);
$origentity = lti_libxml_disable_entity_loader(true);
libxml_clear_errors();
$document = new DOMDocument();
@ -4489,7 +4488,6 @@ function lti_load_cartridge($url, $map, $propertiesmap = array()) {
libxml_clear_errors();
libxml_use_internal_errors($origerrors);
lti_libxml_disable_entity_loader($origentity);
if (count($errors) > 0) {
$message = 'Failed to load cartridge.';
@ -4584,10 +4582,10 @@ function lti_new_access_token($typeid, $scopes) {
*
* @param bool $value
* @return bool
*
* @deprecated since Moodle 4.3
*/
function lti_libxml_disable_entity_loader(bool $value): bool {
if (PHP_VERSION_ID < 80000) {
return (bool)libxml_disable_entity_loader($value);
}
debugging(__FUNCTION__ . '() is deprecated, please do not use it any more', DEBUG_DEVELOPER);
return true;
}

View File

@ -70,13 +70,10 @@ if ($consumerkey === false) {
}
// TODO MDL-46023 Replace this code with a call to the new library.
$origentity = lti_libxml_disable_entity_loader(true);
$xml = simplexml_load_string($rawbody);
if (!$xml) {
lti_libxml_disable_entity_loader($origentity);
throw new Exception('Invalid XML content');
}
lti_libxml_disable_entity_loader($origentity);
$body = $xml->imsx_POXBody;
foreach ($body->children() as $child) {

View File

@ -1,5 +1,9 @@
This files describes API changes in the lti code.
=== 4.3 ===
* The `lti_libxml_disable_entity_loader` method is deprecated, as it is no longer required from PHP 8.0
=== 4.2 ===
* get_jwt_claim_mappings() function has been added to service_base class. It allows a service subplugin to be