Skip to content

Commit

Permalink
Avoid deprecation warnings about libxml_disable_entity_loader in PHP 8.1
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Jun 28, 2022
1 parent 9f3e64d commit ec7c8e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions lib/private/Updater/ChangesCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = [];
Expand Down
10 changes: 7 additions & 3 deletions lib/private/Updater/VersionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ec7c8e8

Please sign in to comment.