Skip to content

Commit

Permalink
Merge pull request #33024 from nextcloud/backport/29862/stable23
Browse files Browse the repository at this point in the history
[stable23] Avoid deprecation warnings about libxml_disable_entity_loader in PHP 8+
  • Loading branch information
CarlSchwan authored Jul 5, 2022
2 parents 661f608 + ec7c8e8 commit acdb08b
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 acdb08b

Please sign in to comment.