From c3a1a66eaefac9e06385d125dd4edae3117cc9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 16 Dec 2021 10:35:03 +0100 Subject: [PATCH] Avoid deprecation warnings about libxml_disable_entity_loader in PHP 8.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/Updater/ChangesCheck.php | 10 +++++++--- lib/private/Updater/VersionCheck.php | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/private/Updater/ChangesCheck.php b/lib/private/Updater/ChangesCheck.php index 600c8db9a3c2c..e3ced6e5b123e 100644 --- a/lib/private/Updater/ChangesCheck.php +++ b/lib/private/Updater/ChangesCheck.php @@ -138,9 +138,13 @@ protected function queryChangesServer(string $uri, ChangesResult $entry): IRespo protected function extractData($body):array { $data = []; if ($body) { - $loadEntities = libxml_disable_entity_loader(true); - $xml = @simplexml_load_string($body); - libxml_disable_entity_loader($loadEntities); + if (\LIBXML_VERSION < 20900) { + $loadEntities = libxml_disable_entity_loader(true); + $xml = @simplexml_load_string($body); + libxml_disable_entity_loader($loadEntities); + } else { + $xml = @simplexml_load_string($body); + } if ($xml !== false) { $data['changelogURL'] = (string)$xml->changelog['href']; $data['whatsNew'] = []; diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php index ffa707d899093..d9f795796b8ce 100644 --- a/lib/private/Updater/VersionCheck.php +++ b/lib/private/Updater/VersionCheck.php @@ -95,9 +95,13 @@ public function check() { } if ($xml) { - $loadEntities = libxml_disable_entity_loader(true); - $data = @simplexml_load_string($xml); - libxml_disable_entity_loader($loadEntities); + if (\LIBXML_VERSION < 20900) { + $loadEntities = libxml_disable_entity_loader(true); + $data = @simplexml_load_string($xml); + libxml_disable_entity_loader($loadEntities); + } else { + $data = @simplexml_load_string($xml); + } if ($data !== false) { $tmp['version'] = (string)$data->version; $tmp['versionstring'] = (string)$data->versionstring;